{
   "ancestor_list" : [],
   "description" : "QuNeo pads play filtered white noise. Midinote becomes center frequency of a Band Pass Filter.",
   "author" : "Bruno Ruviaro",
   "name" : "Subtractive Synthesis Demo with QuNeo - Patch 1",
   "code" : "// ************************************\r\n// Subtractive Synthesis Demo (QuNeo)\r\n// Patch 1 - Filtered Noise\r\n// Bruno Ruviaro, 2013-07-26\r\n// ************************************\r\n\r\n/*\r\n\r\nPads play \"notes\" made of filtered white noise.\r\n(midinote becomes center frequency of a BPF).\r\n\r\nLong Slider controls filter's bandwidth ('Q').\r\n\r\nVertical Sliders control ADSR envelope.\r\n\r\n*/\r\n\r\n\r\ns.waitForBoot({\r\n\r\n\tvar padsArray, rqBus, ampAdjustmentBus, att = 0.01, dec = 0.3, sus = 1, rel = 1, quneoChannel;\r\n\r\n\tquneoChannel = 11;\r\n\tpadsArray = Array.newClear(64);\r\n\trqBus = Bus.control(s, 1).set(0.001);\r\n\tampAdjustmentBus = Bus.control(s, 1).set(20);\r\n\r\n\t// MIDIIn.connectAll;\r\n\r\n\tMIDIdef.freeAll;\r\n\r\n\t~toQuNeo = MIDIOut.newByName(\"QUNEO-QUNEO MIDI 1\", \"QUNEO-QUNEO MIDI 1\");\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\tvar padNote = padNumber + 60; // middle C for first pad\r\n\t\t\tpadsArray[padNumber] = Synth(\"noise-quneo\", [\r\n\t\t\t\t\\freq, padNote.midicps,\r\n\t\t\t\t\\amp, vel/127,\r\n\t\t\t\t\\rq, rqBus.asMap,\r\n\t\t\t\t\\ampAdjust, ampAdjustmentBus.asMap,\r\n\t\t\t\t\\att, att,\r\n\t\t\t\t\\dec, dec,\r\n\t\t\t\t\\sus, sus,\r\n\t\t\t\t\\rel, rel;\r\n\t\t])},\r\n\t\tnoteNum: (36..99),\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].release},\r\n\t\tchan: quneoChannel);\r\n\r\n\tMIDIdef.cc(\r\n\t\tkey: \\adsr,\r\n\t\tfunc: {arg val, ccnum;\r\n\t\t\tcase\r\n\t\t\t{ccnum==6} {att = val.linlin(0, 127, 0.01, 4)}\r\n\t\t\t{ccnum==7} {dec = val.linlin(0, 127, 0.05, 2)}\r\n\t\t\t{ccnum==8} {sus = val.linlin(0, 127, 0.10, 1)}\r\n\t\t\t{ccnum==9} {rel = val.linlin(0, 127, 0.05, 4)};\r\n\t\t\t[att, dec, sus, rel].round(0.01).postln},\r\n\t\tccNum: (6..9),\r\n\t\tchan: quneoChannel); // Vertical Sliders\r\n\t~toQuNeo.control(0, 1, 0.3.linlin(0.01, 4, 0, 127));\r\n\t~toQuNeo.control(0, 2, 0.3.linlin(0.05, 2, 0, 127));\r\n\t~toQuNeo.control(0, 3, 1.linlin(0.1, 1, 0, 127));\r\n\t~toQuNeo.control(0, 4, 1.linlin(0.05, 4, 0, 127));\r\n\r\n\tMIDIdef.cc(\r\n\t\tkey: \\rqslider,\r\n\t\tfunc: {arg val, ccnum;\r\n\t\t\tvar newVal = val.linexp(0, 127, 0.0001, 0.2);\r\n\t\t\trqBus.value = newVal;\r\n\t\t\tampAdjustmentBus.value = val.linexp(0, 127, 100, 1);\r\n\t\t\t(\"RQ is \"++newVal.round(0.0001)).postln},\r\n\t\tccNum: 10, // Long Slider\r\n\t\tchan: quneoChannel);\r\n\r\n\t~toQuNeo.control(0, 6, 1); // init Long Slider\r\n\r\n\tSynthDef(\"noise-quneo\", {arg freq = 1000, amp = 0.1, rq = 0.001, att = 0.01, dec = 0.3, sus = 1, rel = 1, gate = 1, ampAdjust = 1;\r\n\t\tvar snd, env;\r\n\t\tenv = EnvGen.kr(Env.adsr(att, dec, sus, rel), gate: gate, doneAction: 2);\r\n\t\tsnd = BPF.ar(WhiteNoise.ar(amp), freq, Lag.kr(rq, 1));\r\n\t\tsnd = snd * env * Lag.kr(ampAdjust, 1);\r\n\t\tOut.ar(0, [snd, snd]);\r\n\t}).add;\r\n\r\n}); // end of block",
   "is_private" : null,
   "id" : "1-4UQ",
   "labels" : [
      "subtractive synthesis",
      "quneo",
      "white noise"
   ]
}
