final state before opening

main
mwinter 11 months ago
parent bfca2cd8eb
commit 55dfc20885

@ -411,7 +411,7 @@
"decoupled": false,
"typeTags": "",
"ignoreDefaults": false,
"onCreate": "function shuffle(array) {\n let currentIndex = array.length, randomIndex;\n\n // While there remain elements to shuffle.\n while (currentIndex > 0) {\n\n // Pick a remaining element.\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex--;\n\n // And swap it with the current element.\n [array[currentIndex], array[randomIndex]] = [\n array[randomIndex], array[currentIndex]];\n }\n\n return array;\n}\n\nset(\"automate\", false)\n\nvar imageShuffle = shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9])\nvar time = 0;\nvar imageCount = 0;\nvar imageInterval = 60 * 2\nvar automateInterval = setInterval(function() {\n if(get(\"automate_play\") !== 0){\n //set(\"lock\", false)\n //set(\"automate\", true)\n //var curImageTime = (time % (60 * 3))\n if(time === imageInterval){\n imageCount = imageCount + 1;\n set(\"img_\" + imageShuffle[imageCount] + \"_select\", imageShuffle[imageCount])\n if(imageCount === 8){\n imageShuffle = shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9])\n }\n time = 0\n }\n \n time = time + 1\n set(\"message\", \"another tiling/message will be selected in \" + (imageInterval - time) + \" seconds\")\n set(\"message_public\", \"another tiling/message will be selected in \" + (imageInterval - time) + \" seconds\")\n }\n \n}, 1000);",
"onCreate": "function shuffle(array) {\n let currentIndex = array.length, randomIndex;\n\n // While there remain elements to shuffle.\n while (currentIndex > 0) {\n\n // Pick a remaining element.\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex--;\n\n // And swap it with the current element.\n [array[currentIndex], array[randomIndex]] = [\n array[randomIndex], array[currentIndex]];\n }\n\n return array;\n}\n\nset(\"automate\", false)\n\nvar imageShuffle = shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9])\nvar imageDurs = [10, 10, 5, 10, 5, 10, 5, 10, 10]\nvar time = 0;\nvar imageCount = 0;\nvar imageInterval = 0\nvar automateInterval = setInterval(function() {\n if(get(\"automate_play\") !== 0){\n //set(\"lock\", false)\n //set(\"automate\", true)\n //var curImageTime = (time % (60 * 3))\n if(time === imageInterval){\n imageCount = imageCount + 1;\n set(\"img_\" + imageShuffle[imageCount] + \"_select\", imageShuffle[imageCount])\n if(imageCount === 8){\n imageShuffle = shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9])\n }\n time = 0\n imageInterval = imageDurs[imageShuffle[imageCount] - 1] * 60\n }\n \n time = time + 1\n set(\"message\", \"another tiling/message will be selected in \" + (imageInterval - time) + \" seconds\")\n set(\"message_public\", \"another tiling/message will be selected in \" + (imageInterval - time) + \" seconds\")\n set(\"message_sub\", \"another tiling/message will be selected in \" + (imageInterval - time) + \" seconds\")\n }\n \n}, 1000);",
"onValue": "if(get(\"automate_play\") !== 0){\n set(\"lock\", false)\n set(\"automate\", true)\n} else {\n set(\"lock\", true)\n set(\"automate\", false)\n }"
}
],
@ -963,6 +963,24 @@
"bypass": false,
"onCreate": "",
"onValue": ""
},
{
"type": "variable",
"lock": false,
"id": "message_sub",
"comments": "",
"value": "",
"default": "",
"linkId": "",
"address": "auto",
"preArgs": "",
"typeTags": "",
"decimals": 2,
"target": "",
"ignoreDefaults": false,
"bypass": false,
"onCreate": "",
"onValue": ""
}
],
"tabs": [],

