{
   "labels" : [
      "sampler",
      "looper",
      "quneo"
   ],
   "code" : "/* Sébastien Clara - octobre 2013\r\n// QuNeoSamplerMelodic  v201310\r\n\r\n\r\nYou NEED to install and configure the QuNeo library on Quarks.\r\n\r\n\r\nA QuNeo's Sampler melodic and expressive with different scales.\r\n\r\n  Usage :\r\nHorizontal pad => second for heptatonic scale.\r\nVertical pad => third for heptatonic scale.\r\nFor change the configuration, see variable padsDegree.\r\n\r\npad X => frequency of the vibrato.\r\npad Y => amplitude of the vibrato.\r\n\r\ncircles[0] => change the scale.\r\n\r\n\r\nIf you have a problem with the 15 pad, see http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/QuNeo-Quark-tp7598479p7603927.html\r\n*/\r\n\r\n(\r\ns.waitForBoot({\r\n////////////////////////////////////////////////////////////////////////\r\n// Initialisation\r\n\tvar window, scalePopUp, scalesIndexTxt, selectSampleButton;\r\n\tvar scale, padsDegree = [0,1,2,3, 2,3,4,5, 4,5,6,7, 6,7,8,9];\r\n\tvar scalesIndex = 51, locMoinsUn = 1;\r\n\tvar sampler = Array.fill(padsDegree.size, {nil});\r\n\tvar buffer = Buffer.read(s, Platform.resourceDir +/+ \"sounds/a11wlk01.wav\");\r\n\r\n\tSynthDef(\\looper, { arg out=0, buffer, rate=1, amp=0.5, vibFreq=7, vibAmp=0;\r\n\t\tvar signal;\r\n\r\n\t\tsignal =  PlayBuf.ar(1, buffer, BufRateScale.kr(buffer)*rate, loop:1);\r\n\t\tsignal = signal * SinOsc.kr(vibFreq*15, mul:vibAmp, add:1);\r\n\t\tsignal = signal * amp * EnvGate.new(curve:\\welch);\r\n\r\n\t\tOut.ar(out, signal.dup);\r\n\t}).add;\r\n\r\n\t// QuNeo's functions\r\n\tpadsDegree.size.do({ |i|\r\n\t\t~quNeo.pads[i].note.onFunc = {\r\n\t\t\tsampler[i] = Synth(\\looper, [\\buffer,buffer,\r\n\t\t\t\t\\rate, scale.degreeToRatio(padsDegree[i], 0),\r\n\t\t\t\t\\amp, ~quNeo.pads[i].press.map,\r\n\t\t\t\t\\vibFreq, ~quNeo.pads[i].x.map,\r\n\t\t\t\t\\vibAmp, ~quNeo.pads[i].y.map\r\n\t\t\t])\r\n\t\t};\r\n\r\n\t\t~quNeo.pads[i].note.offFunc = {\r\n\t\t\tsampler[i].set(\\fadeTime,0.02, \\gate,0);\r\n\t\t};\r\n\t});\r\n\t~quNeo.circles[0].loc.func = {\r\n\t\tcase\r\n\t\t{((~quNeo.circles[0].loc.value*10).round > locMoinsUn).and(scalesIndex < (scalePopUp.items.size-1))}\r\n\t\t{scalesIndex = scalesIndex + 1}\r\n\r\n\t\t{((~quNeo.circles[0].loc.value*10).round < locMoinsUn).and(scalesIndex > 0)}\r\n\t\t{scalesIndex = scalesIndex - 1};\r\n\r\n\t\tif (locMoinsUn != (~quNeo.circles[0].loc.value*10).round, {\r\n\t\t\tlocMoinsUn = (~quNeo.circles[0].loc.value*10).round;\r\n\t\t\t{scalePopUp.valueAction = (scalesIndex)}.defer;\r\n\t\t});\r\n//\t\tpostf(\"scalesIndex = %  --  loc = %  --  loc-1 = %\\n\", scalesIndex, (~quNeo.circles[0].loc.value*10).round, locMoinsUn  );\r\n\t};\r\n////////////////////////////////////////////////////////////////////////\r\n// Gui\r\n\twindow = Window(\"A QuNeo's Sampler\", Rect(500, 700, 250, 50));\r\n\r\n\tselectSampleButton = Button(window).states_([[\"Select a sample\"]]);\r\n\tscalePopUp = PopUpMenu(window).items_(ScaleInfo.scales.keys.asArray.sort);\r\n\tscalesIndexTxt = StaticText(window).align_(\\center);\r\n\r\n\twindow.layout_( VLayout(\r\n\t\tselectSampleButton,\r\n\t\tHLayout(scalePopUp, scalesIndexTxt)\r\n\t) ).front;\r\n\r\n////////////////////////////////////////////////////////////////////////\r\n// Actions\r\n\tscalePopUp.action = { arg menu;\r\n\t\tscale = ScaleInfo.at(menu.item);\r\n//\t\tpostf(\"\\t*** Using scale: ---> %\\n\", menu.item.asString);\r\n\t\tscalesIndex = menu.value;\r\n\t\tscalesIndexTxt.string = menu.value.asString;\r\n\t};\r\n\tscalePopUp.valueAction = (scalesIndex);\r\n\r\n\tselectSampleButton.action = {\r\n\t\tDialog.openPanel({ arg pathFile;\r\n\t\t\t(\"sample =>\" + pathFile).postln;\r\n\t\t\tbuffer = Buffer.read(s, pathFile);\r\n\t\t});\r\n\t};\r\n\r\n\twindow.onClose = {\r\n\t\tpadsDegree.size.do({ |i|\r\n\t\t\t~quNeo.pads[i].note.onFunc = nil;\r\n\t\t\t~quNeo.pads[i].note.offFunc = nil;\r\n\t\t});\r\n\t\t~quNeo.circles[0].loc.func = nil;\r\n//\t\t\"Clear QuNeo's functions.\\n\".postln;\r\n\t};\r\n})\r\n)",
   "is_private" : null,
   "id" : "1-4V4",
   "name" : "A QuNeo's Sampler melodic and expressive with different scales",
   "author" : "sebastienclara",
   "ancestor_list" : [],
   "description" : ""
}
