commit fa0049219b560fe692846c5d91dde9cfd14559d5 Author: Riviera Date: Wed Dec 6 19:54:23 2023 +0000 Updating things diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab29fc5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.mp3 +*.wav +*.bak +*.webm +.* +!.gitignore diff --git a/mixer.scd b/mixer.scd new file mode 100644 index 0000000..bf5999a --- /dev/null +++ b/mixer.scd @@ -0,0 +1,209 @@ +s.options.numOutputBusChannels = 4; + +( +s.waitForBoot({ + ~python_server = NetAddr("127.0.0.1", 57120); + ~python_server.sendMsg("/hello", "supercollider"); + ~begin_00 = Condition(); + ~begin_01 = Condition(); + + ~begin_02 = Condition(); + ~begin_03 = Condition(); + + ~begin_04 = Condition(); + ~begin_05 = Condition(); + + ~begin_06 = Condition(); + ~begin_07 = Condition(); + + ( + OSCFunc({~begin_00.unhang()}, '/begin/00', recvPort: 58110); + ); + + ( + OSCFunc({~begin_01.unhang()}, '/begin/01', recvPort: 58110); + ); + + ( + OSCFunc({~begin_02.unhang()}, '/begin/02', recvPort: 58110); + ); + + ( + OSCFunc({~begin_03.unhang()}, '/begin/03', recvPort: 58110); + ); + + ( + OSCFunc({~begin_04.unhang()}, '/begin/04', recvPort: 58110); + ); + + ( + OSCFunc({~begin_05.unhang()}, '/begin/05', recvPort: 58110); + ); + + ( + OSCFunc({~begin_06.unhang()}, '/begin/06', recvPort: 58110); + ); + + ( + OSCFunc({~begin_07.unhang()}, '/begin/07', recvPort: 58110); + ); + + Routine({ + loop { + ~begin_00.wait + ( + OSCdef.new(\begin_00, + {|msg, time, addr, recvPort| + ~sig_00 = msg[1]}, '/begin/00', recvPort: 58110;) + ); + ~sig_00.postln; + ~mono_00 = Mix.new(~sig_00); + ~buffer_00 = Buffer.readChannel(s, ~mono_00, + channels: 0); // prevent errors + ~synth_00 = SynthDef("zero",{ arg out = 0, bufnum; + Out.ar( out, + PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: 2) + ); + }); + ~synth_00.play(s, [\bufnum, ~buffer_00]).onFree {~python_server.sendMsg( + "/done00", ~sig_00)}; + ~begin_01.wait + ( + OSCdef.new(\begin_01, + {|msg, time, addr, recvPort| + ~sig_01 = msg[1]}, '/begin/01', recvPort: 58110;) + ); + ~sig_01.postln; + ~mono_01 = Mix.new(~sig_01); + ~buffer_01 = Buffer.readChannel(s, ~mono_01, + channels: 0); // prevent errors + ~synth_01 = SynthDef("one",{ arg out = 0, bufnum; + Out.ar( out, + PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: 2) + ); + }); + ~synth_01.play(s, [\bufnum, ~buffer_01]).onFree {~python_server.sendMsg( + "/done01", ~sig_01)}; + } + }).play; + + + Routine({ + loop { + ~begin_02.wait + ( + OSCdef.new(\begin_02, + {|msg, time, addr, recvPort| + ~sig_02 = msg[1]}, '/begin/02', recvPort: 58110;) + ); + ~sig_02.postln; + ~mono_02 = Mix.new(~sig_02); + ~buffer_02 = Buffer.readChannel(s, ~mono_02, + channels: 0); // prevent errors + ~synth_02 = SynthDef("two",{ arg out = 1, bufnum; + Out.ar( out, + PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: 2) + ); + }); + ~synth_02.play(s, [\bufnum, ~buffer_02]).onFree {~python_server.sendMsg( + "/done02", ~sig_02)}; + ~begin_03.wait + ( + OSCdef.new(\begin_03, + {|msg, time, addr, recvPort| + ~sig_03 = msg[1]}, '/begin/03', recvPort: 58110;) + ); + ~sig_03.postln; + ~mono_03 = Mix.new(~sig_03); + ~buffer_03 = Buffer.readChannel(s, ~mono_03, + channels: 0); // prevent errors + ~synth_03 = SynthDef("three",{ arg out = 1, bufnum; + Out.ar( out, + PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: 2) + ); + }); + ~synth_03.play(s, [\bufnum, ~buffer_03]).onFree {~python_server.sendMsg( + "/done03", ~sig_03)}; + } + }).play; + + Routine({ + loop { + ~begin_04.wait + ( + OSCdef.new(\begin_04, + {|msg, time, addr, recvPort| + ~sig_04 = msg[1]}, '/begin/04', recvPort: 58110;) + ); + ~sig_04.postln; + ~mono_04 = Mix.new(~sig_04); + ~buffer_04 = Buffer.readChannel(s, ~mono_04, + channels: 0); // prevent errors + ~synth_04 = SynthDef("four",{ arg out = 2, bufnum; + Out.ar( out, + PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: 2) + ); + }); + ~synth_04.play(s, [\bufnum, ~buffer_04]).onFree {~python_server.sendMsg( + "/done04", ~sig_04)}; + ~begin_05.wait + ( + OSCdef.new(\begin_05, + {|msg, time, addr, recvPort| + ~sig_05 = msg[1]}, '/begin/05', recvPort: 58110;) + ); + ~sig_05.postln; + ~mono_05 = Mix.new(~sig_05); + ~buffer_05 = Buffer.readChannel(s, ~mono_05, + channels: 0); // prevent errors + ~synth_05 = SynthDef("five",{ arg out = 2, bufnum; + Out.ar( out, + PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: 2) + ); + }); + ~synth_05.play(s, [\bufnum, ~buffer_05]).onFree {~python_server.sendMsg( + "/done05", ~sig_05)}; + } + }).play; + + + Routine({ + loop { + ~begin_06.wait + ( + OSCdef.new(\begin_06, + {|msg, time, addr, recvPort| + ~sig_06 = msg[1]}, '/begin/06', recvPort: 58110;) + ); + ~sig_06.postln; + ~mono_06 = Mix.new(~sig_06); + ~buffer_06 = Buffer.readChannel(s, ~mono_06, + channels: 0); // prevent errors + ~synth_06 = SynthDef("six",{ arg out = 3, bufnum; + Out.ar( out, + PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: 2) + ); + }); + ~synth_06.play(s, [\bufnum, ~buffer_06]).onFree {~python_server.sendMsg( + "/done06", ~sig_06)}; + ~begin_07.wait + ( + OSCdef.new(\begin_07, + {|msg, time, addr, recvPort| + ~sig_07 = msg[1]}, '/begin/07', recvPort: 58110;) + ); + ~sig_07.postln; + ~mono_07 = Mix.new(~sig_07); + ~buffer_07 = Buffer.readChannel(s, ~mono_07, + channels: 0); // prevent errors + ~synth_07 = SynthDef("seven",{ arg out = 3, bufnum; + Out.ar( out, + PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: 2) + ); + }); + ~synth_07.play(s, [\bufnum, ~buffer_07]).onFree {~python_server.sendMsg( + "/done07", ~sig_07)}; + } + }).play; +}); +) diff --git a/scmixer.sh b/scmixer.sh new file mode 100755 index 0000000..6086737 --- /dev/null +++ b/scmixer.sh @@ -0,0 +1,3 @@ +#!/bin/bash +export QT_QPA_PLATFORM=offscreen +sclang -D /home/xpub/mixer.scd diff --git a/server.py b/server.py new file mode 100755 index 0000000..312f102 --- /dev/null +++ b/server.py @@ -0,0 +1,128 @@ +import argparse +import subprocess +from pythonosc.dispatcher import Dispatcher +from pythonosc import osc_server +from pythonosc import udp_client +from typing import List, Any + +client = udp_client.SimpleUDPClient("127.0.0.1", 58110) + +def send_message(channel, message): + print("will send a message ", channel, message) + client.send_message(channel, message) + +def track_0(): + cmd_0 = "ffmpeg -y -i \"$(tree -if /home/xpub/audio_0 | grep -Eo '^(.*/)([^/]*)\.mp3$' | shuf -n 1)\" /home/xpub/wav_files/00.wav" + proc_0 = subprocess.Popen(cmd_0,shell=True) + wav_0 = proc_0.communicate()[0] + +def track_1(): + cmd_1 = "ffmpeg -y -i \"$(tree -if /home/xpub/audio_0 | grep -Eo '^(.*/)([^/]*)\.mp3$' | shuf -n 1)\" /home/xpub/wav_files/01.wav" + proc_1 = subprocess.Popen(cmd_1,shell=True) + wav_1 = proc_1.communicate()[0] + +def track_2(): + cmd_2 = "ffmpeg -y -i \"$(tree -if /home/xpub/audio_1 | grep -Eo '^(.*/)([^/]*)\.mp3$' | shuf -n 1)\" /home/xpub/wav_files/02.wav" + proc_2 = subprocess.Popen(cmd_2,shell=True) + wav_2 = proc_2.communicate()[0] + +def track_3(): + cmd_3 = "ffmpeg -y -i \"$(tree -if /home/xpub/audio_1 | grep -Eo '^(.*/)([^/]*)\.mp3$' | shuf -n 1)\" /home/xpub/wav_files/03.wav" + proc_3 = subprocess.Popen(cmd_3,shell=True) + wav_3 = proc_3.communicate()[0] + +def track_4(): + cmd_4 = "ffmpeg -y -i \"$(tree -if /home/xpub/audio_2 | grep -Eo '^(.*/)([^/]*)\.mp3$' | shuf -n 1)\" /home/xpub/wav_files/04.wav" + proc_4 = subprocess.Popen(cmd_4,shell=True) + wav_4 = proc_4.communicate()[0] + +def track_5(): + cmd_5 = "ffmpeg -y -i \"$(tree -if /home/xpub/audio_2 | grep -Eo '^(.*/)([^/]*)\.mp3$' | shuf -n 1)\" /home/xpub/wav_files/05.wav" + proc_5 = subprocess.Popen(cmd_5,shell=True) + wav_5 = proc_5.communicate()[0] + +def track_6(): + cmd_6 = "ffmpeg -y -i \"$(tree -if /home/xpub/audio_3 | grep -Eo '^(.*/)([^/]*)\.mp3$' | shuf -n 1)\" /home/xpub/wav_files/06.wav" + proc_6 = subprocess.Popen(cmd_6,shell=True) + wav_6 = proc_6.communicate()[0] + +def track_7(): + cmd_7 = "ffmpeg -y -i \"$(tree -if /home/xpub/audio_3 | grep -Eo '^(.*/)([^/]*)\.mp3$' | shuf -n 1)\" /home/xpub/wav_files/07.wav" + proc_7 = subprocess.Popen(cmd_7,shell=True) + wav_7 = proc_7.communicate()[0] + +def init(address: str, *args: List[Any]) -> None: + track_0() + send_message("/begin/00", "/home/xpub/wav_files/00.wav") + track_2() + send_message("/begin/02", "/home/xpub/wav_files/02.wav") + track_4() + send_message("/begin/04", "/home/xpub/wav_files/04.wav") + track_6() + send_message("/begin/06", "/home/xpub/wav_files/06.wav") + track_1() + track_3() + track_5() + track_7() + +def set_done(address: str, *args: List[Any]) -> None: + value1 = args[0] + doneno = address[-2:] + + print(f"done{doneno}: {value1}") + if doneno == "00": + send_message("/begin/01", "/home/xpub/wav_files/01.wav") + track_0() + + if doneno == "01": + send_message("/begin/00", "/home/xpub/wav_files/00.wav") + track_1() + + if doneno == "02": + send_message("/begin/03", "/home/xpub/wav_files/03.wav") + track_2() + + if doneno == "03": + send_message("/begin/02", "/home/xpub/wav_files/02.wav") + track_3() + + if doneno == "04": + send_message("/begin/05", "/home/xpub/wav_files/05.wav") + track_4() + + if doneno == "05": + send_message("/begin/04", "/home/xpub/wav_files/04.wav") + track_5() + + if doneno == "06": + send_message("/begin/07", "/home/xpub/wav_files/07.wav") + track_6() + + if doneno == "07": + send_message("/begin/06", "/home/xpub/wav_files/06.wav") + track_7() + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--ip", default="127.0.0.1", + help="The ip of the OSC server") + parser.add_argument("--port", type=int, default=57120, + help="The port the OSC server is listening on") + args = parser.parse_args() + + dispatcher = Dispatcher() + dispatcher.map("/done00", set_done) + dispatcher.map("/done01", set_done) + dispatcher.map("/done02", set_done) + dispatcher.map("/done03", set_done) + dispatcher.map("/done04", set_done) + dispatcher.map("/done05", set_done) + dispatcher.map("/done06", set_done) + dispatcher.map("/done07", set_done) + dispatcher.map("/hello", init) + + server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher) + print("Serving on {}".format(server.server_address)) + + server.serve_forever() + diff --git a/server.sh b/server.sh new file mode 100755 index 0000000..d1ea2b4 --- /dev/null +++ b/server.sh @@ -0,0 +1,2 @@ +#!/bin/bash +python /home/xpub/server.py