{
   "labels" : [
      "ikeda",
      "ryojiikeda",
      "microsound",
      "puredata"
   ],
   "code" : "// Sound Simulator's \"Ryoji Ikeda Pure Data Tutorial\" ported to SC\r\n// source: https://www.youtube.com/watch?v=CLddxGIlVPU\r\n// I only did the porting, kudos to Sound Simulator for the original idea\r\n// and Pure Data implementation!\r\n\r\n(\r\n// SynthDefs & helper functions\r\n\r\n~coeff = {|freq| exp(-2pi * (freq * SampleDur.ir))};\r\n\r\nSynthDef(\\click, { |out, amp=0.1|\r\n\tvar snd;\r\n\tsnd = Impulse.ar(0);\r\n\tsnd = OnePole.ar(snd, ~coeff.(Rand(500, 10000)));\r\n\tDetectSilence.ar(snd, doneAction: Done.freeSelf);\r\n\tsnd = snd * amp;\r\n\tsnd = Pan2.ar(snd, pos: Rand(-1, 1));\r\n\tOut.ar(out, snd);\r\n}).add;\r\n\r\nSynthDef(\\highshort, { |out, amp=0.1|\r\n\tvar snd;\r\n\tsnd = SinOsc.ar(10000);\r\n\tsnd = snd * EnvGen.ar(Env([0,1,1,0], [0.001, 0.010, 0.010]), doneAction: Done.freeSelf);\r\n\tsnd = snd * amp;\r\n\tOut.ar(0, snd!2);\r\n}).add;\r\n\r\nSynthDef(\\bass, { |out, amp=0.1|\r\n\t//TODO: substitute HPF with OnePole+OneZero, but we must calculate the coeffs!\r\n\tvar snd, noi;\r\n\tsnd = SinOsc.ar([49, 98, 196]).sum * 2.0;\r\n\tsnd = Clip.ar(snd, -0.9, 0.9);\r\n\tsnd = OnePole.ar(snd, ~coeff.(50));\r\n\tsnd = HPF.ar(snd, 20);\r\n\tnoi = HPF.ar(OnePole.ar(WhiteNoise.ar, ~coeff.(100)), 500); // HPF = [hip~ 500]*2\r\n\tnoi = noi * EnvGen.ar(Env.linen(0.010, 0.005, 0.005));\r\n\tsnd = snd * EnvGen.ar(Env.linen(0.010, 1.090, 0.200), doneAction: Done.freeSelf);\r\n\tsnd = snd + noi;\r\n\tsnd = snd * amp;\r\n\tOut.ar(out, snd!2);\r\n}).add;\r\n\r\nSynthDef(\\envsine, { |out, amp=0.1|\r\n\tvar snd, noi;\r\n\tsnd = SinOsc.ar(1174);\r\n\tsnd = snd * EnvGen.ar(Env.linen(0.010, 0.200, 0.500));\r\n\tsnd = snd;\r\n\tsnd = FreeVerb2.ar(snd, snd, mix: 0.5, room: 0.7, damp: 0.2);\r\n\tsnd = snd * amp;\r\n\tDetectSilence.ar(snd, doneAction: Done.freeSelf);\r\n\tOut.ar(out, snd);\r\n}).add;\r\n\r\nSynthDef(\\highlong, { |out, amp=0.1|\r\n\tvar snd;\r\n\tsnd = SinOsc.ar(12544);\r\n\tsnd = snd * EnvGen.ar(Env.linen(0.001, 0.400, 0.150), doneAction: Done.freeSelf);\r\n\tsnd = snd * amp;\r\n\tOut.ar(out, snd!2);\r\n}).add;\r\n\r\nSynthDef(\\midsine, { |out, amp=0.1|\r\n\tvar snd, env;\r\n\tsnd = SinOsc.ar(3136);\r\n\tsnd = Clip.ar(snd, -0.9, 0.9);\r\n\tenv=Env.linen(0.005, 0.050, 0.010);\r\n\tsnd = snd * EnvGen.ar(env, doneAction: Done.freeSelf);\r\n\tsnd = snd * amp;\r\n\tOut.ar(out, snd!2);\r\n}).add;\r\n\r\nSynthDef(\\burst, { |out, amp=0.1|\r\n\tvar snd;\r\n\tsnd = WhiteNoise.ar(mul: -7.dbamp);\r\n\tsnd = snd * EnvGen.ar(Env.linen(0.001, 0.400, 0.010), doneAction: Done.freeSelf);\r\n\tsnd = snd * amp;\r\n\tOut.ar(out, snd!2);\r\n}).add;\r\n\r\n~xox = {|str| str.collectAs({|l| switch(l.toLower,$x, {1}, $o, {Rest(1)})}, Array)};\r\n)\r\n\r\n(\r\n// sequencing\r\n\r\n~tick32 = 0.08823;\r\n~tick16 = ~tick32 * 2;\r\n\r\n~p1 = \"xxxxxxxxxxxxxxxx\"; //click\r\n~p2 = \"xxxoxxooxxxooxxo\"; //highshort\r\n~p3 = \"xooooooooooooooooooxoooooooooooo\"; //bass\r\n~p4 = \"ooooooxooooooooooooooooooooooooo\"; //envsine\r\n~p5 = \"oooooooooooooooooooooooooxoooooo\"; //highlong\r\n~p6 = \"xooooooooooooooooooooooooooooooo\"\r\n   ++ \"xxoooooooooooooooooooooooooooooo\"; //midsine\r\n\r\n~p7 = Array.newClear(31).fill(Rest(~tick16)).add(~tick16).scramble; //burst\r\n\r\nPdef(\\ikeda, Ppar([\r\n\tPbind(\\instrument, \\click,     \\dur, Pseq(~tick32 * ~xox.(~p1), inf)),\r\n\tPbind(\\instrument, \\highshort, \\dur, Pseq(~tick32 * ~xox.(~p2), inf)),\r\n\tPbind(\\instrument, \\bass,      \\dur, Pseq(~tick16 * ~xox.(~p3), inf)),\r\n\tPbind(\\instrument, \\envsine,   \\dur, Pseq(~tick16 * ~xox.(~p4), inf)),\r\n\tPbind(\\instrument, \\highlong,  \\dur, Pseq(~tick16 * ~xox.(~p5), inf)),\r\n\tPbind(\\instrument, \\midsine,   \\dur, Pseq(~tick32 * ~xox.(~p6), inf)),\r\n\tPbind(\\instrument, \\burst,     \\dur, Pseq(~p7, inf)),\r\n])).play;\r\n)\r\n\r\nPdef(\\ikeda).stop;\r\n\r\n\r\n// test single synths\r\nz = Synth(\\click);\r\ny = Synth(\\highshort);\r\nx = Synth(\\bass);\r\nw = Synth(\\envsine);\r\nv = Synth(\\highlong);\r\nu = Synth(\\midsine);\r\nt = Synth(\\burst);",
   "is_private" : null,
   "id" : "1-5i2",
   "author" : "gosub",
   "name" : "Sound Simulator's \"Ryoji Ikeda Pure Data Tutorial\" ported to SC",
   "description" : "Sound Simulator's \"Ryoji Ikeda Pure Data Tutorial\" ported to SC\r\n\r\nsource: https://www.youtube.com/watch?v=CLddxGIlVPU\r\n\r\nI only did the porting, kudos to Sound Simulator for the original idea and Pure Data implementation!",
   "ancestor_list" : []
}
