{ "patcher" : { "fileversion" : 1, "appversion" : { "major" : 8, "minor" : 3, "revision" : 0, "architecture" : "x64", "modernui" : 1 } , "classnamespace" : "dsp.gen", "rect" : [ 84.0, 129.0, 1087.0, 669.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, "default_fontface" : 0, "default_fontname" : "Arial", "gridonopen" : 1, "gridsize" : [ 15.0, 15.0 ], "gridsnaponopen" : 1, "objectsnaponopen" : 1, "statusbarvisible" : 2, "toolbarvisible" : 1, "lefttoolbarpinned" : 0, "toptoolbarpinned" : 0, "righttoolbarpinned" : 0, "bottomtoolbarpinned" : 0, "toolbars_unpinned_last_save" : 0, "tallnewobj" : 0, "boxanimatetime" : 200, "enablehscroll" : 1, "enablevscroll" : 1, "devicewidth" : 0.0, "description" : "", "digest" : "", "tags" : "", "style" : "", "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { "box" : { "id" : "obj-3", "maxclass" : "newobj", "numinlets" : 1, "numoutlets" : 0, "patching_rect" : [ 682.0, 640.0, 274.0, 22.0 ], "text" : "out 4 @comment \"Current interpolation time (ms)\"" } } , { "box" : { "id" : "obj-10", "maxclass" : "newobj", "numinlets" : 1, "numoutlets" : 0, "patching_rect" : [ 456.0, 640.0, 207.0, 22.0 ], "text" : "out 3 @comment \"Current Z position\"" } } , { "box" : { "id" : "obj-9", "maxclass" : "newobj", "numinlets" : 1, "numoutlets" : 0, "patching_rect" : [ 230.0, 640.0, 208.0, 22.0 ], "text" : "out 2 @comment \"Current Y position\"" } } , { "box" : { "id" : "obj-7", "maxclass" : "newobj", "numinlets" : 0, "numoutlets" : 1, "outlettype" : [ "" ], "patching_rect" : [ 682.0, 14.0, 174.0, 22.0 ], "text" : "in 3 @comment \"Device on/off\"" } } , { "box" : { "code" : "getRandomTime(inLow, inHigh) {\r\n\tnoise1 = noise();\r\n\treturn (((noise1 * 0.5) + 0.5) * (inHigh - inLow) + inLow);\r\n}\r\n\r\ngetNewXYZ() {\r\n\tnoiseX = noise();\r\n\tnoiseY = noise();\r\n\tnoiseZ = noise();\r\n\treturn noiseX, noiseY, noiseZ;\r\n}\r\n\r\nHistory low(0);\r\nHistory high(0);\r\nHistory play(0);\r\nHistory interpolating(0);\r\nHistory timeCounter(0);\r\nHistory time(0);\r\nHistory oldX(0);\r\nHistory oldY(0);\r\nHistory oldZ(0);\r\nHistory newX(0);\r\nHistory newY(0);\r\nHistory newZ(0);\r\nHistory currentX(0);\r\nHistory currentY(0);\r\nHistory currentZ(0);\r\n\r\nParam globalScale(1);\r\n\r\nlow = mstosamps(in1);\r\nhigh = mstosamps(in2);\r\nplay = in3;\r\n\r\nif (play) {\r\n\tif (interpolating) {\r\n\t\tif (timeCounter < time) {\r\n\t\t\tcurrentX = scale(timeCounter, 0, time, oldX, newX);\r\n\t\t\tcurrentY = scale(timeCounter, 0, time, oldY, newY);\r\n\t\t\tcurrentZ = scale(timeCounter, 0, time, oldZ, newZ);\r\n\t\t\ttimeCounter += 1;\t\t\r\n\t\t} else {\r\n\t\t\tinterpolating = 0;\r\n\t\t}\r\n\r\n\t} else {\r\n\t\ttime = getRandomTime(low, high);\r\n\t\ttimeCounter = 0;\r\n\t\toldX = newX;\r\n\t\toldY = newY;\r\n\t\toldZ = newZ;\r\n\t\tnewX, newY, newZ = getNewXYZ();\r\n\t\tinterpolating = 1;\r\n\t}\r\n}\r\n\r\nout1 = currentX * globalScale;\r\nout2 = currentY * globalScale;\r\nout3 = currentZ * globalScale;\r\nout4 = sampstoms(time);", "fontface" : 0, "fontname" : "<Monospaced>", "fontsize" : 12.0, "id" : "obj-5", "maxclass" : "codebox", "numinlets" : 3, "numoutlets" : 4, "outlettype" : [ "", "", "", "" ], "patching_rect" : [ 4.0, 48.0, 697.0, 579.0 ] } } , { "box" : { "id" : "obj-1", "maxclass" : "newobj", "numinlets" : 0, "numoutlets" : 1, "outlettype" : [ "" ], "patching_rect" : [ 4.0, 14.0, 247.0, 22.0 ], "text" : "in 1 @comment \"Interpolation time min (ms)\"" } } , { "box" : { "id" : "obj-2", "maxclass" : "newobj", "numinlets" : 0, "numoutlets" : 1, "outlettype" : [ "" ], "patching_rect" : [ 343.0, 14.0, 250.0, 22.0 ], "text" : "in 2 @comment \"Interpolation time max (ms)\"" } } , { "box" : { "id" : "obj-4", "maxclass" : "newobj", "numinlets" : 1, "numoutlets" : 0, "patching_rect" : [ 4.0, 640.0, 208.0, 22.0 ], "text" : "out 1 @comment \"Current X position\"" } } ], "lines" : [ { "patchline" : { "destination" : [ "obj-5", 0 ], "source" : [ "obj-1", 0 ] } } , { "patchline" : { "destination" : [ "obj-5", 1 ], "source" : [ "obj-2", 0 ] } } , { "patchline" : { "destination" : [ "obj-10", 0 ], "source" : [ "obj-5", 2 ] } } , { "patchline" : { "destination" : [ "obj-3", 0 ], "source" : [ "obj-5", 3 ] } } , { "patchline" : { "destination" : [ "obj-4", 0 ], "source" : [ "obj-5", 0 ] } } , { "patchline" : { "destination" : [ "obj-9", 0 ], "source" : [ "obj-5", 1 ] } } , { "patchline" : { "destination" : [ "obj-5", 2 ], "source" : [ "obj-7", 0 ] } } ] } }