@ -37,7 +37,7 @@
"id": "main_panel",
"linkId": "",
"width": 520,
"height": 480,
"height": 530,
"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": "",
@ -533,6 +533,88 @@
"bypass": false,
"onCreate": "",
"onValue": ""
},
{
"type": "button",
"top": 480,
"left": 250,
"id": "automate_play",
"linkId": "",
"width": 30,
"height": 30,
"label": "#{\n@{this} == 1 ? \"^stop\" : \"^play\"\n}",
"css": ":host{\n--color-raised:#2A2A2D;\n> .label {\nfont-size: 150%;\n}",
"doubleTap": false,
"on": 1,
"off": 0,
"value": "",
"address": "/automate_play",
"preArgs": "",
"target": "",
"bypass": false,
"default": "",
"decimals": 1,
"colorWidget": "grey",
"mode": "toggle",
"lock": false,
"visible": false,
"interaction": true,
"comments": "",
"expand": "false",
"colorText": "auto",
"colorStroke": "auto",
"colorFill": "auto",
"alphaStroke": "auto",
"alphaFillOff": "auto",
"alphaFillOn": "auto",
"lineWidth": "auto",
"borderRadius": "auto",
"padding": "auto",
"html": "",
"colorTextOn": "auto",
"vertical": false,
"wrap": false,
"decoupled": false,
"typeTags": "",
"ignoreDefaults": false,
"onCreate": "function shuffle(array) {\n let currentIndex = array.length, randomIndex;\n\n // While there remain elements to shuffle.\n while (currentIndex > 0) {\n\n // Pick a remaining element.\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex--;\n\n // And swap it with the current element.\n [array[currentIndex], array[randomIndex]] = [\n array[randomIndex], array[currentIndex]];\n }\n\n return array;\n}\n\nset(\"automate\", false)\n\nvar imageShuffle = shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9])\nvar imageDurs = [6, 6, 3, 6, 3, 6, 3, 6, 6]\nvar time = 0;\nvar imageCount = 0;\nvar imageInterval = 0\nvar automateInterval = setInterval(function() {\n if(get(\"automate_play\") !== 0){\n //set(\"lock\", false)\n //set(\"automate\", true)\n //var curImageTime = (time % (60 * 3))\n if(time === imageInterval){\n imageCount = imageCount + 1;\n set(\"img_\" + imageShuffle[imageCount] + \"_select\", imageShuffle[imageCount])\n if(imageCount === 8){\n imageShuffle = shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9])\n }\n time = 0\n imageInterval = imageDurs[imageShuffle[imageCount] - 1] * 60\n }\n \n time = time + 1\n set(\"message\", \"another tiling/message will be selected in \" + (imageInterval - time) + \" seconds\")\n set(\"message_public\", \"another tiling/message will be selected in \" + (imageInterval - time) + \" seconds\")\n set(\"message_sub\", \"another tiling/message will be selected in \" + (imageInterval - time) + \" seconds\")\n }\n \n}, 1000);",
"onValue": "if(get(\"automate_play\") !== 0){\n set(\"lock\", false)\n set(\"automate\", true)\n} else {\n set(\"lock\", true)\n set(\"automate\", false)\n }"
},
{
"type": "variable",
"lock": false,
"id": "message_public",
"comments": "",
"value": "",
"default": "",
"linkId": "",
"address": "auto",
"preArgs": "",
"typeTags": "",
"decimals": 2,
"target": "",
"ignoreDefaults": false,
"bypass": false,
"onCreate": "",
"onValue": ""
},
{
"type": "variable",
"lock": false,
"id": "message_sub",
"comments": "",
"value": "",
"default": "",
"linkId": "",
"address": "auto",
"preArgs": "",
"typeTags": "",
"decimals": 2,
"target": "",
"ignoreDefaults": false,
"bypass": false,
"onCreate": "",
"onValue": ""
}
],
"tabs": [],

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -189,7 +189,7 @@ class MainWindow(QGlPicamera2):
self.shortcut_close_window = QShortcut(QKeySequence('f'), self)
self.shortcut_close_window.activated.connect(self.goFullscreen)
self.setWindowFlags(Qt.FramelessWindowHint)
self.move(0, 0)
self.move(920, 80)
def mousePressEvent(self, event):
self.oldPos = event.globalPos()
@ -243,7 +243,7 @@ cv2.setMouseCallback("Frame", moveROI)
#picam2.controls.ScalerCrop = (800, 0, 3040, 3040)
#picam2.controls.ScalerCrop = (1375, 550, 1800, 1800)
picam2.controls.ScalerCrop = (925, 630, 2025, 2025)
picam2.controls.ScalerCrop = (945, 630, 2025, 2025)
#picam2.controls.Brightness = 0.2
picam2.controls.Contrast = 1.1
#picam2.set_controls({"ExposureValue": 2})

