adding tracker lock after timeout

main
mwinter 1 year ago
parent b96cca7a2e
commit 0489f77199

@ -92,7 +92,7 @@
"linkId": "",
"width": 96,
"height": 72,
"label": "Robinson",
"label": "Berger",
"css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}",
"doubleTap": false,
"on": 1,
@ -138,7 +138,7 @@
"linkId": "",
"width": 96,
"height": 72,
"label": "Ammann",
"label": "Robinson",
"css": "JS{\n:host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}\n",
"doubleTap": false,
"on": 2,
@ -230,7 +230,7 @@
"linkId": "",
"width": 96,
"height": 72,
"label": "Kari",
"label": "Penrose",
"css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}",
"doubleTap": false,
"on": 4,
@ -368,7 +368,7 @@
"linkId": "",
"width": 96,
"height": 72,
"label": "Jaendel",
"label": "Ammann",
"css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}",
"doubleTap": false,
"on": 6,
@ -414,7 +414,7 @@
"linkId": "",
"width": 96,
"height": 72,
"label": "Berger",
"label": "Kari",
"css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}",
"doubleTap": false,
"on": 8,
@ -460,7 +460,7 @@
"linkId": "",
"width": 96,
"height": 72,
"label": "Penrose",
"label": "Jaendel",
"css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}",
"doubleTap": false,
"on": 9,
@ -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 in \" + i + \" seconds\")\n if(i < 1){\n set(\"lock\", true)\n set(\"message\", \"select another tiling\")\n clearInterval(timeOut)\n }\n }, 1000);\n }\n}",
"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}",
"onValue": ""
}
],

@ -10,14 +10,15 @@ SynthDef(\hdpPlayer, {arg playBuf = 0, gate = 0;
);
(
var recDir, recPaths, recInfo, playBuf, player, isPlaying, playRoutine;
recDir = "/home/mwinter/Portfolio/a_history_of_the_domino_problem/a_history_of_the_domino_problem_source/recs/";
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);
OSCFunc({ arg msg, time;
[time, msg].postln;
@ -31,7 +32,7 @@ OSCFunc({ arg msg, time;
});
isPlaying = true;
piece = msg[1];
playDur = (5.0.rand + 5) * 10;
playDur = (5.0.rand + 5) * 60;
numPlayFrames = playDur * recInfo[piece][1];
startFrame = (recInfo[piece][0] - numPlayFrames).rand;
playBuf.free;
@ -43,7 +44,7 @@ OSCFunc({ arg msg, time;
30.wait;
isPlaying = false;
}).play
},'/playTiling', n);
},'/playTiling', localAddress);
)
n = NetAddr("127.0.0.1", 57120)

@ -5,7 +5,7 @@ var imgPositions, imgIndexToAudioIndex, curPos, tarPos,
netAddress, localAddress, serialPort, serialListener,
moveTo, jogControl, jogHorizontal, jogVertical,
imgSelect, imgCalibrate, lastSelect,
trackerPos, trackerOffsetBaseDist, trackerOffset;
trackerPos, trackerOffsetBaseDist, trackerOffset, trackLock;
// init global vars
imgPositions = 9.collect({nil});
@ -29,7 +29,7 @@ trackerOffset = [
[trackerOffsetBaseDist * 0, trackerOffsetBaseDist * -1],
[trackerOffsetBaseDist * -1, trackerOffsetBaseDist * -1]
];
trackLock = true;
~serialPort = SerialPort("/dev/ttyACM0", baudrate: 115200, crtscts: true);
@ -110,6 +110,7 @@ imgSelect = {
var imgIndex, audioIndex;
msg.postln;
if((msg[1] > 0), {
trackLock = false;
imgIndex = msg[1] - 1;
imgIndex.postln;
if(imgPositions[imgIndex] != nil, {tarPos = imgPositions[imgIndex].deepCopy; moveTo.value(tarPos)});
@ -118,6 +119,7 @@ imgSelect = {
lastSelect = imgIndex;
audioIndex = imgIndexToAudioIndex[imgIndex];
if(audioIndex != nil, {localAddress.sendMsg('/playTiling', audioIndex)});
Routine({60.wait; trackLock = true}).play;
}, {
lastSelect.postln;
if(msg[1] == ((lastSelect + 1) * -1), {"here".postln; lastSelect = -1})
@ -154,7 +156,7 @@ imgCalibrate = {
}.value;
trackerPos = OSCFunc({arg msg;
if(lastSelect.postln > -1, {
if((lastSelect.postln > -1) && trackLock.postln.not, {
var distX, distY, isFocusing;
distX = curPos.x - imgPositions[lastSelect].x;
distY = curPos.y - imgPositions[lastSelect].y;

Loading…
Cancel
Save