{
   "code" : "/*\r\n A SuperCollider implementation of the synth sound described here:\r\n \"http://www.attackmagazine.com/technique/synth-secrets/detuned-pad/\"\r\n*/\r\n\r\n// Chord seq:\r\n// 1. (E1, E2, B3, D4, G4)\r\n// 2. (G1, G2, B3, D4, F#4, A4)\r\n// 3. (G1, G2, B3, D4, F#4, A4, B4)\r\n// 4. (A1, A2, C4, E4, G4)\r\n// 5. (C1, C2, G3, E4, G4)\r\n\r\n(\r\n// sequence\r\n~crdStr = [[\"E1\", \"E2\", \"B3\", \"D4\", \"G4\"],\r\n\t[\"G1\", \"G2\", \"B3\", \"D4\", \"F#4\", \"A4\"],\r\n\t[\"B4\"],\r\n\t[\"A1\", \"A2\", \"C4\", \"E4\", \"G4\"],\r\n\t[\"C1\", \"C2\", \"G3\", \"E4\", \"G4\"]\r\n];\r\n\r\n// Map from chord names to midi notes\r\n~noteToMidi = {\r\n\targ noteStr;\r\n\tvar notes = Dictionary[\r\n\t\"C\"  -> 0,\r\n\t\"C#\" -> 1,\r\n\t\"D\"  -> 2,\r\n\t\"D#\" -> 3,\r\n\t\"E\"  -> 4,\r\n\t\"F\"  -> 5,\r\n\t\"F#\" -> 6,\r\n\t\"G\"  -> 7,\r\n\t\"G#\" -> 8,\r\n\t\"A\"  -> 9,\r\n\t\"A#\" -> 10,\r\n\t\"B\"  -> 11];\r\n\tvar octave = noteStr.last.digit;\r\n\tvar degree = notes[noteStr[..noteStr.size-2].postln];\r\n\toctave*12 + degree;\r\n};\r\n\r\n~crdArray = ~crdStr.collect{\r\n\targ crd;\r\n\tcrd.collect{|c| ~noteToMidi.(c)};\r\n};\r\n)\r\n\r\n// STEP 1: a simple synth\r\n(\r\n// Init synth\r\nSynthDef(\\simpSaw1, {|freq, gate=1|\r\n\tvar env = EnvGen.ar(Env.adsr(0.01,0.3,0.5,0.1), gate, doneAction:2);\r\n\tvar snd = Saw.ar(freq!2);\r\n\tOut.ar(0, env*snd);\r\n}).add;\r\n)\r\n\r\n// Play chord seq\r\n(\r\nPbind(\r\n\t\\instrument, \\simpSaw1,\r\n\t\\freq, Pseq(~crdArray + 24, inf).midicps,\r\n\t\\dur, 2.5*Pseq([1, 0.375, 0.625, 1, 1], 1),\r\n\t\\sustain, 2.55*Pseq([1, 1, 0.625, 1, 1], 1)\r\n).play;\r\n)\r\n\r\n// STEP2: add voices/detune/de-phase\r\n\r\n(\r\nSynthDef(\\simpSaw2, {|freq, gate=1|\r\n\tvar adsr = EnvGen.ar(Env.adsr(0.25,0.01,0.75,0.25), gate, doneAction:2);\r\n\tvar nvoices1 = 5, nvoices2 = 7;\r\n\tvar detune1 = 10, detune2 = 5;\r\n\r\n\tvar osc1 = {\r\n\t\tvar m = 2**(detune1/1200).rand2;\r\n\t\tvar saw = LFSaw.ar(m * freq/2);\r\n\t\tDelayC.ar(saw, 0.02, freq.reciprocal.rand);\r\n\t}.dup(nvoices1);\r\n\r\n\tvar osc2 = {\r\n\t\tvar m = 2**(detune2/1200).rand2;\r\n\t\tvar saw = LFSaw.ar(m * freq);\r\n\t\tDelayC.ar(saw, 0.02, freq.reciprocal.rand);\r\n\t}.dup(nvoices2);\r\n\r\n\tOut.ar(0, Splay.ar(osc1 + osc2 * adsr)/4);\r\n}).add;\r\n)\r\n\r\n// Play chord seq\r\n(\r\nPbind(\r\n\t\\instrument, \\simpSaw2,\r\n\t\\freq, Pseq(~crdArray+24, inf).midicps,\r\n\t\\dur, 2.5*Pseq([1, 0.375, 0.625, 1, 1], 1),\r\n\t\\sustain, 2.5*Pseq([1, 1, 0.625, 1, 1], 1)\r\n).play;\r\n)\r\n\r\n\r\n// STEP3: add LFO\r\n(\r\nSynthDef(\\simpSaw3, {|freq, gate=1|\r\n\tvar adsr = EnvGen.ar(Env.adsr(0.25,0.01,0.75,0.25), gate, doneAction:2);\r\n\tvar nvoices1 = 5, nvoices2 = 7;\r\n\tvar detune1 = 10, detune2 = 5;\r\n\r\n\tvar osc1 = {\r\n\t\tvar m = 2**(detune1/1200).rand2;\r\n\t\tvar lfo = SinOsc.ar(3.rand).range(0,1);\r\n\t\tDelayC.ar(Saw.ar(m * freq/2), 0.02, freq.reciprocal.rand * lfo);\r\n\t}.dup(nvoices1);\r\n\r\n\tvar osc2 = {\r\n\t\tvar m = 2**(detune2/1200).rand2;\r\n\t\tvar lfo = SinOsc.ar(3.rand).range(0,1);\r\n\t\tDelayC.ar(Saw.ar(m * freq), 0.02, freq.reciprocal.rand * lfo);\r\n\t}.dup(nvoices2);\r\n\r\n\tOut.ar(0, Splay.ar(osc1 + osc2 * adsr)/4);\r\n}).add;\r\n)\r\n\r\n// Play chord seq\r\n(\r\nPbind(\r\n\t\\instrument, \\simpSaw3,\r\n\t\\freq, Pseq(~crdArray+24, inf).midicps,\r\n\t\\dur, 2.5*Pseq([1, 0.375, 0.625, 1, 1], 1),\r\n\t\\sustain, 2.5*Pseq([1, 1, 0.625, 1, 1], 1)\r\n).play;\r\n)\r\n\r\n// STEP4: add filter\r\n(\r\nSynthDef(\\simpSaw4, {|freq, gate=1|\r\n\tvar adsr = EnvGen.ar(Env.adsr(1e-8,1e-6,0.75,0.125), gate, doneAction:2);\r\n\tvar nvoices1 = 5, nvoices2 = 7;\r\n\tvar detune1 = 12, detune2 = 8;\r\n\r\n\tvar osc1 = {\r\n\t\tvar m = 2**(detune1/1200).rand2;\r\n\t\tvar lfo = SinOsc.ar(3.rand).range(0,1);\r\n\t\tDelayC.ar(LFSaw.ar(m * freq/2), 0.02, freq.reciprocal.rand * lfo);\r\n\t}.dup(nvoices1);\r\n\r\n\tvar osc2 = {\r\n\t\tvar m = 2**(detune2/1200).rand2;\r\n\t\tvar lfo = SinOsc.ar(3.rand).range(0,1);\r\n\t\tDelayC.ar(LFSaw.ar(m * freq), 0.02, freq.reciprocal.rand * lfo);\r\n\t}.dup(nvoices2);\r\n\r\n\tvar snd = BLowPass4.ar(osc1, 800, 0.5) + osc2 / 4;\r\n\tOut.ar(0, Splay.ar(snd*adsr));\r\n}).add;\r\n)\r\n\r\n// Play chord seq\r\n(\r\nPbind(\r\n\t\\instrument, \\simpSaw4,\r\n\t\\freq, Pseq(~crdArray+24, inf).midicps,\r\n\t\\dur, 2.5*Pseq([1, 0.375, 0.625, 1, 1], 1),\r\n\t\\sustain, 2.5*Pseq([1, 1, 0.625, 1, 1], 1)\r\n).play(quant: 1);\r\n)\r\n\r\n// Now Let's hear each version one at a time:\r\n(\r\n{\r\n\t~list = [\\simpSaw1, \\simpSaw2, \\simpSaw3, \\simpSaw4];\r\n\t4.do{\r\n\t\targ i;\r\n\t\tPbind(\r\n\t\t\t\\instrument, ~list[i],\r\n\t\t\t\\freq, Pseq(~crdArray+24, inf).midicps,\r\n\t\t\t\\dur, 2.5*Pseq([1, 0.375, 0.625, 1, 1], 1),\r\n\t\t\t\\sustain, 2.5*Pseq([1, 1, 0.625, 1, 1], 1)\r\n\t\t).play(quant: 1);\r\n\t\t(2.5*[1, 0.375, 0.625, 1, 1].sum + 0.125).wait;\r\n\t};\r\n}.fork;\r\n)",
   "is_private" : null,
   "id" : "1-4YS",
   "labels" : [
      "synth",
      "pad",
      "sound design"
   ],
   "description" : "A SuperCollider implementation of the synth sound described here:\r\n \"http://www.attackmagazine.com/technique/synth-secrets/detuned-pad/\"",
   "ancestor_list" : [],
   "author" : "coreyker",
   "name" : "Detuned Synth Pad"
}