@ -8,7 +8,7 @@ s.waitForBoot({
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);
Out.ar([0, 1], BrownNoise.ar * 0.03 * (fade - 1).abs);
}).add;
5.wait;
@ -28,24 +28,27 @@ s.waitForBoot({
playRoutine.stop;
playRoutine = Routine({
var playDur, piece, numPlayFrames, startFrame;
if(isPlaying, {
//if(isPlaying, {
player.set(\gate, 0);
30.wait;
//});
if(msg[1] >= 0, {
isPlaying = true;
piece = msg[1].postln;
//playDur = (5.0.rand + 5) * 60;
playDur = 10 * 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;
});
isPlaying = true;
piece = msg[1];
//playDur = (5.0.rand + 5) * 60;
playDur = 10 * 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);
})

@ -12,13 +12,13 @@ dirTuples, dirAdjustRoutine, dirTuplesSeq;
// init global vars
imgPositions = 9.collect({nil});
imgIndexToAudioIndex = [0, 1, nil, 2, nil, 3, nil, 4, 5];
imgIndexToAudioIndex = [0, 1, -1, 2, -1, 3, -1, 4, 5];
curPos = Point.new(0, 0);
tarPos = Point.new(0, 0);
netAddress = NetAddr.new("127.0.0.1", 8080);
localAddress = NetAddr.new("127.0.0.1", 57120);
lastSelect = -1;
trackerOffsetBaseDist = 16000;
trackerOffsetBaseDist = 12000;
trackerOffset = [
[trackerOffsetBaseDist * 1, trackerOffsetBaseDist * 1],
[trackerOffsetBaseDist * 0, trackerOffsetBaseDist * 1],
@ -57,16 +57,24 @@ dirTuples = [ [ -1, -1 ], [ -1, 0 ], [ -1, 1 ], [ 0, -1 ], [ 0, 1 ], [ 1, -1 ],
safeMode = false;
fork {
netAddress.sendMsg("/STATE/SET", "{message: \"all clear\"}");
netAddress.sendMsg("/STATE/SET", "{message_sub: \"all clear\"}");
netAddress.sendMsg("/STATE/SET", "{message_public: \"all clear\"}");
2.wait;
netAddress.sendMsg("/STATE/SET", "{message: \"\"}");
netAddress.sendMsg("/STATE/SET", "{message_sub: \"\"}");
netAddress.sendMsg("/STATE/SET", "{message_public: \"\"}");
}
});
}, {
if(str[1..3].asString == "!!!", {
netAddress.sendMsg("/STATE/SET", "{message: \"!!! limit switch still on after 1000 steps, this should NEVER happen\"}");
netAddress.sendMsg("/STATE/SET", "{message_sub: \"!!! limit switch still on after 1000 steps, this should NEVER happen\"}");
netAddress.sendMsg("/STATE/SET", "{message_public: \"!!! limit switch still on after 1000 steps, this should NEVER happen\"}");
}, {
safeMode = true;
netAddress.sendMsg("/STATE/SET", "{message: \"!! limit hit, move the other direction\"}");
netAddress.sendMsg("/STATE/SET", "{message_sub: \"!! limit hit, move the other direction\"}");
netAddress.sendMsg("/STATE/SET", "{message_public: \"!! limit hit, move the other direction\"}");
});
});
str = "";
@ -124,23 +132,34 @@ imgSelect = {
netAddress.sendMsg("/STATE/SET", "{img_" ++ (i + 1).asString ++ "_select: " ++ (i + 1).neg ++ "}")})});
lastSelect = imgIndex;
audioIndex = imgIndexToAudioIndex[imgIndex];
if(audioIndex != nil, {localAddress.sendMsg('/playTiling', audioIndex)});
dirTuplesSeq = dirTuples.deepCopy.scramble.collect({arg tup; [tup, tup * -1]}).flatten;
//if(audioIndex != nil, {localAddress.sendMsg('/playTiling', audioIndex)});
localAddress.sendMsg('/playTiling', audioIndex);
dirTuplesSeq = 2.collect({dirTuples.deepCopy.scramble.collect({arg tup; [tup, tup * -1]}).flatten}).flatten;
dirAdjustRoutine = Routine({
180.wait;
120.wait;
imgPositions[imgIndex] = curPos.deepCopy;
trackLock = true;
10.wait;
8.do({arg dirAdjust;
//10.wait;
100.do({arg dirAdjust;
"here".postln;
tarPos = imgPositions[imgIndex].deepCopy + (dirTuplesSeq[dirAdjust] * 200);
moveTo.value(tarPos);
2.wait;
trackLock = false;
10.wait;
trackLock = true;
5.wait;
if(dirAdjust < 8, {
tarPos = imgPositions[imgIndex].deepCopy + (dirTuplesSeq[dirAdjust] * 200);
moveTo.value(tarPos);
3.wait;
trackLock = false;
15.wait;
trackLock = true;
//3.wait;
}, {
trackLock = false;
15.wait;
trackLock = true;
15.wait;
});
});
trackLock = false;
//20.wait;
//trackLock = true;
}).play;
}, {
//lastSelect.postln;
@ -160,7 +179,7 @@ imgCalibrate = {
20.do({0.1.wait});
[-1, 0, 1].do({arg row;
[-1, 0, 1].do({arg col;
imgPositions[imageCalibrationIndex] = setPos.deepCopy + Point.new(6550 * col, 6550 * row);
imgPositions[imageCalibrationIndex] = setPos.deepCopy + Point.new(6700 * col, 6700 * row);
imgPositions[imageCalibrationIndex].postln;
imageCalibrationIndex = imageCalibrationIndex + 1;
});
@ -168,6 +187,8 @@ imgCalibrate = {
imgPositions.postln;
netAddress.sendMsg("/STATE/SET", "{message: \"image calibrated\"}");
netAddress.sendMsg("/STATE/SET", "{message_sub: \"image calibrated\"}");
netAddress.sendMsg("/STATE/SET", "{message_public: \"image calibrated\"}");
});
OSCFunc({ arg msg;
@ -176,7 +197,11 @@ imgCalibrate = {
setPos = curPos.deepCopy;
calibrateHold.play(AppClock);
}, {
calibrateHold.stop; calibrateHold.reset; netAddress.sendMsg("/STATE/SET", "{message: \"\"}");
calibrateHold.stop;
calibrateHold.reset;
netAddress.sendMsg("/STATE/SET", "{message: \"\"}");
netAddress.sendMsg("/STATE/SET", "{message_sub: \"\"}");
netAddress.sendMsg("/STATE/SET", "{message_public: \"\"}");
});
}, '/img_calibrate', netAddress);
}.value;
@ -187,11 +212,11 @@ trackerPos = OSCFunc({arg msg;
distX = curPos.x - imgPositions[lastSelect].x;
distY = curPos.y - imgPositions[lastSelect].y;
isFocusing = false;
if((imgPositions[lastSelect] != nil) && (distX.abs < 300) && ((msg[1] - trackerOffset[lastSelect][0]).abs > 3000), {
if((imgPositions[lastSelect] != nil) && (distX.abs < 350) && ((msg[1] - trackerOffset[lastSelect][0]).abs > 3000), {
tarPos.x = curPos.x + (10 * (msg[1] - trackerOffset[lastSelect][0]).sign);// * -1);
isFocusing = true;
});
if((imgPositions[lastSelect] != nil) && (distY.abs < 300) && ((msg[2] - trackerOffset[lastSelect][1]).abs > 3000), {
if((imgPositions[lastSelect] != nil) && (distY.abs < 350) && ((msg[2] - trackerOffset[lastSelect][1]).abs > 3000), {
tarPos.y = curPos.y + (10 * (msg[2] - trackerOffset[lastSelect][1]).sign);// * -1);
isFocusing = true;
});

Loading…
Cancel
Save