|
| 1 | +{ |
| 2 | + "patcher" : { |
| 3 | + "fileversion" : 1, |
| 4 | + "appversion" : { |
| 5 | + "major" : 8, |
| 6 | + "minor" : 2, |
| 7 | + "revision" : 2, |
| 8 | + "architecture" : "x64", |
| 9 | + "modernui" : 1 |
| 10 | + } |
| 11 | +, |
| 12 | + "classnamespace" : "dsp.gen", |
| 13 | + "rect" : [ 733.0, 78.0, 652.0, 788.0 ], |
| 14 | + "bglocked" : 0, |
| 15 | + "openinpresentation" : 0, |
| 16 | + "default_fontsize" : 12.0, |
| 17 | + "default_fontface" : 0, |
| 18 | + "default_fontname" : "Arial", |
| 19 | + "gridonopen" : 1, |
| 20 | + "gridsize" : [ 15.0, 15.0 ], |
| 21 | + "gridsnaponopen" : 1, |
| 22 | + "objectsnaponopen" : 1, |
| 23 | + "statusbarvisible" : 2, |
| 24 | + "toolbarvisible" : 1, |
| 25 | + "lefttoolbarpinned" : 0, |
| 26 | + "toptoolbarpinned" : 0, |
| 27 | + "righttoolbarpinned" : 0, |
| 28 | + "bottomtoolbarpinned" : 0, |
| 29 | + "toolbars_unpinned_last_save" : 0, |
| 30 | + "tallnewobj" : 0, |
| 31 | + "boxanimatetime" : 200, |
| 32 | + "enablehscroll" : 1, |
| 33 | + "enablevscroll" : 1, |
| 34 | + "devicewidth" : 0.0, |
| 35 | + "description" : "", |
| 36 | + "digest" : "", |
| 37 | + "tags" : "", |
| 38 | + "style" : "", |
| 39 | + "subpatcher_template" : "", |
| 40 | + "assistshowspatchername" : 0, |
| 41 | + "boxes" : [ { |
| 42 | + "box" : { |
| 43 | + "id" : "obj-7", |
| 44 | + "maxclass" : "newobj", |
| 45 | + "numinlets" : 0, |
| 46 | + "numoutlets" : 1, |
| 47 | + "outlettype" : [ "" ], |
| 48 | + "patching_rect" : [ 611.0, 15.0, 28.0, 22.0 ], |
| 49 | + "text" : "in 2" |
| 50 | + } |
| 51 | + |
| 52 | + } |
| 53 | +, { |
| 54 | + "box" : { |
| 55 | + "id" : "obj-6", |
| 56 | + "maxclass" : "newobj", |
| 57 | + "numinlets" : 1, |
| 58 | + "numoutlets" : 0, |
| 59 | + "patching_rect" : [ 589.0, 750.0, 35.0, 22.0 ], |
| 60 | + "text" : "out 4" |
| 61 | + } |
| 62 | + |
| 63 | + } |
| 64 | +, { |
| 65 | + "box" : { |
| 66 | + "id" : "obj-3", |
| 67 | + "maxclass" : "newobj", |
| 68 | + "numinlets" : 1, |
| 69 | + "numoutlets" : 0, |
| 70 | + "patching_rect" : [ 412.333333333333314, 750.0, 35.0, 22.0 ], |
| 71 | + "text" : "out 3" |
| 72 | + } |
| 73 | + |
| 74 | + } |
| 75 | +, { |
| 76 | + "box" : { |
| 77 | + "id" : "obj-2", |
| 78 | + "maxclass" : "newobj", |
| 79 | + "numinlets" : 1, |
| 80 | + "numoutlets" : 0, |
| 81 | + "patching_rect" : [ 213.666666666666657, 750.0, 35.0, 22.0 ], |
| 82 | + "text" : "out 2" |
| 83 | + } |
| 84 | + |
| 85 | + } |
| 86 | +, { |
| 87 | + "box" : { |
| 88 | + "code" : "// buffers with patterns for rhythm and warping\r\nBuffer beatPtrn;\r\nBuffer warpPtrn;\r\nBuffer ratchetPtrn;\r\n\r\n// external parameters\r\nParam div(1);\r\nParam thresh(0.9);\r\nParam barReset(0);\r\nParam offset(0);\r\nParam resetCount(0);\r\n\r\n// send external clicks to increment counter\r\nParam free(0);\r\n\r\n// ratcheting probability param\r\nParam ratchet(0);\r\n\r\n// history for storage of params\r\nHistory d(1);\r\nHistory o(0);\r\n\r\nHistory bCount(0);\r\nHistory nCount(0);\r\nHistory rCount(0);\r\nHistory wPhasor(0);\r\n\r\n// global variables\r\ntrig, cr, rt = 0;\r\n\r\n// reset counter bang after specified amount of time\r\nif (resetCount > 0){\r\n\tcr = rate(in1, resetCount, sync=\"lock\");\r\n\tcr = delta(cr) < -thresh;\r\n}\r\n\r\n// manual click when free=true\r\nif (free){\r\n\ttrig = in2;\r\n} else {\r\n\t// only adjust the new parameters when one bar \r\n\t// of 4/4 finished\r\n\tif (barReset){\r\n\t\tbarTrig = delta(in1) < -thresh;\r\n\t\td = latch(div, barTrig);\r\n\t\to = fract(latch(offset, barTrig));\t\r\n\t} else {\r\n\t\td = div;\r\n\t\to = fract(offset);\r\n\t}\r\n\r\n\t// apply offset to the phasor\r\n\t// of = ((in1 - o) % 1 + 1) % 1;\r\n\tof = fract(in1 - o);\r\n\r\n\t// stretch/shrink phasor with rate and locked to main\r\n\trt = rate(of, d, sync=\"lock\");\r\n\r\n\t// create a trigger when delta is below thresh\r\n\ttrig = delta(rt) < -thresh;\r\n\r\n\t// warp the phasor based on warping pattern if more than 1 value\r\n\tif (dim(warpPtrn) > 1){\r\n\t\t// get warp increment\r\n\t\twp = peek(warpPtrn, trunc(wPhasor));\r\n\t\t// add to wphasor\r\n\t\twPhasor += delta(rt) * wp;\r\n\t\tif (trig) {\r\n\t\t\twPhasor = 0;\r\n\t\t}\r\n\t\t// get fractional component of wPhasor\r\n\t\trt = fract(wPhasor);\r\n\t\t// new triggers\r\n\t\ttrig = delta(rt) < -thresh;\r\n\t}\r\n}//if not free\r\n\r\n// increment the beat counter (used to look up patterns)\r\nbCount = counter(trig, cr);\r\n\r\nbt = 0;\r\n// get the beat pattern value\r\nif (trig){\r\n\tbt = peek(beatPtrn, trunc(bCount % dim(beatPtrn)));\r\n\tbt = abs(noise()) < bt;\r\n}\r\n\r\n// increment the note counter (the notes that are actually played)\r\nnCount = counter(trig * bt, cr);\r\n\r\n// no ratchet effect when free=true\r\nif (!free){\r\n\t// ratcheting effect, triggering extra divisions\r\n\t// in between the standard trigger\r\n\t// based on probability percentage\r\n\tif (ratchet > 0){\r\n\t\tns = latch(abs(noise()), trig);\r\n\t\t//rch = latch(ratchet, trig);\r\n\t\trch = latch(peek(ratchetPtrn, trunc(rCount % dim(ratchetPtrn))), trig);\r\n\t\r\n\t\tif (ns < ratchet){\r\n\t\t\t// increment the ratchet counter (that are actually played)\r\n\t\t\trCount = counter(trig * bt, cr);\r\n\t\t\trch = fract(rt * rch);\r\n\t\t\t// output the ratchet triggers separately\r\n\t\t\tout2 = max(0, (delta(rch) < -thresh) - trig);\r\n\t\t\t// or not?\r\n\t\t\t//trig += delta(rch) < -thresh;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n// output the beat count\r\nout4 = bCount;\r\n// output the note count\r\nout3 = nCount;\r\n// output the main trigger\r\nout1 = trig * bt;", |
| 89 | + "fontface" : 0, |
| 90 | + "fontname" : "<Monospaced>", |
| 91 | + "fontsize" : 12.0, |
| 92 | + "id" : "obj-5", |
| 93 | + "maxclass" : "codebox", |
| 94 | + "numinlets" : 2, |
| 95 | + "numoutlets" : 4, |
| 96 | + "outlettype" : [ "", "", "", "" ], |
| 97 | + "patching_rect" : [ 15.0, 45.0, 615.0, 690.0 ] |
| 98 | + } |
| 99 | + |
| 100 | + } |
| 101 | +, { |
| 102 | + "box" : { |
| 103 | + "id" : "obj-1", |
| 104 | + "maxclass" : "newobj", |
| 105 | + "numinlets" : 0, |
| 106 | + "numoutlets" : 1, |
| 107 | + "outlettype" : [ "" ], |
| 108 | + "patching_rect" : [ 15.0, 15.0, 28.0, 22.0 ], |
| 109 | + "text" : "in 1" |
| 110 | + } |
| 111 | + |
| 112 | + } |
| 113 | +, { |
| 114 | + "box" : { |
| 115 | + "id" : "obj-4", |
| 116 | + "maxclass" : "newobj", |
| 117 | + "numinlets" : 1, |
| 118 | + "numoutlets" : 0, |
| 119 | + "patching_rect" : [ 15.0, 750.0, 35.0, 22.0 ], |
| 120 | + "text" : "out 1" |
| 121 | + } |
| 122 | + |
| 123 | + } |
| 124 | + ], |
| 125 | + "lines" : [ { |
| 126 | + "patchline" : { |
| 127 | + "destination" : [ "obj-5", 0 ], |
| 128 | + "source" : [ "obj-1", 0 ] |
| 129 | + } |
| 130 | + |
| 131 | + } |
| 132 | +, { |
| 133 | + "patchline" : { |
| 134 | + "destination" : [ "obj-2", 0 ], |
| 135 | + "source" : [ "obj-5", 1 ] |
| 136 | + } |
| 137 | + |
| 138 | + } |
| 139 | +, { |
| 140 | + "patchline" : { |
| 141 | + "destination" : [ "obj-3", 0 ], |
| 142 | + "source" : [ "obj-5", 2 ] |
| 143 | + } |
| 144 | + |
| 145 | + } |
| 146 | +, { |
| 147 | + "patchline" : { |
| 148 | + "destination" : [ "obj-4", 0 ], |
| 149 | + "source" : [ "obj-5", 0 ] |
| 150 | + } |
| 151 | + |
| 152 | + } |
| 153 | +, { |
| 154 | + "patchline" : { |
| 155 | + "destination" : [ "obj-6", 0 ], |
| 156 | + "source" : [ "obj-5", 3 ] |
| 157 | + } |
| 158 | + |
| 159 | + } |
| 160 | +, { |
| 161 | + "patchline" : { |
| 162 | + "destination" : [ "obj-5", 1 ], |
| 163 | + "source" : [ "obj-7", 0 ] |
| 164 | + } |
| 165 | + |
| 166 | + } |
| 167 | + ] |
| 168 | + } |
| 169 | + |
| 170 | +} |
0 commit comments