{
   "ancestor_list" : [],
   "description" : "A simple GUI for Waveset Synthesis. Requires WavesetsEvent, which should be placed in your SC extensions folder. Most of the code came from the included help files.\r\n\r\nhttps://github.com/musikinformatik/WavesetsEvent",
   "name" : "Simple GUI for WavesetsEvent",
   "author" : "IMF",
   "id" : "1-5du",
   "is_private" : null,
   "code" : "/***************************************************\r\n****************************************************\r\n\r\nA simple GUI for Waveset Synthesis.\r\n\r\nRequires WavesetsEvent, which should be placed in your\r\nSC extensions folder.\r\n\r\nMost of the code came from the included help files.\r\nhttps://github.com/musikinformatik/WavesetsEvent\r\n\r\n***************************************************\r\n***************************************************/\r\n\r\n(\r\ns.waitForBoot{\r\n\r\nvar numSliders = 9;\r\nvar numButtons = 3;\r\nvar switchFile, sliders, buttons, actions, labels, controls, init;\r\n\r\nWavesetsEvent.prepareSynthDefs;\r\n~wavesets = ~wavesets ?? {\r\n\tWavesetsEvent.read(Platform.resourceDir +/+ \"sounds/a11wlk01-44_1.aiff\")\r\n};\r\n\r\nTdef(\\ws, {\r\n\tinf.do{ |i|\r\n\t\tvar event = ~wavesets.asEvent((\r\n\t\t\tstart: ( i % ~wavesets.size) + ~shuf.rand, //from which waveset to start + waveset shuffle\r\n\t\t\tnum: ~numWs, //how many wavesets to play\r\n\t\t\trepeats: ~repeats, // how many times to repeat the selected wavesets\r\n\t\t\trate: ~playRate, //playback speed of the audio file\r\n\t\t\trate2: ~playRate2, //end playback speed of the audio file (will create a linear glisson sweep)\r\n\t\t\tamp: if(~prob.coin, {~volume}, {0}), //scale the amplitude of the original sound + random waveset omission from 0 - 100%\r\n\t\t\tpan: ~pan, //stereo panorama position\r\n\t\t\tlegato: ~legato //scales the duration, so that wavesets will overlap or have gaps between them.\r\n\t\t\t));\r\n\t\tevent.play;\r\n\t\tevent[\\dur].wait;\r\n\t}\r\n});\r\n\r\n\r\n//gui\r\nw = Window.new(\"wavesets\", Rect(128, 64, 400, 400)).front;\r\nw.addFlowLayout;\r\nw.view.decorator.gap=5@5;\r\n\r\n\tlabels = [\"numWs\", \"repeats\", \"playRate\", \"playRate2\", \"volume\", \"pan\",  \"legato\", \"shuffle\", \"omission\"];\r\n\r\ncontrols = (\r\n\t\tnumWs: [1, 50, \\lin, 1],\r\n\t\trepeats: [1, 10, \\lin, 1],\r\n\t\tplayRate: [-10, 10, \\lin],\r\n\t\tplayRate2: [-10, 10, \\lin],\r\n\t\tvolumes: [0, 1, \\lin],\r\n\t\tpan: [-1, 1, \\lin],\r\n\t\tlegato: [0.001, 2, \\lin],\r\n\t\tshuffle: [0, 100, \\lin, 1],\r\n\t\tomission: [0, 1, 'lin']\r\n\t);\r\n\r\ninit = [1, 2, 1, 1.5, 1, 0, 1, 0, 1];\r\n\r\nactions = (\r\n\t\tnumWs: {|v| ~numWs = v},\r\n\t\trepeats: {|v| ~repeats = v},\r\n\t\tplayRate: {|v| ~playRate = v},\r\n\t\tplayRate2: {|v| ~playRate2 = v},\r\n\t\tvolume: {|v| ~volume = v},\r\n\t\tpan: {|v| ~pan = v},\r\n\t\tlegato: {|v| ~legato = v},\r\n\t\tshuffle: {|v| ~shuf = v},\r\n\t\tomission: {|v| ~prob = v}\r\n\t);\r\n\r\n//create buttons\r\nbuttons = numButtons.collect{|i|\r\n\tButton.new(w, 125@30);\r\n};\r\n\r\n//create sliders\r\nsliders = numSliders.collect{|i|\r\n\t\tEZSlider.new(w, 390@30, labels[i], controls[labels[i].asSymbol], {|sl| actions[labels[i].asSymbol].(sl.value)}, init[i], true)\r\n\t\t.setColors(sliderBackground: Color.rand);\r\n};\r\n\r\n//new soundfile button\r\nbuttons[0]\r\n.states_(\r\n\t[[\"Switch File\", Color.black]]\r\n)\r\n.action_({|obj|\r\n\tDialog.openPanel({ | path |\r\n\t\tvar ws = WavesetsEvent.new;\r\n\t\tws.readChannel(path, onComplete: { ~wavesets = ws; ~path = path })\r\n\t});\r\n});\r\n\r\n//start button\r\nbuttons[1]\r\n.states_(\r\n\t[[\"Start\", Color.black]]\r\n)\r\n.action_({|obj|\r\n\tTdef(\\ws).play;\r\n});\r\n\r\n//stop button\r\nbuttons[2]\r\n.states_(\r\n\t[[\"Stop\", Color.black]]\r\n)\r\n.action_({|obj|\r\n\tTdef(\\ws).stop;\r\n});\r\n\r\n}\r\n\r\n)",
   "labels" : [
      "gui",
      "granular synthesis",
      "wavesets",
      "wavesetsevent"
   ]
}
