diff --git a/openstagecontrol/stepper_control_gui.json b/openstagecontrol/stepper_control_gui_v1.json similarity index 100% rename from openstagecontrol/stepper_control_gui.json rename to openstagecontrol/stepper_control_gui_v1.json diff --git a/openstagecontrol/stepper_control_gui_v2_public.json b/openstagecontrol/stepper_control_gui_v2_public.json index d96649a..e679624 100644 --- a/openstagecontrol/stepper_control_gui_v2_public.json +++ b/openstagecontrol/stepper_control_gui_v2_public.json @@ -6,7 +6,7 @@ "type": "root", "id": "root", "linkId": "", - "css": "", + "css": "JS{\nif(@{lock}) return `\n:host > inner > .navigation {\n pointer-events: none;\n filter: grayscale(100%);\n}`\n}", "default": "", "value": "", "address": "/root", @@ -21,7 +21,7 @@ "id": "main_tab", "linkId": "", "label": "a history of the domino problem", - "css": ":root {\n--color-bg: black;\n--color-raised: black;\n--color-accent: grey;\n--color-light: grey;\n}", + "css": ":root {\n--color-bg: black;\n--color-raised: black;\n--color-accent: grey;\n--color-light: grey;\n}\n> .panel {\n display: flex;\n align-items: center;\n justify-content: center;\n}", "default": "", "value": "", "address": "/tab_1", @@ -32,12 +32,12 @@ "widgets": [ { "type": "panel", - "top": 140, - "left": 270, + "top": "auto", + "left": "auto", "id": "main_panel", "linkId": "", - "width": 820, - "height": 600, + "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}", "scroll": true, "default": "", @@ -50,11 +50,11 @@ "widgets": [ { "type": "text", - "top": 430, - "left": 140, + "top": 410, + "left": 20, "id": "message", "linkId": "", - "width": 478, + "width": 480, "height": 50, "css": ".text {\n background-color: black;\n border: 1px solid grey;\n}", "vertical": false, @@ -85,443 +85,26 @@ "onValue": "" }, { - "type": "panel", + "type": "button", "top": 20, - "left": 120, - "id": "img_matrix", + "left": 20, + "id": "img_1_select", "linkId": "", - "width": 530, - "height": 390, - "css": ".panel {\n background-color: black;\n border: 2px solid grey;\n}", - "scroll": false, + "width": 96, + "height": 72, + "label": "Robinson", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 1, + "off": -1, "default": "", "value": "", - "address": "/image_select", + "address": "/img_select", "preArgs": "", "target": "", - "bypass": true, - "variables": "@{parent.variables}", - "widgets": [ - { - "type": "button", - "top": 20, - "left": 20, - "id": "img_1_select", - "linkId": "", - "width": 96, - "height": 72, - "label": false, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "on": 1, - "off": -1, - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "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": "", - "onValue": "" - }, - { - "type": "button", - "top": 20, - "left": 212, - "id": "img_2_select", - "linkId": "", - "width": 96, - "height": 72, - "label": false, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "on": 2, - "off": -2, - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "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": "", - "onValue": "" - }, - { - "type": "button", - "top": 20, - "left": 404, - "id": "img_3_select", - "linkId": "", - "width": 96, - "height": 72, - "label": false, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "on": 3, - "off": -3, - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "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": "", - "onValue": "" - }, - { - "type": "button", - "top": 164, - "left": 20, - "id": "img_4_select", - "linkId": "", - "width": 96, - "height": 72, - "label": false, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "on": 4, - "off": -4, - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "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": "", - "onValue": "" - }, - { - "type": "button", - "top": 308, - "left": 20, - "id": "img_7_select", - "linkId": "", - "width": 96, - "height": 72, - "label": false, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "on": 7, - "off": -7, - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "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": "", - "onValue": "" - }, - { - "type": "button", - "top": 164, - "left": 212, - "id": "img_5_select", - "linkId": "", - "width": 96, - "height": 72, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "colorTextOn": "auto", - "wrap": false, - "typeTags": "", - "ignoreDefaults": false, - "onCreate": "", - "onValue": "", - "label": false, - "doubleTap": false, - "on": 5, - "off": -5, - "vertical": false, - "decoupled": false - }, - { - "type": "button", - "top": 164, - "left": 404, - "id": "img_6_select", - "linkId": "", - "width": 96, - "height": 72, - "label": false, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "on": 6, - "off": -6, - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "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": "", - "onValue": "" - }, - { - "type": "button", - "top": 308, - "left": 212, - "id": "img_8_select", - "linkId": "", - "width": 96, - "height": 72, - "label": false, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "on": 8, - "off": -8, - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "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": "", - "onValue": "" - }, - { - "type": "button", - "top": 308, - "left": 404, - "id": "img_9_select", - "linkId": "", - "width": 96, - "height": 72, - "label": false, - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "on": 9, - "off": -9, - "default": "", - "value": "", - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false, - "decimals": 2, - "mode": "toggle", - "lock": false, - "visible": true, - "interaction": true, - "comments": "", - "expand": "false", - "colorText": "auto", - "colorWidget": "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": "", - "onValue": "" - } - ], - "tabs": [], + "bypass": false, "decimals": 2, - "innerPadding": false, - "padding": 0, - "alphaStroke": 0, + "mode": "toggle", "lock": false, "visible": true, "interaction": true, @@ -531,21 +114,406 @@ "colorWidget": "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": "", + "onValue": "globals.lockFunc(get(this))" + }, + { + "type": "button", + "top": 20, + "left": 212, + "id": "img_2_select", + "linkId": "", + "width": 96, + "height": 72, + "label": "Ammann", + "css": "JS{\n:host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}\n", + "doubleTap": false, + "on": 2, + "off": -2, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "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": "", + "onValue": "globals.lockFunc(get(this))" + }, + { + "type": "button", + "top": 20, + "left": 404, + "id": "img_3_select", + "linkId": "", + "width": 96, + "height": 72, + "label": "message 3", + "css": "", + "doubleTap": false, + "on": 3, + "off": -3, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "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": "", + "onValue": "globals.lockFunc(get(this))" + }, + { + "type": "button", + "top": 164, + "left": 20, + "id": "img_4_select", + "linkId": "", + "width": 96, + "height": 72, + "label": "Kari", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 4, + "off": -4, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "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": "", + "onValue": "globals.lockFunc(get(this))" + }, + { + "type": "button", + "top": 308, + "left": 20, + "id": "img_7_select", + "linkId": "", + "width": 96, + "height": 72, + "label": "message 1", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 7, + "off": -7, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "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": "", + "onValue": "globals.lockFunc(get(this))" + }, + { + "type": "button", + "top": 164, + "left": 212, + "id": "img_5_select", + "linkId": "", + "width": 96, + "height": 72, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", "alphaFillOff": "auto", "alphaFillOn": "auto", "lineWidth": "auto", "borderRadius": "auto", + "padding": "auto", "html": "", - "colorBg": "auto", - "layout": "default", - "justify": "start", - "gridTemplate": "", - "contain": true, - "tabsPosition": "top", - "traversing": false, + "colorTextOn": "auto", + "wrap": false, "typeTags": "", "ignoreDefaults": false, "onCreate": "", + "onValue": "globals.lockFunc(get(this))", + "label": "message 2", + "doubleTap": false, + "on": 5, + "off": -5, + "vertical": false, + "decoupled": false + }, + { + "type": "button", + "top": 164, + "left": 404, + "id": "img_6_select", + "linkId": "", + "width": 96, + "height": 72, + "label": "Jaendel", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 6, + "off": -6, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "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": "", + "onValue": "globals.lockFunc(get(this))" + }, + { + "type": "button", + "top": 308, + "left": 212, + "id": "img_8_select", + "linkId": "", + "width": 96, + "height": 72, + "label": "Berger", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 8, + "off": -8, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "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": "", + "onValue": "globals.lockFunc(get(this))" + }, + { + "type": "button", + "top": 308, + "left": 404, + "id": "img_9_select", + "linkId": "", + "width": 96, + "height": 72, + "label": "Penrose", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 9, + "off": -9, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "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": "", + "onValue": "globals.lockFunc(get(this))" + }, + { + "type": "variable", + "lock": false, + "id": "lock", + "comments": "", + "value": 0, + "default": "", + "linkId": "", + "address": "auto", + "preArgs": "", + "typeTags": "", + "decimals": 2, + "target": "", + "ignoreDefaults": false, + "bypass": false, + "onCreate": "", "onValue": "" } ], @@ -556,7 +524,7 @@ "alphaStroke": 0, "lock": false, "visible": true, - "interaction": true, + "interaction": "#{@{lock}}", "comments": "", "expand": "false", "colorText": "auto", @@ -577,7 +545,7 @@ "traversing": false, "typeTags": "", "ignoreDefaults": false, - "onCreate": "", + "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}", "onValue": "" } ], diff --git a/python/vernier_tracker.py b/python/vernier_tracker.py index d18970d..2c22cbb 100644 --- a/python/vernier_tracker.py +++ b/python/vernier_tracker.py @@ -86,7 +86,7 @@ def track(frame, roi, dKernel): replaceCrop(frame, roiFineOuter, thresh) meanCourse = pow(cropCoarse.mean(), 1) - print(meanCourse) + #print(meanCourse) mean = 0 direction = 1 if(meanCourse > 40): diff --git a/supercollider/installation_audio_player.scd b/supercollider/installation_audio_player.scd new file mode 100644 index 0000000..9a8e8a5 --- /dev/null +++ b/supercollider/installation_audio_player.scd @@ -0,0 +1,44 @@ +( +SynthDef(\hdpPlayer, {arg playDurBus = 5, playBuf = 0; + var startTrig, playDur, fadeTime, changeTrig, playSig, fade; + startTrig = InTrig.kr(playDurBus); + playDur = In.kr(playDurBus); + fadeTime = 30; + playSig = PlayBuf.ar(2, playBuf, BufRateScale.kr(playBuf), startTrig, 0); + fade = EnvGen.kr(Env.asr(fadeTime, 1, fadeTime), Stepper.kr(startTrig + TDelay.kr(startTrig, playDur - fadeTime), 0, 0, 1)); + Out.ar(0, playSig * fade); + Out.ar([0, 1], BrownNoise.ar * 0.05 * (fade - 1).abs); + SendReply.kr(TDelay.kr(startTrig, playDur), '/unlock'); +}).add; + +); + +( +var recDir, recPaths, recInfo, playBuf, playDurBus, lock; +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]); +playDurBus = Bus.control(s,1); +lock = false; + +OSCFunc({ arg msg, time; + var numPlayFrames, startFrame; + [time, msg].postln; + lock.postln; + if(lock.not, { + numPlayFrames = (5.rand + 5) * 60 * recInfo[msg[1]][1]; + startFrame = (recInfo[msg[1]][0] - numPlayFrames).rand; + playBuf.free; + playBuf = Buffer.read(s, recPaths[msg[1]], startFrame, numPlayFrames, action: {arg buf; + playDurBus.set(numPlayFrames / recInfo[msg[1]][1]) + }); + lock = true; + Routine({10.wait; lock = false; lock.postln}).play + }); +},'/playTiling', n); +Synth(\hdpPlayer, [\playDurBus, playDurBus, \playBuf, playBuf]); +) + +n = NetAddr("127.0.0.1", 57120) +n.sendMsg('/playTiling', 5) diff --git a/supercollider/installation_control.scd b/supercollider/installation_control_v1.scd similarity index 100% rename from supercollider/installation_control.scd rename to supercollider/installation_control_v1.scd diff --git a/supercollider/installation_control_v2.scd b/supercollider/installation_control_v2.scd new file mode 100644 index 0000000..a72204a --- /dev/null +++ b/supercollider/installation_control_v2.scd @@ -0,0 +1,181 @@ +// main controller for the installation +// TODO: playback of the recordings, automation, switch from open-loop to closed-loop with the openCV tracker +( +var imgPositions, imgIndexToAudioIndex, curPos, tarPos, +netAddress, localAddress, serialPort, serialListener, +moveTo, jogControl, jogHorizontal, jogVertical, +imgSelect, imgCalibrate, lastSelect, +trackerPos, trackerOffsetBaseDist, trackerOffset; + +// init global vars +imgPositions = 9.collect({nil}); +imgIndexToAudioIndex = [0, 1, nil, 2, nil, 3, nil, 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; +trackerOffset = [ + [trackerOffsetBaseDist * 1, trackerOffsetBaseDist * 1], + [trackerOffsetBaseDist * 0, trackerOffsetBaseDist * 1], + [trackerOffsetBaseDist * -1, trackerOffsetBaseDist * 1], + + [trackerOffsetBaseDist * 1, trackerOffsetBaseDist * 0], + [trackerOffsetBaseDist * 0, trackerOffsetBaseDist * 0], + [trackerOffsetBaseDist * -1, trackerOffsetBaseDist * 0], + + [trackerOffsetBaseDist * 1, trackerOffsetBaseDist * -1], + [trackerOffsetBaseDist * 0, trackerOffsetBaseDist * -1], + [trackerOffsetBaseDist * -1, trackerOffsetBaseDist * -1] +]; + + +~serialPort = SerialPort("/dev/ttyACM0", baudrate: 115200, crtscts: true); + +// recieve motor feedback +~serialListener = Routine({ + var byte, str, res, valArray, + stepper, limitSwitchNeg, limitSwitchPos, safeMode, limitPos; + + safeMode = false; + + loop{ + byte = ~serialPort.read; + if(byte==13, { + if(str[1].asString == "[", { + valArray = str.asString.interpret.postln; + curPos = Point.new(valArray[0], valArray[1]); + limitSwitchNeg = valArray[2]; + limitSwitchPos = valArray[3]; + if(safeMode && (limitSwitchNeg == limitSwitchPos), { + safeMode = false; + fork { + netAddress.sendMsg("/STATE/SET", "{message: \"all clear\"}"); + 2.wait; + netAddress.sendMsg("/STATE/SET", "{message: \"\"}"); + } + }); + }, { + if(str[1..3].asString == "!!!", { + netAddress.sendMsg("/STATE/SET", "{message: \"!!! limit switch still on after 1000 steps, this should NEVER happen\"}"); + }, { + safeMode = true; + netAddress.sendMsg("/STATE/SET", "{message: \"!! limit hit, move the other direction\"}"); + }); + }); + str = ""; + }, {str = str++byte.asAscii}); + }; +}).play(AppClock); + +// send new coordinates to the arduino / motors +moveTo = {arg point; + if((point.x.abs < 8000) && (curPos.y.abs < 8000), { + "move to".postln; + point.postln; + ~serialPort.putAll(point.x.asInteger.asString ++ " " ++ point.y.asInteger.asString); + ~serialPort.put(10); + }); +}; + +jogControl = {arg axis; + var jog, count = 0, jogRate= 0, jogDirection = 1; + jog = Task({ + loop{ + count = (count + 0.01).clip(0, 1); + 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; + moveTo.value(tarPos); + 0.1.wait + }; + }); + OSCFunc({arg msg; + msg.postln; + if(msg[1] == 0, {count = 0; jogRate = 0; jog.pause()}, {jogDirection = msg[1]; jog.play(AppClock)}); + }, axis, netAddress); +}; + +jogHorizontal = jogControl.value('/jog_horizontal'); +jogVertical = jogControl.value('/jog_vertical'); + +imgSelect = { + OSCFunc({arg msg; + var imgIndex, audioIndex; + msg.postln; + if((msg[1] > 0), { + imgIndex = msg[1] - 1; + 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)}); + }, { + lastSelect.postln; + if(msg[1] == ((lastSelect + 1) * -1), {"here".postln; lastSelect = -1}) + }); + }, '/img_select', netAddress) +}.value; + +imgCalibrate = { + var calibrateHold, imgIndex, setPos; + calibrateHold = Routine({ + var imageCalibrationIndex = 0; + 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].postln; + imageCalibrationIndex = imageCalibrationIndex + 1; + }); + }); + + imgPositions.postln; + netAddress.sendMsg("/STATE/SET", "{message: \"image calibrated\"}"); + }); + + OSCFunc({ arg msg; + imgIndex = msg[1] - 1; + if(imgIndex >= 0, { + setPos = curPos.deepCopy; + calibrateHold.play(AppClock); + }, { + calibrateHold.stop; calibrateHold.reset; netAddress.sendMsg("/STATE/SET", "{message: \"\"}"); + }); + }, '/img_calibrate', netAddress); +}.value; + +trackerPos = OSCFunc({arg msg; + if(lastSelect.postln > -1, { + var distX, distY, isFocusing; + 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), { + 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), { + tarPos.y = curPos.y + (10 * (msg[2] - trackerOffset[lastSelect][1]).sign);// * -1); + isFocusing = true; + }); + if(isFocusing, {moveTo.value(tarPos)}); + }) +}, '/trackerpos'); +) + +//in case of emergency +~serialPort.close +~serialPort = SerialPort.new("/dev/ttyACM0", baudrate: 115200, crtscts: true); +~serialListener.reset +~serialListener.play(AppClock); + +