{
   "ancestor_list" : [],
   "description" : "Each QuNeo pad activates a differnt pattern of \"notes\" made of filtered white noise.",
   "name" : "Subtractive Synthesis Demo with QuNeo - Patch 2",
   "author" : "Bruno Ruviaro",
   "is_private" : null,
   "id" : "1-4UR",
   "code" : "// ************************************\r\n// Subtractive Synthesis Demo (QuNeo)\r\n// Patch 2 - Patterns of Filtered Noise\r\n// Bruno Ruviaro, 2013-07-26\r\n// ************************************\r\n\r\n/*\r\n\r\nEach pad activates a differnt pattern of \"notes\" made of filtered white noise.\r\n\r\n*/\r\n\r\n\r\ns.waitForBoot({\r\n\r\n\tvar padsArray, patternArray, quneoChannel;\r\n\r\n\tpadsArray = Array.newClear(16);\r\n\tpatternArray = Array.newClear(16);\r\n\tquneoChannel = 11;\r\n\r\n\t// MIDIIn.connectAll;\r\n\r\n\tMIDIdef.freeAll;\r\n\r\n\tpatternArray[0] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\freq, Pwhite(100, 5500),\r\n\t\t\\pulseFreq, Pwhite(5, 10),\r\n\t\t\\dur, 0.3,\r\n\t\t\\amp, Pwhite(0.1, 0.5),\r\n\t\t\\rq, Pwhite(0.001, 0.05));\r\n\r\n\tpatternArray[1] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\degree, Pseq([0,3,5,7,9,11,14,17], inf),\r\n\t\t\\pulseFreq, Pwhite(1, 4),\r\n\t\t\\dur, 0.3,\r\n\t\t\\amp, 1,\r\n\t\t\\rq, 0.01);\r\n\r\n\tpatternArray[2] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\degree, Prand([0,3,5,7,9,11,14,17], inf) - 12,\r\n\t\t\\pulseFreq, Pwhite(1, 9),\r\n\t\t\\dur, 0.3,\r\n\t\t\\sustain, 0.1,\r\n\t\t\\amp, 1,\r\n\t\t\\rq, 0.1);\r\n\r\n\tpatternArray[3] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\degree, Pxrand([0,3,5,7,9,11,14,17], inf) + 12,\r\n\t\t\\pulseFreq, Pwhite(1, 9),\r\n\t\t\\dur, Pseq([0.2, 0.3, 0.2, 0.4], inf) * Pwhite(2, 4),\r\n\t\t\\sustain, 0.6,\r\n\t\t\\amp, Pwhite(0.05, 0.2),\r\n\t\t\\rq, Prand([0.05, 0.1], inf));\r\n\r\n\tpatternArray[4] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\scale, Scale.phrygian,\r\n\t\t\\degree, Pseq([0,3,5,7,9,11,14,17], inf),\r\n\t\t\\pulseFreq, Pwhite(3, 6),\r\n\t\t\\dur, 0.3,\r\n\t\t\\amp, 0.5,\r\n\t\t\\rq, Pwhite(0.005, 0.01));\r\n\r\n\tpatternArray[5] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\scale, Scale.phrygian,\r\n\t\t\\degree, Pseq([0,3,5,7,9,11,14,17], inf) + Pwrand([0, 1], [0.9, 0.1], inf),\r\n\t\t\\pulseFreq, Pwhite(3, 9),\r\n\t\t\\dur, Pseq([Pseq(0.33!8, 2), Pseq([0.1], 1)], inf),\r\n\t\t\\amp, Pwhite(0.3, 1),\r\n\t\t\\rq, Pwhite(0.005, 0.01));\r\n\r\n\tpatternArray[6] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\scale, Scale.phrygian,\r\n\t\t\\degree, Pseq([0,3,5,7,9,11,14,17], inf) + Pwrand([0, 1], [0.9, 0.1], inf),\r\n\t\t\\pulseFreq, 0.5,\r\n\t\t\\dur, Pseq( (0.1!60) ++ (0.2!8)   , inf),\r\n\t\t\\amp, 1,\r\n\t\t\\rq, Pwrand([0.005, 0.01], [0.95, 0.05], inf));\r\n\r\n\tpatternArray[7] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\freq, Pwhite(1000, 9500),\r\n\t\t\\pulseFreq, Pwhite(5, 10),\r\n\t\t\\dur, 0.3,\r\n\t\t\\amp, Pwhite(0.1, 0.2),\r\n\t\t\\rq, Pwhite(0.001, 0.05));\r\n\r\n\tpatternArray[8] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\degree, Pshuf([4,3,5,7,9,11,14,17], inf),\r\n\t\t\\pulseFreq, Pwhite(1, 9),\r\n\t\t\\dur, 0.3,\r\n\t\t\\amp, Pwhite(0.4, 0.5),\r\n\t\t\\rq, 0.01);\r\n\r\n\tpatternArray[9] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\note, Prand([0,3,5,7,9,11,14,17], inf),\r\n\t\t\\pulseFreq, Pwhite(1, 9),\r\n\t\t\\dur, 0.3,\r\n\t\t\\sustain, 0.1,\r\n\t\t\\amp, 0.1,\r\n\t\t\\rq, 0.1);\r\n\r\n\tpatternArray[10] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\degree, Pxrand([0,3,5,7,9,11,14,17], inf) - 12,\r\n\t\t\\pulseFreq, Pwhite(1, 9),\r\n\t\t\\dur, Pseq([0.2, 0.1, 0.2, 0.4], inf) * Pwhite(1, 4),\r\n\t\t\\sustain, 0.2,\r\n\t\t\\amp, Pwhite(0.3, 0.6),\r\n\t\t\\rq, Prand([0.05, 0.1], inf));\r\n\r\n\tpatternArray[11] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\scale, Scale.phrygian,\r\n\t\t\\degree, Pseq([0,5,9,3,7,11], inf),\r\n\t\t\\pulseFreq, Pwhite(5, 11),\r\n\t\t\\dur, 0.3,\r\n\t\t\\amp, 1,\r\n\t\t\\rq, Pwhite(0.005, 0.01));\r\n\r\n\tpatternArray[12] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\scale, Scale.phrygian,\r\n\t\t\\degree, Pseq([0,3,5,7,9,11,14,17], inf) + Pwrand([0, 12], [0.5, 0.5], inf),\r\n\t\t\\pulseFreq, Pwhite(1, 12),\r\n\t\t\\dur, 0.43,\r\n\t\t\\amp, 0.6,\r\n\t\t\\rq, Pwhite(0.005, 0.01));\r\n\r\n\tpatternArray[13] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\scale, Scale.locrian,\r\n\t\t\\degree, Pseq([7,8,6,5,4,3,2,1,0,4], inf) + Pwrand([0, 1], [0.9, 0.1], inf),\r\n\t\t\\pulseFreq, 0.5,\r\n\t\t\\dur, Pseq( (0.1!10) ++ (0.2!8)   , inf),\r\n\t\t\\amp, 0.6,\r\n\t\t\\rq, Pwrand([0.005, 0.01], [0.95, 0.05], inf));\r\n\r\n\tpatternArray[14] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\degree, Pxrand([1,3,4,7], inf) + 24,\r\n\t\t\\pulseFreq, Pwhite(1, 9),\r\n\t\t\\dur, Pseq([0.2, 0.3, 0.1, 0.4], inf) * Pwhite(2, 4),\r\n\t\t\\sustain, 0.6,\r\n\t\t\\amp, Pwhite(0.01, 0.13),\r\n\t\t\\rq, Prand([0.05, 0.1], inf));\r\n\r\n\tpatternArray[15] = Pbind(\r\n\t\t\\instrument, \"noise-quneo-2\",\r\n\t\t\\scale, Scale.mixolydian,\r\n\t\t\\degree, Pseq([0,7,5,3,9,11,0], inf),\r\n\t\t\\pulseFreq, Pwhite(1, 9),\r\n\t\t\\dur, 0.1,\r\n\t\t\\amp, 0.3,\r\n\t\t\\rq, Pwhite(0.001, 0.05));\r\n\r\n\tMIDIdef.noteOn(\r\n\t\tkey: \\noteOn,\r\n\t\tfunc: {arg vel, note;\r\n\t\t\tvar padNumber = note - 36; // starting from 0\r\n\t\t\t// var padNote = padNumber + 60; // middle C for first pad\r\n\t\t\tpadsArray[padNumber] = patternArray[padNumber].play;\r\n\t\t\t\tpadNumber.postln;\r\n\t\t},\r\n\t\tnoteNum: (36..51),\r\n\t\tchan: quneoChannel);\r\n\r\n\tMIDIdef.noteOff(\r\n\t\tkey: \\noteOff,\r\n\t\tfunc: {arg vel, note;\r\n\t\t\tvar padNumber = note - 36;\r\n\t\t\tpadsArray[padNumber].stop},\r\n\t\tnoteNum: (36..51),\r\n\t\tchan: quneoChannel);\r\n\r\nSynthDef(\"noise-quneo-2\", {arg freq = 1000, pulseFreq = 10, amp = 0.1, rq = 0.001, att = 0.01, dec = 0.3, sus = 1, rel = 1, gate = 1;\r\n\tvar snd, env;\r\n\tenv = EnvGen.kr(Env.adsr(att, dec, sus, rel), gate: gate, doneAction: 2);\r\n\tsnd = BPF.ar(WhiteNoise.ar(Impulse.ar(pulseFreq)), freq, Lag.kr(rq, 1));\r\n\tsnd = snd * env * Lag.kr(amp, 1) * 100;\r\n\tsnd = Clip.ar(snd, -0.5, 0.5);\r\n\tOut.ar(0, [snd, snd]);\r\n\t}).add;\r\n});",
   "labels" : [
      "patterns",
      "subtractive synthesis",
      "quneo",
      "white noise"
   ]
}
