{
   "labels" : [
      "percussion",
      "drums",
      "organ",
      "synthdef",
      "piano",
      "tradicional instrumens",
      "woodwind",
      "brass"
   ],
   "is_private" : null,
   "id" : "1-5aD",
   "code" : "//\\\\##//\\\\##//\\\\##//\\\\##//\\\\##//\\\\##//\\\\##//\\\\\r\n//\\\\##//\\\\##                  //\\\\##//\\\\##//\\\\\r\n//\\\\##//\\\\##  SynthDEFaults   //\\\\##//\\\\##//\\\\\r\n//\\\\##//\\\\##                  //\\\\##//\\\\##//\\\\\r\n//\\\\##//\\\\##//\\\\##//\\\\##//\\\\##//\\\\##//\\\\##//\\\\\r\n\r\n/*\r\n- A Collection of Tradicional SynthDefs-\r\n//under GNU GPL 3 as per SuperCollider license\r\n//Organized by Zé Craum\r\n\r\n//This is the first scratch, ASAP it will be avaible in a more organized form.\r\n\r\n//Some Guidelines from uploading contributiong or helping organizing existing stuff:\r\n1.Executing code should return a SynthDef;\r\n2.The SynthDEFaults should have ControlSpecs for every parameter to define an acceptable range;\r\n3.The SynthDEFaults should not depend on things outside of the core lib or sc3-plugins;\r\n4.The SynthDEFaults should have reasonable defaults that allow it to make a representative sound with no arguments;\r\n5. SynthDEFaults symbol should be always be like \\Piano_BabyGrandPiano; \\Guitar_FDBEletric...\r\n6. SynthDEFaults must be written using NamedControl Style (Still being updated);\r\n6.1. Additional arguments besides from amp/dur/pitch default events must be written as local variables and must have comments;\r\n7. All the SynthDef should be designed for working with the main scope of Patterns\r\n\r\nExamples at: http://sccode.org/1-5aE\r\n\r\nContribuitions, comments, advises, criticisms, etc are very welcome: zecraum at gmail com\r\n//\r\n\r\n*/\r\n(\r\n\r\n//  //  //  //  //  //\r\n////    Pianos    ////\r\n//  //  //  //  //  //\r\n\r\nSynthDef(\\piano_MDA, {\r\n\t//Piano synth based on Mda Plugin\r\n    |out = 0, freq= 440, gate= 1, vel= 80, decay= 0.8, release= 0.8, hard= 0.4, velhard= 0.8, muffle= 0.8, velmuff= 0.8, velcurve= 0.8, stereo= 0.2, tune= 0.5, random= 0.1, stretch= 0.1, sustain= 0, mul= 1, add= 0, amp = 0.5|\r\n    var snd;\r\n    snd = MdaPiano.ar(freq, gate, vel, decay, release, hard, velhard, muffle, velmuff, velcurve, stereo, tune, random, stretch, sustain, mul, add);\r\n    snd = snd * EnvGen.kr(Env.asr(0, 1, 0.1), gate, doneAction: 2);\r\n    Out.ar(out, snd * amp);\r\n//by ????\r\n\r\n}).add;\r\n\r\n//  //  //  //  //  //  //  //  //\r\n////     Electric Pianos      ////\r\n//  //  //  //  //  //  //  //  //\r\n\r\n\r\nSynthDef(\\Piano_rhodeySC, {\r\n\t//FM Rhodes Synthethizer\r\n    |\r\n    // standard meanings\r\n    out = 0, freq = 440, gate = 1, pan = 0, amp = 0.1,\r\n    // all of these range from 0 to 1\r\n    vel = 0.8, modIndex = 0.2, mix = 0.2, lfoSpeed = 0.4, lfoDepth = 0.1\r\n    |\r\n    var env1, env2, env3, env4;\r\n    var osc1, osc2, osc3, osc4, snd;\r\n\r\n    lfoSpeed = lfoSpeed * 12;\r\n\r\n    freq = freq * 2;\r\n\r\n    env1 = EnvGen.ar(Env.adsr(0.001, 1.25, 0.0, 0.04, curve: \\lin));\r\n    env2 = EnvGen.ar(Env.adsr(0.001, 1.00, 0.0, 0.04, curve: \\lin));\r\n    env3 = EnvGen.ar(Env.adsr(0.001, 1.50, 0.0, 0.04, curve: \\lin));\r\n    env4 = EnvGen.ar(Env.adsr(0.001, 1.50, 0.0, 0.04, curve: \\lin));\r\n\r\n    osc4 = SinOsc.ar(freq * 0.5) * 2pi * 2 * 0.535887 * modIndex * env4 * vel;\r\n    osc3 = SinOsc.ar(freq, osc4) * env3 * vel;\r\n    osc2 = SinOsc.ar(freq * 15) * 2pi * 0.108819 * env2 * vel;\r\n    osc1 = SinOsc.ar(freq, osc2) * env1 * vel;\r\n    snd = Mix((osc3 * (1 - mix)) + (osc1 * mix));\r\n    snd = snd * (SinOsc.ar(lfoSpeed) * lfoDepth + 1);\r\n\r\n    // using the doneAction: 2 on the other envs can create clicks (bc of the linear curve maybe?)\r\n    snd = snd * EnvGen.ar(Env.asr(0, 1, 0.1), gate, doneAction: 2);\r\n    snd = Pan2.ar(snd, pan, amp);\r\n\r\n    Out.ar(out, snd);\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-522\r\n}).add;\r\n\r\n\r\nSynthDef(\\everythingrhodes,{|out= 0 freq = 440 amp = 0.1 gate=1 lforate = 4.85 lfowidth= 0.5 cutoff= 2000 rq=0.5 pan = 0.0|\r\n\r\n//Electric Piano\r\n\tvar pulse, filter, env;\r\n\r\n\tpulse = Pulse.ar(freq*[1,33.5.midiratio],[0.2,0.1],[0.7,0.3]);\r\n\r\n\tenv = EnvGen.ar(Env.adsr(0.0,1.0,0.8,3.0),gate,doneAction:2);\r\n\r\n\t//keyboard tracking filter cutoff\r\n\tfilter = BLowPass4.ar(pulse,(cutoff*(env.squared))+200+freq,rq);\r\n\r\n\tOut.ar(out,Pan2.ar(Mix(filter)*env*amp,pan));\r\n\r\n//By Nick Collins, from Mitchell Sigman (2011) Steal this Sound\r\n//http://www.sussex.ac.uk/Users/nc81/index.html\r\n}).add;\r\n\r\n\r\n//  //  //  //  //  //  //  //\r\n////    Harpsichord     ////\r\n//  //  //  //  //  //  //  //\r\n\r\nSynthDef(\\harpsichord_simple, { arg out = 0, freq = 440, amp = 0.1, pan = 0;\r\n    var env, snd;\r\n\tenv = Env.perc(level: amp).kr(doneAction: 2);\r\n\tsnd = Pulse.ar(freq, 0.25, 0.75);\r\n\tsnd = snd * env;\r\n\tOut.ar(out, Pan2.ar(snd, pan));\r\n\r\n//Simple and light harpsichord\r\n//By Bruno Ruviaro\r\n//https://github.com/brunoruviaro/SynthDefs-for-Patterns/blob/master/harpsichord.scd\r\n}).add;\r\n\r\nSynthDef(\\harpsichord_pluck, {\r\n\t|amp=0.1, freq=440, pan=0, atk=0, rel=0, trig= 1, maxdelaytime= 0.2, decaytime= 7, coef= 0.1|\r\n\tvar env, sig, delay;\r\n\tenv = EnvGen.kr(Env.linen(atk, decaytime, rel), doneAction: Done.freeSelf);\r\n\tsig = PinkNoise.ar(amp); //Can use white noise here, but Pink is more realistic\r\n\tdelay = freq.reciprocal;\r\n\tsig = Pluck.ar(sig, trig, maxdelaytime , delay , decaytime , coef ) //fundamental\r\n\t+ Pluck.ar(sig, trig, maxdelaytime , delay/2 , decaytime , coef ); //octave higher\r\n\tOut.ar(0, Pan2.ar(sig , pan));\r\n//Harpsichord based on Pluck Ugen\r\n//By Zé Craum\r\n\r\n}).add;\r\n\r\n//  //  //  //  //  //\r\n////  Organs    ////\r\n//  //  //  //  //  //\r\n\r\nSynthDef(\\organ_tonewheel0, {\r\n\t//additive tonewheel organ with few CPU usage\r\n\r\n\targ freq = 440, amp = 0.7, atk = 0.001, sus = 0.2, rel = 0.01, pan = 0,\r\n\tbass = 1, quint = 1, fundamental = 1, oct = 1, nazard = 1, blockFlute = 1, tierce = 1, larigot = 1, sifflute = 1, //organ voices (drawbars) amplitudes\r\n    vrate = 3, vdepth = 0.008; //vibrato arguments\r\n\tvar sig, env, vibrato;\r\n\r\n\tvibrato = SinOsc.kr(DC.kr(vrate)).range(1 - DC.kr(vdepth), 1+ DC.kr(vdepth));\r\n\tenv = EnvGen.ar(Env.linen(atk, sus, rel), doneAction: Done.freeSelf);\r\n\tsig = DynKlang.ar(`[[1/12,  1/7, 1, 12, 19, 24, 28, 31, 36].midiratio, ([DC.ar(bass) , DC.ar(quint), DC.ar(fundamental), DC.ar(oct), DC.ar(nazard), DC.ar(blockFlute), DC.ar(tierce), DC.ar(larigot), DC.ar(sifflute)].normalizeSum), nil], vibrato * freq);\r\n\r\n\tsig = sig * env;\r\n\tOut.ar(0, Pan2.ar(sig, pan, amp));\r\n//By Zé Craum\r\n}).add;\r\n\r\nSynthDef(\\organ_tonewheel1, {\r\n\t//additive tonewheel organ with more CPU usage\r\n\r\n\targ freq = 440, amp = 0.7, atk = 0.001, sus = 0.2, rel = 0.01, pan = 0,\r\n\tbass = 1, quint = 1, fundamental = 1, oct = 1, nazard = 1, blockFlute = 1, tierce = 1, larigot = 1, sifflute = 1, //organ voices (drawbars) amplitudes\r\n    vrate = 3, vdepth = 0.008, vdelay = 0.1, vonset = 0, vrateVariation = 0.1, vdepthVariation = 0.1; //vibrato arguments\r\n\tvar sig, env, vibrato;\r\n\r\n\tvibrato = Vibrato.kr(DC.kr(freq), DC.kr(vrate), DC.kr(vdepth), DC.kr(vdelay), DC.kr(vonset), DC.kr(vrateVariation), DC.kr(vdepthVariation));\r\n\tenv = EnvGen.ar(Env.linen(atk, sus, rel), doneAction: Done.freeSelf);\r\n\tsig = DynKlang.ar(`[[1/12,  1/7, 1, 12, 19, 24, 28, 31, 36].midiratio, ([DC.ar(bass) , DC.ar(quint), DC.ar(fundamental), DC.ar(oct), DC.ar(nazard), DC.ar(blockFlute), DC.ar(tierce), DC.ar(larigot), DC.ar(sifflute)].normalizeSum), nil], vibrato);\r\n\r\n\tsig = sig * env;\r\n\tOut.ar(0, Pan2.ar(sig, pan, amp));\r\n//By Zé Craum\r\n}).add;\r\n\r\n\r\nSynthDef(\\organ_tonewheel2, {\r\n\t//subtractive tonewheel organ with cheap CPU usage\r\n\targ freq = 440, amp = 0.9, atk = 0.001, sus = 0.4, rel = 0.1, tune = 0.29, tuneRate = 6.0, rq = 1;\r\n\tvar sig, env, vibrato;\r\n\tenv = EnvGen.ar(Env.linen(atk, sus, rel, 0.5), doneAction: Done.freeSelf);\r\n\tvibrato = SinOsc.ar(tuneRate).range(freq, freq * (tune.midiratio));\r\n\tsig = LFPulse.ar(freq, 0, 0.5, 0.2) + LFPulse.ar(freq + vibrato, 0, 0.18);\r\n\tsig = RLPF.ar(sig /*+ PinkNoise.ar(20/freq) */, ((28.midiratio) * (freq)) , rq) ;\r\n\r\n\tsig = sig * env;\r\n\tsig = sig * amp;\r\n\tsig = LeakDC.ar(sig);\r\n\tOut.ar(0, sig!2);\r\n//By Zé Craum\r\n}).add;\r\n\r\n\r\n\r\nSynthDef(\\organ_tonewheel3, {\r\n\t//subtractive tonewheel organ with more CPU usage\r\n\targ freq = 440, amp = 0.9, atk = 0.001, sus = 0.4, rel = 0.1, vrate = 6, vdepth = 0.02, vdelay = 0.1, vonset = 0, vrateVariation = 0.1, vdepthVariation = 0.1, rq =1;\r\n\tvar sig, env, vibrato;\r\n\tenv = EnvGen.ar(Env.linen(atk, sus, rel, 0.5), doneAction: Done.freeSelf);\r\n\tvibrato = Vibrato.kr(DC.kr(freq), DC.kr(vrate), DC.kr(vdepth), DC.kr(vdelay), DC.kr(vonset), DC.kr(vrateVariation), DC.kr(vdepthVariation));\r\n\tsig = LFPulse.ar(freq, 0, 0.5, 0.2) + LFPulse.ar(freq + vibrato, 0, 0.18);\r\n\tsig = BLowPass4.ar(sig, ((28.midiratio) * (freq)) , rq) ;\r\n\r\n\tsig = sig * env;\r\n\tsig = sig * amp;\r\n\tsig = LeakDC.ar(sig);\r\n\tOut.ar(0, sig!2);\r\n\r\n//By Zé Craum\r\n}).add;\r\n\r\n\r\nSynthDef(\\organ_tonewheel4,{|out= 0 freq = 440 amp = 0.1 gate=1 lforate = 4.85 lfowidth= 0.1 cutoff= 5000 rq=0.25 pan = 0.0|\r\n//Subtractive tonewheel organ from Steal this Sound example\r\n\tvar lfo, pulse, filter, env;\r\n\r\n\tlfo = LFTri.kr(lforate*[1,1.01],Rand(0,2.0)!2);\r\n\r\n\tpulse = Pulse.ar( (((freq*[1,3]).cpsmidi) + (lfo*lfowidth)).midicps,[0.5,0.51],[0.4,0.6]);\r\n\r\n\tenv = EnvGen.ar(Env.adsr(0.0,0.0,1.0,0.1),gate,doneAction:2);\r\n\r\n\tfilter = BLowPass4.ar(pulse,cutoff,rq);\r\n\r\n\tfilter= BPeakEQ.ar(filter,500,1.0,3);\r\n\r\n\tOut.ar(out,Pan2.ar(Mix(filter)*env*amp,pan));\r\n\r\n//By Nick Collins, from Mitchell Sigman (2011) Steal this Sound\r\n//http://www.sussex.ac.uk/Users/nc81/index.html\r\n}).add;\r\n\r\n\r\nSynthDef(\\organ_donor,{|out= 0 freq = 440 amp = 0.2 gate=1 lforate = 10 lfowidth= 0.0 cutoff= 100 rq=0.5 pan=0.0|\r\n\r\n\t//Simulation of transistor organ from Steal This Sound\r\n\tvar vibrato, pulse, filter, env;\r\n\r\n\tvibrato = SinOsc.ar(lforate,Rand(0,2.0));\r\n\r\n\t//up octave, detune by 4 cents\r\n\t//11.96.midiratio = 1.9953843530485\r\n\t//up octave and a half, detune up by 10 cents\r\n\t//19.10.midiratio = 3.0139733629359\r\n\r\n\t//Pulse version\r\n\t//pulse = Mix(Pulse.ar(([1,1.9953843530485,3.0139733629359]*freq)*(1.0+(lfowidth*vibrato)),Rand(0.4,0.6)!3,[1.0,0.7,0.3]))*0.5;\r\n\r\n\t//better alternative\r\n\tpulse = Mix(VarSaw.ar(([1,1.9953843530485,3.0139733629359]*freq)*(1.0+(lfowidth*vibrato)),Rand(0.0,1.0)!3,Rand(0.3,0.5)!3,[1.0,0.7,0.3]))*0.5;\r\n\r\n\tfilter = RLPF.ar(pulse,cutoff,rq);\r\n\r\n\tenv = EnvGen.ar(Env.adsr(0.01,0.5,1.0,0.5),gate,doneAction:2);\r\n\r\n\tOut.ar(out,Pan2.ar(filter*env*amp,pan));\r\n\r\n//By Nick Collins, from Mitchell Sigman (2011) Steal this Sound\r\n//http://www.sussex.ac.uk/Users/nc81/index.html\r\n}).add;\r\n\r\n\r\n\r\nSynthDef(\\organ_reed, {\r\n\t//Reed Organ Simulation\r\n    |out = 0, freq = 440, amp = 0.1, gate = 1, attack = 0.3, release = 0.3|\r\n    var snd, blow;\r\n    // pulse with modulating width\r\n    snd = Pulse.ar((Rand(-0.03, 0.05) + freq.cpsmidi).midicps, 0.48 + LFNoise1.kr(0.06, 0.1), 0.2);\r\n    // add a little \"grit\" to the reed\r\n    snd = Disintegrator.ar(snd, 0.5, 0.7);\r\n    // a little ebb and flow in volume\r\n    snd = snd * LFNoise2.kr(5, 0.05, 1);\r\n    // use the same signal to control both the resonant freq and the amplitude\r\n    blow = EnvGen.ar(Env.asr(attack, 1.0, release), gate, doneAction: 2);\r\n    snd = snd + BPF.ar(snd, blow.linexp(0, 1, 2000, 2442), 0.3, 3);\r\n    // boost the high end a bit to get a buzzier sound\r\n    snd = BHiShelf.ar(snd, 1200, 1, 3);\r\n    snd = snd * blow;\r\n    Out.ar(out, Pan2.ar(snd, 0, amp));\r\n\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-51m\r\n}).add;\r\n\r\n\r\n//  //  //  //  //  //  //  //\r\n////    Woodwinds      ////\r\n//  //  //  //  //  //  //  //\r\n\r\n\r\nSynthDef(\"flute_waveguide\", { arg scl = 0.2, freq = 440, ipress = 0.9, ibreath = 0.09, ifeedbk1 = 0.4, ifeedbk2 = 0.4, dur = 1, gate = 1, amp = 0.4;\r\n\r\n\tvar kenv1, kenv2, kenvibr, kvibr, sr, cr, block;\r\n\tvar poly, signalOut, ifqc;\r\n\tvar aflow1, asum1, asum2, afqc, atemp1, ax, apoly, asum3, avalue, atemp2, aflute1;\r\n\tvar fdbckArray;\r\n\r\n\tsr = SampleRate.ir;\r\n\tcr = ControlRate.ir;\r\n\tblock = cr.reciprocal;\r\n\r\n\tifqc = freq;\r\n\r\n\t// noise envelope\r\n\tkenv1 = EnvGen.kr(Env.new(\r\n\t\t[ 0.0, 1.1 * ipress, ipress, ipress, 0.0 ], [ 0.06, 0.2, dur - 0.46, 0.2 ], 'linear' )\r\n\t);\r\n\t// overall envelope\r\n\tkenv2 = EnvGen.kr(Env.new(\r\n\t\t[ 0.0, amp, amp, 0.0 ], [ 0.1, dur - 0.02, 0.1 ], 'linear' ), doneAction: 2\r\n\t);\r\n\t// vibrato envelope\r\n\tkenvibr = EnvGen.kr(Env.new( [ 0.0, 0.0, 1, 1, 0.0 ], [ 0.5, 0.5, dur - 1.5, 0.5 ], 'linear') );\r\n\r\n\t// create air flow and vibrato\r\n\taflow1 = LFClipNoise.ar( sr, kenv1 );\r\n\tkvibr = SinOsc.ar( 5, 0, 0.1 * kenvibr );\r\n\r\n\tasum1 = ( ibreath * aflow1 ) + kenv1 + kvibr;\r\n\tafqc = ifqc.reciprocal - ( asum1/20000 ) - ( 9/sr ) + ( ifqc/12000000 ) - block;\r\n\r\n\tfdbckArray = LocalIn.ar( 1 );\r\n\r\n\taflute1 = fdbckArray;\r\n\tasum2 = asum1 + ( aflute1 * ifeedbk1 );\r\n\r\n\t//ax = DelayL.ar( asum2, ifqc.reciprocal * 0.5, afqc * 0.5 );\r\n\tax = DelayC.ar( asum2, ifqc.reciprocal - block * 0.5, afqc * 0.5 - ( asum1/ifqc/cr ) + 0.001 );\r\n\r\n\tapoly = ax - ( ax.cubed );\r\n\tasum3 = apoly + ( aflute1 * ifeedbk2 );\r\n\tavalue = LPF.ar( asum3, 2000 );\r\n\r\n\taflute1 = DelayC.ar( avalue, ifqc.reciprocal - block, afqc );\r\n\r\n\tfdbckArray = [ aflute1 ];\r\n\r\n\tLocalOut.ar( fdbckArray );\r\n\r\n\tsignalOut = avalue;\r\n\r\n\tOffsetOut.ar( 0, [ signalOut * kenv2, signalOut * kenv2 ] );\r\n\r\n// Originally found at http://ecmc.rochester.edu/ecmc/docs/supercollider/scbook/Ch21_Interface_Investigations/ixi%20SC%20tutorial/ixi_SC_tutorial_10.html\r\n//by Wilson, Cottle and Collins\r\n//also available at Bruno Ruviaro Collection https://github.com/brunoruviaro/SynthDefs-for-Patterns/blob/master/flute.scd\r\n}).add;\r\n\r\n//  //  //  //  //  //  //  //\r\n////       Strings         ////\r\n//  //  //  //  //  //  //  //\r\n\r\nSynthDef(\\strings, { arg out, freq=440, amp=0.8, gate=1, pan, freqLag=0.2;\r\n\t\t\t\t\tvar env, in, delay, f1, f2;\r\n\t\t\t\t\tf1 = freq.lag(freqLag);\r\n\t\t\t\t\tf2 = freq.lag(freqLag * 0.5);\r\n\t\t\t\t\tdelay = 0.25 / f2;\r\n\t\t\t\t\tenv = Env.asr(0, 1, 0.3);\r\n\t\t\t\t\tin = WhiteNoise.ar(180);\r\n\t\t\t\t\tin = CombL.ar(in, delay, delay, 1);\r\n\t\t\t\t\tin = Resonz.ar(in, f1, 0.001).abs;\r\n\t\t\t\t\tin = in * EnvGen.kr(env, gate, doneAction:2);\r\n\t\t\t\t\tOut.ar(out, Pan2.ar(in, pan, amp));\r\n\r\n//From SC Examples Folder\r\n// some small pieces\r\n// Julian Rohrhuber, 2007\r\n}).add;\r\n\r\n\r\nSynthDef(\\violin, {\r\n\t| midinote=60, gate=1, amp=0.8 |\r\n\tvar env = EnvGen.kr(Env.asr(0.1, 1, 0.1), gate, doneAction:2);\r\n\tvar sig = VarSaw.ar(\r\n\t\tmidinote.midicps,\r\n\t\twidth:LFNoise2.kr(1).range(0.2, 0.8)*SinOsc.kr(5, Rand(0.0, 1.0)).range(0.7,0.8))*0.25;\r\n\tsig = sig * env * amp;\r\n\tOut.ar(0, sig!2);\r\n//It is also used for simulating Farfisa organ and flutes\r\n//by nicolaariutti\r\n//http://sccode.org/1-5as\r\n}).add;\r\n\r\n//  //  //  //  //  //  //  //\r\n////     Percussion       ////\r\n//  //  //  //  //  //  //  //\r\n\r\n\r\nSynthDef(\\kalimba, {\r\n\t//Kalimba based on bank of ressonators\r\n    |out = 0, freq = 440, amp = 0.1, mix = 0.1, relMin = 2.5, relMax = 3.5|\r\n    var snd;\r\n    // Basic tone is a SinOsc\r\n    snd = SinOsc.ar(freq) * EnvGen.ar(Env.perc(0.005, Rand(relMin, relMax), 1, -8), doneAction: 2);\r\n    // The \"clicking\" sounds are modeled with a bank of resonators excited by enveloped pink noise\r\n    snd = (snd * (1 - mix)) + (DynKlank.ar(`[\r\n        // the resonant frequencies are randomized a little to add variation\r\n        // there are two high resonant freqs and one quiet \"bass\" freq to give it some depth\r\n        [240*ExpRand(0.9, 1.1), 2020*ExpRand(0.9, 1.1), 3151*ExpRand(0.9, 1.1)],\r\n        [-7, 0, 3].dbamp,\r\n        [0.8, 0.05, 0.07]\r\n    ], PinkNoise.ar * EnvGen.ar(Env.perc(0.001, 0.01))) * mix);\r\n    Out.ar(out, Pan2.ar(snd, 0, amp));\r\n//By Nathan Ho aka Snappiz\r\n//http://sccode.org/1-51l\r\n}).add;\r\n\r\n\r\nSynthDef(\"marimba1\", {arg freq = 440, amp = 0.4;\r\n\tvar snd, env;\r\n\tenv = Env.linen(0.015, 1, 0.5, amp).kr(doneAction: 2);\r\n\tsnd = BPF.ar(Saw.ar(0), freq, 0.02);\r\n\tsnd = BLowShelf.ar(snd, 220, 0.81, 6);\r\n\tsnd = snd * env;\r\n\tOut.ar(0, Splay.ar(snd));\r\n//By Bruno Ruviaro\r\n//https://github.com/brunoruviaro/SynthDefs-for-Patterns/blob/master/marimba.scd\r\n}).add;\r\n\r\n\r\nSynthDef(\\bell_tubular, {\r\n\t|freq = 440, t60=9, pitchy=1, amp=0.25, gate=1, pan = 0|\r\n\tvar sig, exciter;\r\n\texciter = WhiteNoise.ar() * EnvGen.ar(Env.perc(0.001, 0.05), gate) * 0.25;\r\n\tsig = DynKlank.ar(\r\n\t\t`[\r\n\t\t\t[1, 2, 2.803, 3.871, 5.074, 7.81, 10.948, 14.421],   // freqs\r\n\t\t\t[1, 0.044, 0.891, 0.0891, 0.794, 0.1, 0.281, 0.079], // amplitudes\r\n\t\t\t[1, 0.205, 1, 0.196, 0.339, 0.047, 0.058, 0.047]*t60     // ring times\r\n\t\t],\r\n\t\texciter,\r\n\t\tfreqscale: freq);\r\n\tDetectSilence.ar(sig, 0.001, 0.5, doneAction:2);\r\n\tOut.ar(0, Pan2.ar(sig, pan, amp));\r\n//This is the same used for glockenspiel, xylophone, marimba and regular bell, what changes is only the ring time t60\r\n//By nicolaariutti and edited by Zé Craum\r\n//\thttp://sccode.org/1-5ay#c835\r\n}).add;\r\n\r\nSynthDef(\\glockenspiel, {\r\n\t|freq = 440, t60=6, pitchy=1, amp=0.25, gate=1, pan = 0|\r\n\tvar sig, exciter;\r\n\texciter = WhiteNoise.ar() * EnvGen.ar(Env.perc(0.001, 0.05), gate) * 0.25;\r\n\tsig = DynKlank.ar(\r\n\t\t`[\r\n\t\t\t[1, 2, 2.803, 3.871, 5.074, 7.81, 10.948, 14.421],   // freqs\r\n\t\t\t[1, 0.044, 0.891, 0.0891, 0.794, 0.1, 0.281, 0.079], // amplitudes\r\n\t\t\t[1, 0.205, 1, 0.196, 0.339, 0.047, 0.058, 0.047]*t60     // ring times\r\n\t\t],\r\n\t\texciter,\r\n\t\tfreqscale: freq);\r\n\tDetectSilence.ar(sig, 0.001, 0.5, doneAction:2);\r\n\tOut.ar(0, Pan2.ar(sig, pan, amp));\r\n//This is the same used for glockenspiel, xylophone, marimba and regular bell, what changes is only the ring time t60\r\n//By nicolaariutti and edited by Zé Craum\r\n//\thttp://sccode.org/1-5ay#c835\r\n}).add;\r\n\r\n\r\nSynthDef(\\xilophone, {\r\n\t|freq = 440, t60=1, pitchy=1, amp=0.25, gate=1, pan = 0|\r\n\tvar sig, exciter;\r\n\texciter = WhiteNoise.ar() * EnvGen.ar(Env.perc(0.001, 0.05), gate) * 0.25;\r\n\tsig = DynKlank.ar(\r\n\t\t`[\r\n\t\t\t[1, 2, 2.803, 3.871, 5.074, 7.81, 10.948, 14.421],   // freqs\r\n\t\t\t[1, 0.044, 0.891, 0.0891, 0.794, 0.1, 0.281, 0.079], // amplitudes\r\n\t\t\t[1, 0.205, 1, 0.196, 0.339, 0.047, 0.058, 0.047]*t60     // ring times\r\n\t\t],\r\n\t\texciter,\r\n\t\tfreqscale: freq);\r\n\tDetectSilence.ar(sig, 0.001, 0.5, doneAction:2);\r\n\tOut.ar(0, Pan2.ar(sig, pan, amp));\r\n//This is the same used for glockenspiel, xylophone, marimba and regular bell, what changes is only the ring time t60\r\n//By nicolaariutti and edited by Zé Craum\r\n//\thttp://sccode.org/1-5ay#c835\r\n}).add;\r\n\r\n\r\nSynthDef(\\marimba, {\r\n\t|freq = 440, t60=0.5, pitchy=1, amp=0.25, gate=1, pan = 0|\r\n\tvar sig, exciter;\r\n\texciter = WhiteNoise.ar() * EnvGen.ar(Env.perc(0.001, 0.05), gate) * 0.25;\r\n\tsig = DynKlank.ar(\r\n\t\t`[\r\n\t\t\t[1, 2, 2.803, 3.871, 5.074, 7.81, 10.948, 14.421],   // freqs\r\n\t\t\t[1, 0.044, 0.891, 0.0891, 0.794, 0.1, 0.281, 0.079], // amplitudes\r\n\t\t\t[1, 0.205, 1, 0.196, 0.339, 0.047, 0.058, 0.047]*t60     // ring times\r\n\t\t],\r\n\t\texciter,\r\n\t\tfreqscale: freq);\r\n\tDetectSilence.ar(sig, 0.001, 0.5, doneAction:2);\r\n\tOut.ar(0, Pan2.ar(sig, pan, amp));\r\n//This is the same used for glockenspiel, xylophone, marimba and regular bell, what changes is only the ring time t60\r\n//By nicolaariutti and edited by Zé Craum\r\n//\thttp://sccode.org/1-5ay#c835\r\n}).add;\r\n\r\nSynthDef(\\prayer_bell, { |outbus, t_trig = 1, sing_switch = 0, freq = 2434, amp = 0.5, decayscale = 1, lag = 10, i_doneAction = 0|\r\n  var sig, input, first, freqscale, mallet, sing;\r\n  freqscale = freq / 2434;\r\n  freqscale = Lag3.kr(freqscale, lag);\r\n  decayscale = Lag3.kr(decayscale, lag);\r\n\r\n  mallet = LPF.ar(Trig.ar(t_trig, SampleDur.ir)!2, 10000 * freqscale);\r\n  sing = LPF.ar(\r\n    LPF.ar(\r\n      {\r\n        PinkNoise.ar * Integrator.kr(sing_switch * 0.001, 0.999).linexp(0, 1, 0.01, 1) * amp\r\n      } ! 2,\r\n      2434 * freqscale\r\n    ) + Dust.ar(0.1), 10000 * freqscale\r\n  ) * LFNoise1.kr(0.5).range(-45, -30).dbamp;\r\n  input = mallet + (sing_switch.clip(0, 1) * sing);\r\n\r\n\r\n  sig = DynKlank.ar(`[\r\n    [\r\n      (first = LFNoise1.kr(0.5).range(2424, 2444)) + Line.kr(20, 0, 0.5),\r\n      first + LFNoise1.kr(0.5).range(1,3),\r\n      LFNoise1.kr(1.5).range(5435, 5440) - Line.kr(35, 0, 1),\r\n      LFNoise1.kr(1.5).range(5480, 5485) - Line.kr(10, 0, 0.5),\r\n      LFNoise1.kr(2).range(8435, 8445) + Line.kr(15, 0, 0.05),\r\n      LFNoise1.kr(2).range(8665, 8670),\r\n      LFNoise1.kr(2).range(8704, 8709),\r\n      LFNoise1.kr(2).range(8807, 8817),\r\n      LFNoise1.kr(2).range(9570, 9607),\r\n      LFNoise1.kr(2).range(10567, 10572) - Line.kr(20, 0, 0.05),\r\n      LFNoise1.kr(2).range(10627, 10636) + Line.kr(35, 0, 0.05),\r\n      LFNoise1.kr(2).range(14689, 14697) - Line.kr(10, 0, 0.05)\r\n    ],\r\n    [\r\n      LFNoise1.kr(1).range(-10, -5).dbamp,\r\n      LFNoise1.kr(1).range(-20, -10).dbamp,\r\n      LFNoise1.kr(1).range(-12, -6).dbamp,\r\n      LFNoise1.kr(1).range(-12, -6).dbamp,\r\n      -20.dbamp,\r\n      -20.dbamp,\r\n      -20.dbamp,\r\n      -25.dbamp,\r\n      -10.dbamp,\r\n      -20.dbamp,\r\n      -20.dbamp,\r\n      -25.dbamp\r\n    ],\r\n    [\r\n      20 * freqscale.pow(0.2),\r\n      20 * freqscale.pow(0.2),\r\n      5,\r\n      5,\r\n      0.6,\r\n      0.5,\r\n      0.3,\r\n      0.25,\r\n      0.4,\r\n      0.5,\r\n      0.4,\r\n      0.6\r\n    ] * freqscale.reciprocal.pow(0.5)\r\n  ], input, freqscale, 0, decayscale);\r\n  DetectSilence.ar(sig, doneAction: i_doneAction);\r\n  Out.ar(outbus, sig);\r\n\r\n// Tibetan prayer bells acoustically modeled\r\n//by wondersluyter\r\n//http://sccode.org/wondersluyter\r\n}).add;\r\n\r\n\r\n\r\n\r\n//  //  //  //  //  //  //  //\r\n////      Drum Kits      ////\r\n//  //  //  //  //  //  //  //\r\n\r\n\r\n\r\n\r\nSynthDef(\\snare909,{ |out=0,mul=1,velocity=1|\r\n\tvar excitation, membrane;\r\n\r\n\texcitation = LPF.ar(WhiteNoise.ar(1), 7040, 1) * (0.1 + velocity);\r\n\tmembrane = (\r\n\t\t/* Two simple enveloped oscillators represent the loudest resonances of the drum membranes */\r\n\t\t(LFTri.ar(330,0,1) * EnvGen.ar(Env.perc(0.0005,0.055),doneAction:0) * 0.25)\r\n\t\t+(LFTri.ar(185,0,1) * EnvGen.ar(Env.perc(0.0005,0.075),doneAction:0) * 0.25)\r\n\r\n\t\t/* Filtered white noise represents the snare */\r\n\t\t+(excitation * EnvGen.ar(Env.perc(0.0005,0.4),doneAction:2) * 0.2)\r\n\t\t+(HPF.ar(excitation, 523, 1) * EnvGen.ar(Env.perc(0.0005,0.283),doneAction:0) * 0.2)\r\n\r\n\t) * mul;\r\n\tOut.ar(out, membrane!2)\r\n}).add;\r\n\r\n\r\nSynthDef(\\neurosnare, {\r\n    var snd;\r\n    // a percussive click to give it some attack\r\n    snd = LPF.ar(HPF.ar(WhiteNoise.ar, 300), 8000) * Env.linen(0.001, 0.01, 0.001).ar;\r\n    // sine sweep body. very important!\r\n    snd = snd + (SinOsc.ar(Env([400, 196, 160], [0.04, 0.2], \\exp).ar) * Env.perc(0.04, 0.2).ar * 6.dbamp).tanh;\r\n    // sound of snare coils rattling\r\n    snd = snd + (HPF.ar(BPeakEQ.ar(WhiteNoise.ar, 4000, 0.5, 3), 300) * Env.perc(0.05, 0.2).delay(0.01).ar(2) * -3.dbamp);\r\n    // another sound sweep to improve the attack, optional\r\n    snd = snd + (SinOsc.ar(XLine.kr(3000, 1500, 0.01)) * Env.perc(0.001, 0.02).ar);\r\n    // distortion helps glue everything together and acts as a compressor\r\n    snd = (snd * 1.4).tanh;\r\n    snd = Pan2.ar(snd, \\pan.kr(0), \\amp.kr(0.1));\r\n    Out.ar(\\out.kr(0), snd);\r\n\r\n//By Snapizz\r\n//http://sccode.org/1-57f\r\n\r\n}).add;\r\n\r\n\r\n// Basic drum kit\r\n\r\nSynthDef(\"hihat\", {arg out = 0, amp = 0.5, att = 0.01, rel = 0.2, ffreq = 6000, pan = 0;\r\n\tvar env, snd;\r\n\tenv = Env.perc(att, rel, amp).kr(doneAction: 2);\r\n\tsnd = WhiteNoise.ar;\r\n\tsnd = HPF.ar(in: snd, freq: ffreq, mul: env);\r\n\tOut.ar(out, Pan2.ar(snd, pan));\r\n\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-523\r\n}).add;\r\n\r\nSynthDef(\"snare\", {arg out = 0, amp = 0.1, sinfreq = 180, att = 0.01, rel = 0.2, ffreq = 2000, pan = 0;\r\n\tvar env, snd1, snd2, sum;\r\n\tenv = Env.perc(att, rel, amp).kr(doneAction: 2);\r\n\tsnd1 = HPF.ar(\r\n\t\tin: WhiteNoise.ar,\r\n\t\tfreq: ffreq,\r\n\t\tmul: env\r\n\t);\r\n\tsnd2 = SinOsc.ar(freq: sinfreq, mul: env);\r\n\tsum = snd1 + snd2;\r\n\tOut.ar(out, Pan2.ar(sum, pan));\r\n\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-523\r\n}).add;\r\n\r\nSynthDef(\"kick\", {arg out = 0, amp = 0.3, sinfreq = 60, glissf = 0.9, att = 0.01, rel = 0.45, pan = 0;\r\n\tvar env, snd, ramp;\r\n\tenv = Env.perc(att, rel, amp).kr(doneAction: 2);\r\n\tramp = XLine.kr(\r\n\t\tstart: sinfreq,\r\n\t\tend: sinfreq * glissf,\r\n\t\tdur: rel\r\n\t);\r\n\tsnd = SinOsc.ar(freq: ramp, mul: env);\r\n\tsnd = Pan2.ar(snd, pan);\r\n\tOut.ar(out, snd);\r\n\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-523\r\n}).add;\r\n\r\n\r\n\r\nSynthDef(\\kick1, {\r\n    var snd;\r\n    snd = DC.ar(0);\r\n    snd = snd + (SinOsc.ar(XLine.ar(800, 400, 0.01)) * Env.perc(0.0005, 0.01).ar);\r\n    snd = snd + (BPF.ar(Hasher.ar(Sweep.ar), XLine.ar(800, 100, 0.01), 0.6) * Env.perc(0.001, 0.02).delay(0.001).ar);\r\n    snd = snd + (SinOsc.ar(XLine.ar(172, 50, 0.01)) * Env.perc(0.0001, 0.3, 1, \\lin).delay(0.005).ar(2));\r\n    snd = snd.tanh;\r\n    Out.ar(\\out.kr(0), Pan2.ar(snd, \\pan.kr(0), \\amp.kr(0.1)));\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-57g\r\n}).add;\r\n\r\n\r\n\r\n\r\n\r\nSynthDef(\\kick2, {\r\n    var snd;\r\n    snd = DC.ar(0);\r\n    snd = snd + (HPF.ar(Hasher.ar(Sweep.ar), 1320) * Env.perc(0.003, 0.03).ar * 0.5);\r\n    snd = snd + (SinOsc.ar(XLine.ar(750, 161, 0.02)) * Env.perc(0.0005, 0.02).ar);\r\n    snd = snd + (SinOsc.ar(XLine.ar(167, 52, 0.04)) * Env.perc(0.0005, 0.3).ar(2));\r\n    snd = snd.tanh;\r\n    Out.ar(\\out.kr(0), Pan2.ar(snd, \\pan.kr(0), \\amp.kr(0.1)));\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-57g\r\n}).add;\r\n\r\n\r\n\r\n\r\n\r\nSynthDef(\\kick3, {\r\n    var snd;\r\n    snd = DC.ar(0);\r\n    snd = snd + (SinOsc.ar(XLine.ar(1500, 800, 0.01)) * Env.perc(0.0005, 0.01, curve: \\lin).ar);\r\n    snd = snd + (BPF.ar(Impulse.ar(0) * SampleRate.ir / 48000, 6100, 1.0) * 3.dbamp);\r\n    snd = snd + (BPF.ar(Hasher.ar(Sweep.ar), 300, 0.9) * Env.perc(0.001, 0.02).ar);\r\n    snd = snd + (SinOsc.ar(XLine.ar(472, 60, 0.045)) * Env.perc(0.0001, 0.3, curve: \\lin).delay(0.005).ar(2));\r\n    snd = snd.tanh;\r\n    Out.ar(\\out.kr(0), Pan2.ar(snd, \\pan.kr(0), \\amp.kr(0.1)));\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-57g\r\n}).add;\r\n\r\n\r\nSynthDef(\"kick_808\", {arg out = 0, freq1 = 240, freq2 = 60, amp = 1, ringTime = 10, rel = 1, dist = 0.5, pan = 0;\r\n    var snd, env;\r\n\tsnd = Ringz.ar(\r\n\t\tin: Impulse.ar(0), // single impulse\r\n\t\tfreq: XLine.ar(freq1, freq2, 0.1),\r\n\t\tdecaytime: ringTime);\r\n\tenv = EnvGen.ar(Env.perc(0.001, rel, amp), doneAction: 2);\r\n\tsnd = (1.0 - dist) * snd + (dist * (snd.distort));\r\n\tsnd = snd * env;\r\n\tOut.ar(0, Pan2.ar(snd, pan));\r\n//\r\n//By Bruno Ruviaro\r\n//https://github.com/brunoruviaro/SynthDefs-for-Patterns/blob/master/kick808.scd\r\n}).add;\r\n\r\n\r\nSynthDef(\\SOSkick,\r\n\t{ arg out = 0, freq = 50, mod_freq = 5, mod_index = 5, sustain = 0.4, amp = 0.8, beater_noise_level = 0.025;\r\n\tvar pitch_contour, drum_osc, drum_lpf, drum_env;\r\n\tvar beater_source, beater_hpf, beater_lpf, lpf_cutoff_contour, beater_env;\r\n\tvar kick_mix;\r\n\tpitch_contour = Line.kr(freq*2, freq, 0.02);\r\n\tdrum_osc = PMOsc.ar(\tpitch_contour,\r\n\t\t\t\tmod_freq,\r\n\t\t\t\tmod_index/1.3,\r\n\t\t\t\tmul: 1,\r\n\t\t\t\tadd: 0);\r\n\tdrum_lpf = LPF.ar(in: drum_osc, freq: 1000, mul: 1, add: 0);\r\n\tdrum_env = drum_lpf * EnvGen.ar(Env.perc(0.005, sustain), 1.0, doneAction: 2);\r\n\tbeater_source = WhiteNoise.ar(beater_noise_level);\r\n\tbeater_hpf = HPF.ar(in: beater_source, freq: 500, mul: 1, add: 0);\r\n\tlpf_cutoff_contour = Line.kr(6000, 500, 0.03);\r\n\tbeater_lpf = LPF.ar(in: beater_hpf, freq: lpf_cutoff_contour, mul: 1, add: 0);\r\n\tbeater_env = beater_lpf * EnvGen.ar(Env.perc, 1.0, doneAction: 2);\r\n\tkick_mix = Mix.new([drum_env, beater_env]) * 2 * amp;\r\n\tOut.ar(out, [kick_mix, kick_mix])\r\n\t}\r\n\r\n//DrumSynths SC Example - SOS Drums by Renick Bell, renick_at_gmail.com\r\n// recipes from Gordon Reid in his Sound on Sound articles\r\n// SOSkick -------\r\n// http://www.soundonsound.com/sos/jan02/articles/synthsecrets0102.asp\r\n// increase mod_freq and mod_index for interesting electronic percussion\r\n\t).add;\r\n\r\n\r\nSynthDef(\\SOSsnare,\r\n\t{arg out = 0, sustain = 0.1, drum_mode_level = 0.25,\r\n\tsnare_level = 40, snare_tightness = 1000,\r\n\tfreq = 405, amp = 0.8;\r\n\tvar drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc, drum_mode_mix, drum_mode_env;\r\n\tvar snare_noise, snare_brf_1, snare_brf_2, snare_brf_3, snare_brf_4, snare_reson;\r\n\tvar snare_env;\r\n\tvar snare_drum_mix;\r\n\r\n\tdrum_mode_env = EnvGen.ar(Env.perc(0.005, sustain), 1.0, doneAction: 2);\r\n\tdrum_mode_sin_1 = SinOsc.ar(freq*0.53, 0, drum_mode_env * 0.5);\r\n\tdrum_mode_sin_2 = SinOsc.ar(freq, 0, drum_mode_env * 0.5);\r\n\tdrum_mode_pmosc = PMOsc.ar(\tSaw.ar(freq*0.85),\r\n\t\t\t\t\t184,\r\n\t\t\t\t\t0.5/1.3,\r\n\t\t\t\t\tmul: drum_mode_env*5,\r\n\t\t\t\t\tadd: 0);\r\n\tdrum_mode_mix = Mix.new([drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc]) * drum_mode_level;\r\n\r\n// choose either noise source below\r\n//\tsnare_noise = Crackle.ar(2.01, 1);\r\n\tsnare_noise = LFNoise0.ar(20000, 0.1);\r\n\tsnare_env = EnvGen.ar(Env.perc(0.005, sustain), 1.0, doneAction: 2);\r\n\tsnare_brf_1 = BRF.ar(in: snare_noise, freq: 8000, mul: 0.5, rq: 0.1);\r\n\tsnare_brf_2 = BRF.ar(in: snare_brf_1, freq: 5000, mul: 0.5, rq: 0.1);\r\n\tsnare_brf_3 = BRF.ar(in: snare_brf_2, freq: 3600, mul: 0.5, rq: 0.1);\r\n\tsnare_brf_4 = BRF.ar(in: snare_brf_3, freq: 2000, mul: snare_env, rq: 0.0001);\r\n\tsnare_reson = Resonz.ar(snare_brf_4, snare_tightness, mul: snare_level) ;\r\n\tsnare_drum_mix = Mix.new([drum_mode_mix, snare_reson]) * 5 * amp;\r\n\tOut.ar(out, [snare_drum_mix, snare_drum_mix])\r\n\t}\r\n).add;\r\n//DrumSynths SC Example - SOS Drums by Renick Bell, renick_at_gmail.com\r\n// recipes from Gordon Reid in his Sound on Sound articles\r\n// SOSsnare -------\r\n// http://www.soundonsound.com/sos/Mar02/articles/synthsecrets0302.asp\r\n\r\n\r\nSynthDef(\\SOShats,\r\n\t{arg out = 0, freq = 6000, sustain = 0.1, amp = 0.8;\r\n\tvar root_cymbal, root_cymbal_square, root_cymbal_pmosc;\r\n\tvar initial_bpf_contour, initial_bpf, initial_env;\r\n\tvar body_hpf, body_env;\r\n\tvar cymbal_mix;\r\n\r\n\troot_cymbal_square = Pulse.ar(freq, 0.5, mul: 1);\r\n\troot_cymbal_pmosc = PMOsc.ar(root_cymbal_square,\r\n\t\t\t\t\t[freq*1.34, freq*2.405, freq*3.09, freq*1.309],\r\n\t\t\t\t\t[310/1.3, 26/0.5, 11/3.4, 0.72772],\r\n\t\t\t\t\tmul: 1,\r\n\t\t\t\t\tadd: 0);\r\n\troot_cymbal = Mix.new(root_cymbal_pmosc);\r\n\tinitial_bpf_contour = Line.kr(15000, 9000, 0.1);\r\n\tinitial_env = EnvGen.ar(Env.perc(0.005, 0.1), 1.0);\r\n\tinitial_bpf = BPF.ar(root_cymbal, initial_bpf_contour, mul:initial_env);\r\n\tbody_env = EnvGen.ar(Env.perc(0.005, sustain, 1, -2), 1.0, doneAction: 2);\r\n\tbody_hpf = HPF.ar(in: root_cymbal, freq: Line.kr(9000, 12000, sustain),mul: body_env, add: 0);\r\n\tcymbal_mix = Mix.new([initial_bpf, body_hpf]) * amp;\r\n\tOut.ar(out, [cymbal_mix, cymbal_mix])\r\n\t}).add;\r\n//DrumSynths SC Example - SOS Drums by Renick Bell, renick_at_gmail.com\r\n// recipes from Gordon Reid in his Sound on Sound articles\r\n// SOShats -------\r\n// http://www.soundonsound.com/sos/Jun02/articles/synthsecrets0602.asp\r\n\r\nSynthDef(\\SOStom,\r\n\t{arg out = 0, sustain = 0.4, drum_mode_level = 0.25,\r\n\tfreq = 90, drum_timbre = 1.0, amp = 0.8;\r\n\tvar drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc, drum_mode_mix, drum_mode_env;\r\n\tvar stick_noise, stick_env;\r\n\tvar drum_reson, tom_mix;\r\n\r\n\tdrum_mode_env = EnvGen.ar(Env.perc(0.005, sustain), 1.0, doneAction: 2);\r\n\tdrum_mode_sin_1 = SinOsc.ar(freq*0.8, 0, drum_mode_env * 0.5);\r\n\tdrum_mode_sin_2 = SinOsc.ar(freq, 0, drum_mode_env * 0.5);\r\n\tdrum_mode_pmosc = PMOsc.ar(\tSaw.ar(freq*0.9),\r\n\t\t\t\t\t\t\t\tfreq*0.85,\r\n\t\t\t\t\t\t\t\tdrum_timbre/1.3,\r\n\t\t\t\t\t\t\t\tmul: drum_mode_env*5,\r\n\t\t\t\t\t\t\t\tadd: 0);\r\n\tdrum_mode_mix = Mix.new([drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc]) * drum_mode_level;\r\n\tstick_noise = Crackle.ar(2.01, 1);\r\n\tstick_env = EnvGen.ar(Env.perc(0.005, 0.01), 1.0) * 3;\r\n\ttom_mix = Mix.new([drum_mode_mix, stick_env]) * 2 * amp;\r\n\tOut.ar(out, [tom_mix, tom_mix])\r\n\t}\r\n).add;\r\n//DrumSynths SC Example - SOS Drums by Renick Bell, renick_at_gmail.com\r\n// recipes from Gordon Reid in his Sound on Sound articles\r\n// SOStom -------\r\n// http://www.soundonsound.com/sos/Mar02/articles/synthsecrets0302.asp\r\n\r\n\r\n\r\nSynthDef(\\kick_electro, {\r\n    |out = 0, pan = 0, amp = 0.3|\r\n    var body, bodyFreq, bodyAmp;\r\n    var pop, popFreq, popAmp;\r\n    var click, clickAmp;\r\n    var snd;\r\n\r\n    // body starts midrange, quickly drops down to low freqs, and trails off\r\n    bodyFreq = EnvGen.ar(Env([261, 120, 51], [0.035, 0.08], curve: \\exp));\r\n    bodyAmp = EnvGen.ar(Env.linen(0.005, 0.1, 0.3), doneAction: 2);\r\n    body = SinOsc.ar(bodyFreq) * bodyAmp;\r\n    // pop sweeps over the midrange\r\n    popFreq = XLine.kr(750, 261, 0.02);\r\n    popAmp = EnvGen.ar(Env.linen(0.001, 0.02, 0.001)) * 0.15;\r\n    pop = SinOsc.ar(popFreq) * popAmp;\r\n    // click is spectrally rich, covering the high-freq range\r\n    // you can use Formant, FM, noise, whatever\r\n    clickAmp = EnvGen.ar(Env.perc(0.001, 0.01)) * 0.15;\r\n    click = LPF.ar(Formant.ar(910, 4760, 2110), 3140) * clickAmp;\r\n\r\n    snd = body + pop + click;\r\n    snd = snd.tanh;\r\n\r\n    Out.ar(out, Pan2.ar(snd, pan, amp));\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-523\r\n}).add;\r\n\r\nSynthDef(\\snare_electro, {\r\n    |out = 0, pan = 0, amp = 0.3|\r\n    var pop, popAmp, popFreq;\r\n    var noise, noiseAmp;\r\n    var snd;\r\n\r\n    // pop makes a click coming from very high frequencies\r\n    // slowing down a little and stopping in mid-to-low\r\n    popFreq = EnvGen.ar(Env([3261, 410, 160], [0.005, 0.01], curve: \\exp));\r\n    popAmp = EnvGen.ar(Env.perc(0.001, 0.11)) * 0.7;\r\n    pop = SinOsc.ar(popFreq) * popAmp;\r\n    // bandpass-filtered white noise\r\n    noiseAmp = EnvGen.ar(Env.perc(0.001, 0.15), doneAction: 2);\r\n    noise = BPF.ar(WhiteNoise.ar, 810, 1.6) * noiseAmp;\r\n\r\n    snd = (pop + noise) * 1.3;\r\n\r\n    Out.ar(out, Pan2.ar(snd, pan, amp));\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-523\r\n}).add;\r\n\r\nSynthDef(\\hihat_electro, {\r\n    |out = 0, pan = 0, amp = 0.3|\r\n    var click, clickAmp;\r\n    var noise, noiseAmp;\r\n    var snd;\r\n\r\n    // noise -> resonance -> expodec envelope\r\n    noiseAmp = EnvGen.ar(Env.perc(0.001, 0.3, curve: -8), doneAction: 2);\r\n    noise = Mix(BPF.ar(ClipNoise.ar, [4010, 4151], [0.15, 0.56], [1.0, 0.6])) * 0.7 * noiseAmp;\r\n\r\n    snd = noise;\r\n\r\n    Out.ar(out, Pan2.ar(snd, pan, amp));\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-523\r\n}).add;\r\n\r\n// adapted from a post by Neil Cosgrove (other three are original)\r\nSynthDef(\\clap_electro, {\r\n    |out = 0, amp = 0.5, pan = 0, dur = 1|\r\n    var env1, env2, snd, noise1, noise2;\r\n\r\n    // noise 1 - 4 short repeats\r\n    env1 = EnvGen.ar(\r\n        Env.new(\r\n            [0, 1, 0, 0.9, 0, 0.7, 0, 0.5, 0],\r\n            [0.001, 0.009, 0, 0.008, 0, 0.01, 0, 0.03],\r\n            [0, -3, 0, -3, 0, -3, 0, -4]\r\n        )\r\n    );\r\n\r\n    noise1 = WhiteNoise.ar(env1);\r\n    noise1 = HPF.ar(noise1, 600);\r\n    noise1 = LPF.ar(noise1, XLine.kr(7200, 4000, 0.03));\r\n    noise1 = BPF.ar(noise1, 1620, 3);\r\n\r\n    // noise 2 - 1 longer single\r\n    env2 = EnvGen.ar(Env.new([0, 1, 0], [0.02, 0.18], [0, -4]), doneAction:2);\r\n\r\n    noise2 = WhiteNoise.ar(env2);\r\n    noise2 = HPF.ar(noise2, 1000);\r\n    noise2 = LPF.ar(noise2, 7600);\r\n    noise2 = BPF.ar(noise2, 1230, 0.7, 0.7);\r\n\r\n    snd = noise1 + noise2;\r\n    snd = snd * 2;\r\n    snd = snd.softclip;\r\n\r\n    Out.ar(out, Pan2.ar(snd,pan,amp));\r\n//By Nathan Ho aka Snappizz\r\n//http://sccode.org/1-523\r\n}).add;\r\n\r\n\r\n\r\n//  //  //  //  //  //  //  //\r\n////       Others         ////\r\n//  //  //  //  //  //  //  //\r\n\r\n\r\nSynthDef(\\blips1, {arg out = 0, freq = 25, numharm = 10, atk = 0.01, rel = 1, amp = 0.1, pan = 0.5, beatsPercentage = 1.001;\r\n\tvar snd, env;\r\n\tenv = Env.perc(atk, rel, amp).kr(doneAction: Done.freeSelf);\r\n\tsnd = LeakDC.ar(Mix(Blip.ar([freq, freq*beatsPercentage], numharm, env)));\r\n\tOut.ar(out, Pan2.ar(snd, pan));\r\n\r\n//80's like synth\r\n//By Bruno Ruviaro\r\n//https://github.com/brunoruviaro/SynthDefs-for-Patterns/blob/master/blips.scd\r\n//Edits by Zé Craum\r\n}).add;\r\n\r\n\r\n\r\nSynthDef(\"sawSynth\", { arg freq = 440, amp = 0.1, att = 0.1, rel = 2, lofreq = 1000, hifreq = 3000;\r\n    var env, snd;\r\n    env = Env.perc(\r\n\t\tattackTime: att,\r\n\t\treleaseTime: rel,\r\n\t\tlevel: amp\r\n\t).kr(doneAction: 2);\r\n    snd = Saw.ar(freq: freq * [0.99, 1, 1.001, 1.008], mul: env);\r\n\tsnd = LPF.ar(\r\n\t\tin: snd,\r\n\t\tfreq: LFNoise2.kr(1).range(lofreq, hifreq)\r\n\t);\r\n    snd = Splay.ar(snd);\r\n    Out.ar(0, snd);\r\n// Basic saw synth for chords and bass\r\n//By Bruno Ruviaro\r\n//http://sccode.org/1-54H\r\n}).add;\r\n\r\n\r\nSynthDef(\"noisy\", {arg out = 0, freq = 440, amp = 0.2, pan = 0.5;\r\n\tvar snd, env;\r\n\tenv = Env.perc(0.02, 0.1).kr(doneAction: 2);\r\n\tsnd = Mix(LFPulse.ar(\r\n\t\tfreq: freq * [1, 5/2],\r\n\t\tiphase: 0.0,\r\n\t\twidth: 0.5,\r\n\t\tmul: amp));\r\n\tsnd = snd * env ;\r\n\tOut.ar(out, Pan2.ar(snd, pan));\r\n//By Bruno Ruviaro\r\n//https://github.com/brunoruviaro/SynthDefs-for-Patterns/blob/master/noisy.scd\r\n}).add;\r\n\r\n\r\n//INCLUDE A SAMPLER\r\n\r\nSynthDef(\\sampler_PlayBuf, {\r\n//A really simple sampler\tbased on PlayBuf and midi ratios\r\n\t|out=0, pan=0, buf=0, midiratio=2, amp=1.0, pos=0.0, atk= 0.001, sus = 0.01 rel=1.0|\r\n\tvar sig, rate, start, env;\r\n\tenv = EnvGen.ar(Env.linen(atk, sus, rel), doneAction:2);\r\n\trate = BufRateScale.ir(buf) * (midiratio.midiratio);\r\n\tstart = BufFrames.kr(buf) * pos;\r\n\tsig = PlayBuf.ar(1, buf, rate, 1, start);\r\n\tOut.ar(out, Pan2.ar(sig, pan, amp) * env);\r\n//By Zé Craum\r\n}).add;\r\n\r\nSynthDef(\\sine_simple, {\r\n//A really simple sinusoidal sine wave synth\r\n\t|amp=0.1, freq=440, pan=0, atk = 0.001, sus = 1, rel = 0.01|\r\n\tvar env, sig;\r\n\tenv = EnvGen.kr(Env.linen(atk, sus, rel), doneAction:2);\r\n\tsig = SinOsc.ar(freq);\r\n\tsig = sig * env;\r\n\tOut.ar(0, Pan2.ar(sig, pan, amp));\r\n//By Zé Craum\r\n}).add;\r\n\r\nSynthDef(\\sine_vintage, {\r\n//Crude simulation of old sinusoidal generators - with vibrato and high noise floor\r\n\t|amp=0.2, freq=440, pan=0, atk = 0.001, sus = 2, rel = 0.01,\r\n\tvrate = 2, vdepth = 0.002, vdelay = 0.1, vonset = 0, vrateVariation = 0.1, vdepthVariation = 0.1 /*vibrato arguments*/,\r\n\tnoiseAmp = 0.2|\r\n\tvar env, sig, vibrato;\r\n\tenv = EnvGen.kr(Env.linen(atk, sus, rel), doneAction:2);\r\n\tvibrato = Vibrato.kr(DC.kr(freq), DC.kr(vrate), DC.kr(vdepth), DC.kr(vdelay), DC.kr(vonset), DC.kr(vrateVariation), DC.kr(vdepthVariation));\r\n\tsig = SinOsc.ar(vibrato);\r\n\tsig = sig + PinkNoise.ar(noiseAmp);\r\n\tsig = sig * env;\r\n\tOut.ar(0, Pan2.ar(sig, pan, amp));\r\n//By Zé Craum\r\n}).add;\r\n\r\nSynthDef(\\prophet5pwmstrings,{|out= 0 freq = 440 amp = 1.0 gate=1 lforate = 10 lfowidth= 0.5 cutoff= 12000 rq=0.5 pan = 0.0|\r\n\r\n\tvar lfo, pulse, filter, env;\r\n\r\n\tlfo = LFTri.kr(lforate*[1,1.01],Rand(0,2.0)!2);\r\n\r\n\tpulse = Pulse.ar(freq*[1,1.01],lfo*lfowidth+0.5);\r\n\r\n\tfilter = RLPF.ar(pulse,cutoff,rq);\r\n\r\n\tenv = EnvGen.ar(Env.adsr(0.01,0.0,1.0,0.5),gate,doneAction:2);\r\n\r\n\tOut.ar(out,Pan2.ar(Mix(filter)*env*amp*0.5,pan));\r\n\r\n}).add;\r\n\r\n\r\n\r\n\r\n\r\n//  //  //  //  //  //  //  //\r\n////       Effects         ////\r\n//  //  //  //  //  //  //  //\r\n\r\n\r\n//Steal This Sound\r\nSynthDef(\\choruscompresseffect, {|out =0 gate= 1|\r\n\tvar source = In.ar(out,2);\r\n\tvar chorus;\r\n\tvar env = Linen.kr(gate, 0.1, 1, 0.1, 2);\r\n\r\n\tchorus= Splay.ar(Array.fill(4,{\r\n\t\tvar maxdelaytime= rrand(0.005,0.02);\r\n\r\n\t\tDelayC.ar(source[0], maxdelaytime,LFNoise1.kr(Rand(0.1,0.6),0.25*maxdelaytime,0.75*maxdelaytime) )\r\n\t}));\r\n\r\n\tchorus = Compander.ar(4*(source + chorus),source,0.4,1,4);\r\n\r\n\tXOut.ar(out,env,chorus);\r\n\r\n//From Steal This Sound SC Example\r\n//By Nick Collins\r\n}).add;\r\n\r\nSynthDef(\\reverb, {\r\n\targ out = 0, gate = 1, roomsize = 100, revtime = 1, damping = 0.6, inputbw = 0.5, spread = 15, drylevel = 1, earlyreflevel = 0.7, taillevel = 0.5, maxroomsize = 300, amp = 0.5;\r\n\tvar source = In.ar(out,8);\r\n\tvar reverb;\r\n\tvar env = Linen.kr(gate, 0.1, 1, 0.1, 2);\r\n\r\n\r\n\treverb = GVerb.ar(source, roomsize, revtime, damping, inputbw, spread, drylevel, earlyreflevel, taillevel, maxroomsize);\r\n\treverb = reverb * amp ;\r\n\tXOut.ar(out,env,reverb);\r\n//By Zé Craum\r\n\r\n}).add;\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n)",
   "author" : "unknown",
   "name" : "SynthDEFaults",
   "ancestor_list" : [],
   "description" : "SynthDEFaults\r\n- A Collection of Tradicional SynthDefs-\r\n//under GNU GPL 3 as per SuperCollider license\r\n//Organized by Zé Craum\r\n\r\n//This is the first scratch, ASAP it will be avaible in a more organized form.\r\n\r\n//Some Guidelines from uploading contributiong or helping organizing existing stuff:\r\n1.Executing code should return a SynthDef;\r\n2.The SynthDEFaults should have ControlSpecs for every parameter to define an acceptable range;\r\n3.The SynthDEFaults should not depend on things outside of the core lib or sc3-plugins;\r\n4.The SynthDEFaults should have reasonable defaults that allow it to make a representative sound with no arguments;\r\n5. SynthDEFaults symbol should be always be like \\Piano_BabyGrandPiano; \\Guitar_FDBEletric...\r\n6. SynthDEFaults must be written using NamedControl Style (Still being updated);\r\n6.1. Additional arguments besides from amp/dur/pitch default events must be written as local variables and must have comments;\r\n7. All the SynthDef should be designed for working with the main scope of Patterns\r\n\r\nExamples at: \r\n\r\nContribuitions, comments, advises, criticisms, etc are very welcome: zecraum at gmail com"
}
