From 19232846d5972de9e04f9340baab68b0f6a7d4fd Mon Sep 17 00:00:00 2001 From: mwinter Date: Fri, 10 Nov 2023 19:08:51 +0000 Subject: [PATCH] commiting settings day before exhibition movein --- .../stepper_control_gui_v2_public.json | 4 +- supercollider/installation_audio_player.scd | 91 +++++++++---------- supercollider/installation_control_v2.scd | 47 +++++++--- 3 files changed, 83 insertions(+), 59 deletions(-) diff --git a/openstagecontrol/stepper_control_gui_v2_public.json b/openstagecontrol/stepper_control_gui_v2_public.json index 233e849..3df2096 100644 --- a/openstagecontrol/stepper_control_gui_v2_public.json +++ b/openstagecontrol/stepper_control_gui_v2_public.json @@ -38,7 +38,7 @@ "linkId": "", "width": 520, "height": 480, - "css": "> .panel {\n background-color: black;\n border: 2px solid grey;\n}\n:host {\n top:calc(50% - 156rem);\n left:calc(50% - 251rem);\n z-index:15;\n}", + "css": "> .panel {\n background-color: black;\n border: 2px solid grey;\n}\n:host {\n top:calc(50% - 156rem);\n left:calc(50% - 251rem);\n z-index:15;\n font-size: 125%;\n}", "scroll": true, "default": "", "value": "", @@ -545,7 +545,7 @@ "traversing": false, "typeTags": "", "ignoreDefaults": false, - "onCreate": "set(\"lock\", true)\nglobals.lockFunc = function(val){\n if(val >= 0){\n var i = 10\n set(\"lock\", false)\n var timeOut = setInterval(function() {\n i = i - 1\n set(\"message\", \"you may select another tiling/message in \" + i + \" seconds\")\n if(i < 1){\n set(\"lock\", true)\n set(\"message\", \"select another tiling/message\")\n clearInterval(timeOut)\n }\n }, 1000);\n }\n}", + "onCreate": "set(\"lock\", true)\nglobals.lockFunc = function(val){\n if(val >= 0){\n var i = 180\n set(\"lock\", false)\n var timeOut = setInterval(function() {\n i = i - 1\n set(\"message\", \"you may select another tiling/message in \" + i + \" seconds\")\n if(i < 1){\n set(\"lock\", true)\n set(\"message\", \"select another tiling/message\")\n clearInterval(timeOut)\n }\n }, 1000);\n }\n}", "onValue": "" } ], diff --git a/supercollider/installation_audio_player.scd b/supercollider/installation_audio_player.scd index 99fd798..f625ff2 100644 --- a/supercollider/installation_audio_player.scd +++ b/supercollider/installation_audio_player.scd @@ -1,52 +1,51 @@ ( -SynthDef(\hdpPlayer, {arg playBuf = 0, gate = 0; - var playDur, fadeTime, changeTrig, playSig, fade; - fadeTime = 30; - playSig = PlayBuf.ar(2, playBuf, BufRateScale.kr(playBuf), gate, 0); - fade = EnvGen.kr(Env.asr(fadeTime, 1, fadeTime), gate); - Out.ar(0, playSig * fade); - Out.ar([0, 1], BrownNoise.ar * 0.05 * (fade - 1).abs); -}).add; -); +s.waitForBoot({ + var recDir, recPaths, recInfo, playBuf, player, isPlaying, playRoutine, localAddress; -( -var recDir, recPaths, recInfo, playBuf, player, isPlaying, playRoutine, localAddress; -recDir = "/home/mwinter/a_history_of_the_domino_problem/recs/"; -recPaths = ["berger_knuth.wav", "robinson.wav", "penrose.wav", "ammann.wav", "kari_culik.wav", "jaendel_rao.wav"].collect({arg file; recDir +/+ file}); -recInfo = recPaths.collect({arg path; var sndFile; sndFile = SoundFile.openRead(path); [sndFile.numFrames, sndFile.sampleRate]}); -playBuf = Buffer.read(s, recPaths[0]); -//lock = false; -isPlaying = false; -player = Synth(\hdpPlayer, [\playBuf, playBuf]); -localAddress = NetAddr.new("127.0.0.1", 57120); + SynthDef(\hdpPlayer, {arg playBuf = 0, gate = 0; + var playDur, fadeTime, changeTrig, playSig, fade; + fadeTime = 30; + playSig = PlayBuf.ar(2, playBuf, BufRateScale.kr(playBuf), gate, 0); + fade = EnvGen.kr(Env.asr(fadeTime, 1, fadeTime), gate); + Out.ar(0, playSig * fade); + Out.ar([0, 1], BrownNoise.ar * 0.05 * (fade - 1).abs); + }).add; + + 5.wait; + + recDir = "/home/mwinter/a_history_of_the_domino_problem/recs/"; + recPaths = ["berger_knuth.wav", "robinson.wav", "penrose.wav", "ammann.wav", "kari_culik.wav", "jaendel_rao.wav"].collect({arg file; recDir +/+ file}); + recInfo = recPaths.collect({arg path; var sndFile; sndFile = SoundFile.openRead(path); [sndFile.numFrames, sndFile.sampleRate]}); + playBuf = Buffer.read(s, recPaths[0]); + //lock = false; + isPlaying = false; + player = Synth(\hdpPlayer, [\playBuf, playBuf]); + localAddress = NetAddr.new("127.0.0.1", 57120); -OSCFunc({ arg msg, time; - [time, msg].postln; - //lock.postln; - playRoutine.stop; - playRoutine = Routine({ - var playDur, piece, numPlayFrames, startFrame; - if(isPlaying, { + OSCFunc({ arg msg, time; + [time, msg].postln; + //lock.postln; + playRoutine.stop; + playRoutine = Routine({ + var playDur, piece, numPlayFrames, startFrame; + if(isPlaying, { + player.set(\gate, 0); + 30.wait; + }); + isPlaying = true; + piece = msg[1]; + playDur = (5.0.rand + 5) * 60; + numPlayFrames = playDur * recInfo[piece][1]; + startFrame = (recInfo[piece][0] - numPlayFrames).rand; + playBuf.free; + playBuf = Buffer.read(s, recPaths[piece], startFrame, numPlayFrames, action: {arg buf; + player.set(\gate, 1); + }); + (playDur - 30).wait; player.set(\gate, 0); 30.wait; - }); - isPlaying = true; - piece = msg[1]; - playDur = (5.0.rand + 5) * 60; - numPlayFrames = playDur * recInfo[piece][1]; - startFrame = (recInfo[piece][0] - numPlayFrames).rand; - playBuf.free; - playBuf = Buffer.read(s, recPaths[piece], startFrame, numPlayFrames, action: {arg buf; - player.set(\gate, 1); - }); - (playDur - 30).wait; - player.set(\gate, 0); - 30.wait; - isPlaying = false; - }).play -},'/playTiling', localAddress); + isPlaying = false; + }).play + },'/playTiling', localAddress); +}) ) - -n = NetAddr("127.0.0.1", 57120) -n.sendMsg('/playTiling', 1) - diff --git a/supercollider/installation_control_v2.scd b/supercollider/installation_control_v2.scd index 1e9434c..0cf2312 100644 --- a/supercollider/installation_control_v2.scd +++ b/supercollider/installation_control_v2.scd @@ -5,7 +5,10 @@ var imgPositions, imgIndexToAudioIndex, curPos, tarPos, netAddress, localAddress, serialPort, serialListener, moveTo, jogControl, jogHorizontal, jogVertical, imgSelect, imgCalibrate, lastSelect, -trackerPos, trackerOffsetBaseDist, trackerOffset, trackLock; +trackerPos, trackerOffsetBaseDist, trackerOffset, trackLock, +dirTuples, dirAdjustRoutine, dirTuplesSeq; + +"installation_audio_player.scd".loadRelative; // init global vars imgPositions = 9.collect({nil}); @@ -30,6 +33,7 @@ trackerOffset = [ [trackerOffsetBaseDist * -1, trackerOffsetBaseDist * -1] ]; trackLock = true; +dirTuples = [ [ -1, -1 ], [ -1, 0 ], [ -1, 1 ], [ 0, -1 ], [ 0, 1 ], [ 1, -1 ], [ 1, 0 ], [ 1, 1 ] ]; ~serialPort = SerialPort("/dev/ttyACM0", baudrate: 115200, crtscts: true); @@ -84,14 +88,14 @@ jogControl = {arg axis; jog = Task({ loop{ count = (count + 0.01).clip(0, 1); - count.postln; + //count.postln; jogRate = pow(count, 2) * 500; if(axis == '/jog_horizontal', { tarPos.x = curPos.x + (jogRate * jogDirection * -1); }, { tarPos.y = curPos.y + (jogRate * jogDirection); }); - curPos.postln; + //curPos.postln; moveTo.value(tarPos); 0.1.wait }; @@ -110,19 +114,40 @@ imgSelect = { var imgIndex, audioIndex; msg.postln; if((msg[1] > 0), { + dirAdjustRoutine.stop; trackLock = false; imgIndex = msg[1] - 1; - imgIndex.postln; + //imgIndex.postln; if(imgPositions[imgIndex] != nil, {tarPos = imgPositions[imgIndex].deepCopy; moveTo.value(tarPos)}); 9.do({arg i; if(imgIndex != i, { netAddress.sendMsg("/STATE/SET", "{img_" ++ (i + 1).asString ++ "_select: " ++ (i + 1).neg ++ "}")})}); lastSelect = imgIndex; audioIndex = imgIndexToAudioIndex[imgIndex]; if(audioIndex != nil, {localAddress.sendMsg('/playTiling', audioIndex)}); - Routine({60.wait; trackLock = true}).play; + dirTuplesSeq = dirTuples.deepCopy.scramble; + dirAdjustRoutine = Routine({ + 60.wait; + imgPositions[imgIndex] = curPos.deepCopy; + trackLock = true; + 10.wait; + 8.do({arg dirAdjust; + "here".postln; + tarPos = imgPositions[imgIndex].deepCopy + (dirTuplesSeq[dirAdjust] * 200); + moveTo.value(tarPos); + 2.wait; + trackLock = false; + 10.wait; + trackLock = true; + 10.wait; + }); + }).play; }, { - lastSelect.postln; - if(msg[1] == ((lastSelect + 1) * -1), {"here".postln; lastSelect = -1}) + //lastSelect.postln; + if(msg[1] == ((lastSelect + 1) * -1), { + lastSelect = -1; + dirAdjustRoutine.stop; + trackLock = true; + }) }); }, '/img_select', netAddress) }.value; @@ -175,9 +200,9 @@ trackerPos = OSCFunc({arg msg; ) //in case of emergency -~serialPort.close -~serialPort = SerialPort.new("/dev/ttyACM0", baudrate: 115200, crtscts: true); -~serialListener.reset -~serialListener.play(AppClock); +//~serialPort.close +//~serialPort = SerialPort.new("/dev/ttyACM0", baudrate: 115200, crtscts: true); +//~serialListener.reset +//~serialListener.play(AppClock);