SHARE
TWEET

doubleshotsource02062019

softpretzthebest Feb 6th, 2019 (edited) 140 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Thank you for finding my code for 'doubleshot'. Please note: the following code is unedited and published purely as I left it when I decided the piece was finished. This was my first attempt at coding for performance, so please excuse its clutter and disorganization.
  2.  
  3. -BT Feb. 6, 2019
  4. */
  5.  
  6. /*
  7. //////Thank you to Eli Fieldsteel.////
  8. //////See his pieces and instruction at http://www.elifieldsteel.com/////////
  9. //////Thanks to Patrick McMinn for his stereo delay design that I borrowed and butchered. www.patrickmcminn.com
  10. */
  11.  
  12.  
  13.  
  14. //Composition 1 ORGANIZED
  15.  
  16. //NOTES: Events that need to be made:
  17. //---Event 1:looping of cafe atmosphere////////
  18. //---Event 1.5: individual random talking points and shouts////////
  19. //---Event 2: individual tapping of espresso cup/////
  20. //---Event 3: rhythmic low beat -randomness////
  21. //---Event 4: rhythmic perc with espresso cup-looping. Choosing random taps and kicks.////
  22. //---Event 5: Bass comes in on tempo with perc, pbind of two note progressions
  23. //---EVENT 5.5: Create a common tempo clock
  24. //////TO DO: fix mid beat so that both dur and amp are in sync
  25. //////TO DO: Allow cafe ambi buffer to be faded out upon STOP.*****08/4/2018 DONE!!! Used adsr envelope and gate to activate release in synth//////
  26. //---Event 6: swirl hit in tempo and pitch with bass; random swirly twinkles
  27. //////TO DO: ---need to be tweaked and made more efficient. right now use WAY too much cpu. USE ITERATION TO GENERATE RANDOM SECTIONS OF IT TO SHIMMER --DONE(08/23/2018). Made more efficient by using EFs technique to readbuf according to a noise envelope for it's frequency, thereby giving some randomness. I also created mono version and used randomized panning to lessen cpu load.
  28. //---Event 7: Bass third pbind that can be transitioned to on command and loop as many times as I'd like.
  29. //---Event 8: Crust getting pulled away, fade out cafe atmosphere over 8 seconds time. drums stop.
  30. //---Event 9 and event 10: twinkle and swirls complimenting each other in harmony. wide stereo. twinkle sent to delay and reverb bus. scale progression iterative. individual talking points heavily reverbed and delayed to be hit on command
  31. //---Bass and beat left with descending scale of twinkle and bpf on swirl.
  32. //---fades out and ends
  33.  
  34. //0. organize synth folder
  35. //In Composition1 folder, include code for synthdefs, pbinds, code to allocate audio bus for reverb, code to read multiple sound files into dictionary buffers
  36.  
  37.  
  38. //11-10-18; second reverb bus (long tail) not being able to be sent to. figure this out to be controlled when events are called. Works if I replace \reverb with \reverb2 in the reverb bus, but I cannot use it as a second reverb. Figure this out
  39.  
  40. /************************************************/
  41. /* PROJECT CODE STARTS HERE!*/
  42. s.quit;
  43. s.plotTree;
  44. s.meter;
  45.  
  46. (
  47. //1. config the server
  48. s = Server.local;
  49.  
  50. ServerOptions.devices;
  51.  
  52. s.options.outDevice_(
  53.     "Built-in Output"
  54.     //"Soundflower (2ch)"
  55.     //"Zen Studio"
  56. );
  57. //give local host server numb of channels my output device has and that I will be using
  58. s.options.numOutputBusChannels_(2);
  59.  
  60. //for mic or instrument in, want to use:
  61. s.options.inDevice_(
  62.     //"Zen Studio"
  63.     "Built-in Microph"
  64. );
  65. //s.options.numInputBusChannels_(12);
  66. s.options.sampleRate_(44100);
  67.  
  68. //set higher memsize before booting (2^20)
  69. s.options.memSize_(2.pow(20));
  70. s.newBusAllocators;
  71. ServerBoot.removeAll;
  72. ServerTree.removeAll;
  73. ServerQuit.removeAll;
  74.  
  75. //2. initialize global variables
  76. //like default min output bus, for instance if new pc sends hardware outputs to NOT output zero, which would suck and I would have to go through and change all synthdef output refs. Meanwhile, setting a global output bus index variable helps with this.
  77.  
  78. ~out = 0;
  79.  
  80.  
  81. //3. define piece-specific functions
  82.  
  83. ~makeBuffers = {
  84.     (
  85. b = Dictionary.new;
  86. PathName("/Users/shorthouse/Documents/SuperCollider 2018/Pieces/1/buffers/voices/").entries.do{
  87.     arg subfolder;
  88.     b.add(subfolder.folderName.asSymbol ->
  89.         Array.fill(
  90.             subfolder.entries.size,
  91.             {
  92.                 arg i;
  93.                 Buffer.read(s, subfolder.entries[i].fullPath);
  94.             }
  95.         )
  96.     )
  97. };
  98. )};
  99.  
  100.  
  101. ~makeBusses = {
  102.     ~bus = Dictionary.new;
  103.     ~bus.add(\reverb2 -> Bus.audio(s,2));
  104.     ~bus.add(\reverb -> Bus.audio(s,2));
  105.     ~bus.add(\delay -> Bus.audio(s,2));
  106. };
  107.  
  108. ~cleanup = {
  109.     s.newBusAllocators;
  110.     ServerBoot.removeAll;
  111.     ServerTree.removeAll;
  112.     ServerQuit.removeAll;
  113. };
  114.  
  115. ~makeNodes = {
  116.     s.bind({
  117.     ~mainGrp = Group.new;
  118.         ~delayGrp = Group.after(~mainGrp);
  119.         ~delaySynth = Synth.new(
  120.             \delaystereo,
  121.             [
  122.                 \amp, 1,
  123.                 \in, ~bus[\delay],
  124.                 \out, ~out,
  125.             ],
  126.             ~delayGrp
  127.         );
  128.     ~reverbGrp = Group.after(~delayGrp);
  129.     ~reverbSynth = Synth.new(
  130.         \reverb,
  131.         [
  132.             \in, ~bus[\reverb],
  133.             \out, ~out,
  134.         ],
  135.         ~reverbGrp
  136.         );
  137.         ~reverbSynth = Synth.new(
  138.             \reverb2,
  139.             [
  140.                 \in, ~bus[\reverb2],
  141.                 \out, ~out,
  142.             ],
  143.             ~reverbGrp
  144.         );
  145.     });
  146. };
  147.  
  148. ~makeEvents = {
  149.     //MIDIIn.connectAll;
  150.     //Events need to be in order of occurance of gradualness from cafe into the space of ones mind with repeated iterations and melodies
  151.     e = Dictionary.new;
  152.  
  153.     ///08/4/2018: NEED TO FIGURE OUT HOW TO BE ABLE TO FADE THIS BUFFER OUT ON COMMAND. SET IT AS A SYNTH AND THEN BE ABLE TO TRIGGER A FADE OUT. Changing the 'rel' midplay does not help because the synth has already been instantiated. The updated rel would only take effect if synth is re-ran. I want to be able to trigger a fade out as it's playing at any point in time.
  154.     e.add(\eventcafeatmos -> {
  155. ~cafeatmos =
  156.         Synth(\cafeatmos)
  157.     });
  158.  
  159.     e.add(\twinkle1 -> {
  160.         ~twinkle1 =
  161.         rrand(4,7).do{
  162. Pbind(
  163.                 \instrument, \twinklemel2,
  164.                     \buf, b[\hits][19],
  165.                 \dur, Pseq([1], 1),
  166.                     \amp, 50,
  167.                 \atk, Prand([0.3,0.7,1.2,2],1),
  168.                 \rel, Prand([3,4,5],1),
  169.         \bpfmix, 0,
  170.                 \rq, Prand([0.01, 0.08, 0.1, 0.2, 0.4],1),
  171.                 \rate, Prand([1,0.8,0.6,0.4],1),
  172.                 \pan, Prand([-1,-0.7,-0.3, 0.3, 0.7, 1],1),
  173.                 \group, ~mainGrp,
  174.                 \out, ~bus[\reverb],
  175. ).play;
  176.  
  177.     }
  178.  
  179.     });
  180.  
  181.     e.add(\randomshouts -> {
  182.         (
  183.             Synth(\randshout,
  184.                 [
  185.                     \buf, b[\ct][rrand(0,4)],
  186.                     \rstart, rrand(0.8,1.3),
  187.                     \rend, rrand(0.6,1.1),
  188.                     \rdur, rrand(0.7,2),
  189.                     \amp, 0.5,
  190.                     \pan, rrand(-0.3,0.3),
  191.                     \out, ~out,
  192.                 ]
  193.             );
  194.         )
  195.  
  196.     });
  197.  
  198.     e.add(\randomshouts2 -> {
  199.         (
  200.             Synth(\randshout2,
  201.                 [
  202.                     \buf, b[\ct][rrand(0,4)],
  203.                     \rstart, rrand(0.8,1.3),
  204.                     \rend, rrand(0.6,1.1),
  205.                     \rdur, rrand(0.7,2),
  206.                     \amp, 1,
  207.                     \pan, rrand(-1,1),
  208.                     \out, ~bus[\reverb2],
  209.                     \out, ~bus[\delay],
  210.                 ]
  211.             );
  212.         )
  213.  
  214.     });
  215.  
  216.     e.add(\randomshouts3 -> {
  217.         (
  218.             Synth(\randshout,
  219.                 [
  220.                     \buf, b[\ct][rrand(0,4)],
  221.                     \rstart, rrand(0.8,1.3),
  222.                     \rend, rrand(0.6,1.1),
  223.                     \rdur, rrand(0.7,2),
  224.                     \amp, 0.8,
  225.                     \pan, rrand(-1,1),
  226.                     \out, ~out,
  227.                     \out, ~bus[\delay],
  228.                 ]
  229.             );
  230.         )
  231.     });
  232.  
  233.     //NEED TO MAKE THIS BASS LOOP TO A RHYTHM. HOW DO I DO THIS?
  234.     e.add(\basstap -> {
  235.  
  236.             var db, task;
  237.             db = -30;
  238.             task = Task({
  239.                 1.wait;
  240.  
  241.                 70.do({
  242.                     db = db + 0.5;
  243.                     0.25.wait;
  244.                 });
  245.         });
  246.  
  247.         ~basstap2.stop;
  248.  
  249.  
  250. ~basstap = Pbind(
  251.     \instrument, \simpbass,
  252.             \rel, 0.3,
  253.             \dur, Pseq([0.4,0.4,0.4,0.4],inf),
  254.             //Pseq([0.5,0.5,0.5,0.5,0.8], inf),
  255.             \note, Pseq([40, 40, 40, 40, 40, 40],inf),
  256.             //\amp, Pseq([0.8, 0.65, 0.65], inf),
  257.             \db, Pfunc({
  258.                 if(db < -5) {db} {-5};
  259.             }),
  260.     \out, ~out,
  261. ).play;
  262.  
  263.         task.play;
  264.     });
  265.  
  266.     e.add(\basstap2 -> {
  267.         ~basstap.stop;
  268.  
  269.         ~basstap2 =
  270.         Pbind(
  271.             \instrument, \simpbass,
  272.             \dur, Pseq([0.25, 0.25, 0.25], inf),
  273.             \note, Pseq([40, 40, 40], inf),
  274.             \amp, Pseq([0.9, 0.7, 0.7], inf),
  275.             \out, ~out,
  276.         ).play;
  277.     });
  278.  
  279.     e.add(\basstap3 -> {
  280.         ~basstap3 =
  281.         Pbind(
  282.             \instrument, \simpbass,
  283.             \dur, Pseq([1], inf),
  284.             \note, Pseq([60], inf),
  285.             \amp, 0.8,
  286.             \out, ~out,
  287.         ).play;
  288.     });
  289.  
  290.  
  291.     e.add(\bpfswirls -> {
  292.         ~bpfswirls =
  293.             Pbind(
  294.                     \instrument, \bpfswirl,
  295.                 \dur, Prand([1, 1.5, 2, 2.5],inf),
  296.                 \cf, Pseq([500,1000,2000,3000,5000],inf),
  297.                 \start, 0,
  298.                 \end, b[\hits][16].numFrames-1,
  299.                 \freq, 0.4,
  300.                     \amp, 8,
  301.                 \pan, Prand([-1,-0.8,-0.5, 0.5, 0.8, 1], inf),
  302.                 \rq, Pseq([0.9,0.8,0.7,0.55,0.3],inf),
  303.             \group, ~mainGrp,
  304.             \out, ~bus[\reverb2],
  305.             ).play;
  306.     });
  307.  
  308.     e.add(\lowbeat -> {
  309.         ~lowbeat =
  310.         Pbind(
  311.             \instrument, \espkik,
  312.             \amp, Pseq([3, 2, 2, 2],inf),
  313.             \dur,Pseq([(1/4),(1/4),(1/4),(1/4)],inf),
  314.             //Prand([(1/8), (1/4), (1/2)], inf),
  315.             \rate, Prand([1, 0.8, 0.6, 1.2, 1.3],inf),
  316.             \cfmin, Prand([90,95,100,110,120],inf),
  317.             \cfmax, Prand([180, 190, 200, 210, 220],inf),
  318.             \group, ~reverbGrp,
  319.         ).play;
  320.  
  321.         ~cafeatmos.set(\gate,0);
  322.  
  323.     });
  324.  
  325.     e.add(\midbeat -> {
  326.  
  327.         var amp1, task1;
  328.             amp1 = 0.1;
  329.             task1 = Task({
  330.                 1.wait;
  331.  
  332.                 30.do({
  333.                     amp1 = amp1 + 0.02;
  334.                     0.2.wait;
  335.                 });
  336.         });
  337.  
  338.         ~midbeat =
  339.         Pbind(
  340.             \instrument, \espmidhit,
  341.             \dur, Pseq([(1/8),(1/16),(1/8),(1/8),(1/8),(1/8),(1/8),(1/8),(1/8)], inf),
  342.             \buf, Prand(b[\taps], inf),
  343.             \rate, 1,
  344.             \amp, Pfunc({
  345.                 if(amp1 < 0.5) {amp1} {rrand(0.40,0.75)};
  346.             }),
  347.  
  348.             //Prand([1, 0.8, 0.6, 0.45, 0.4, 0.3], inf),
  349.         ).play;
  350.  
  351.         task1.play;
  352.     });
  353.  
  354.  
  355.  
  356.     /*MIDIdef.noteOn(\controller, {
  357.         arg val, num;
  358.         [val, num].postln;
  359.  
  360.     });*/
  361.  
  362.     /*MIDIdef.cc(\controller, {
  363.     arg val, num;
  364.     [val, num].postln;
  365.     });*/
  366.  
  367.  
  368. };
  369.  
  370. //4. register functions with serverboot/quit/tree
  371. ServerBoot.add(~makeBuffers);
  372. ServerBoot.add(~makeBusses);
  373. ServerQuit.add(~cleanup);
  374.  
  375.  
  376. //5. boot server
  377. s.waitForBoot({
  378.     s.sync; //says to server hey whatever you're doing finish it up and let me know when you're done
  379.  
  380.     SynthDef(\cafeatmos,
  381.         {
  382.             arg amp=0.6, out=0, gate=1;
  383.             var sig, env, gen;
  384.             env = Env.adsr(15,1,1,15,peakLevel: 0.5, curve:1);
  385.             gen = EnvGen.kr(env, gate, doneAction:2);
  386.             sig = PlayBuf.ar(2, b[\hits][6]);
  387.             sig = LPF.ar(sig, 4000);
  388.             sig = sig*amp*gen;
  389.             Out.ar(out, sig);
  390.  
  391.     }).add;
  392.  
  393.  
  394. SynthDef(\randshout,
  395.         {
  396.             arg amp=0.7, out=0, buf=b[\ct][0], rstart=1, rend=1, rdur=1, pan=0;
  397.         var sig, env;
  398.             env = EnvGen.kr(Env([0,1,0],[0.2,3]),doneAction:2);
  399.             sig = PlayBuf.ar(2, buf);
  400.             sig = LPF.ar(sig, 4000);
  401.             sig = Balance2.ar(sig[0],sig[1], pan, amp);
  402.             sig = sig*env*amp;
  403.         Out.ar(out, sig);
  404.     }).add;
  405.  
  406.     SynthDef(\randshout2,
  407.         {
  408.             arg amp=1, out=0, buf=b[\ct][0], rstart=1, rend=1, rdur=1, pan=0;
  409.         var sig, env;
  410.             env = EnvGen.kr(Env([0,1,0],[0.4,2]),doneAction:2);
  411.             sig = PlayBuf.ar(2, buf, XLine.kr(rstart, rend, rdur));
  412.             sig = LPF.ar(sig, 4000);
  413.             sig = DelayN.ar(sig, 0.6, rrand(0.1,0.6),0.6, sig);
  414.             sig = DelayC.ar(sig, 1.0, rrand(0.8,1.0), 0.4, sig);
  415.             sig = Balance2.ar(sig[0],sig[1], pan, amp);
  416.             sig = sig*env*amp;
  417.         Out.ar(out, sig);
  418.     }).add;
  419.  
  420.  
  421. SynthDef(\espkik,
  422.     {
  423.         arg out=0, amp=1, atk=0.02, rel=0.8, buf=0,cfmin = 90, cfmax = 150, rqmin=0.5, rqmax=0.85;
  424.         var sig, env;
  425.         env = EnvGen.kr(Env([0,1,0],[atk,rel]), doneAction:2);
  426.             sig = {PlayBuf.ar(1, b[\hits][14], 0.08, startPos:504000)}!2;
  427.         sig = BPF.ar(sig,
  428.             {LFNoise1.kr(0.1).exprange(cfmin, cfmax)}!2,
  429.             {LFNoise1.kr(0.1).exprange(rqmin, rqmax)}!2);
  430.         sig = Balance2.ar(sig[0],sig[1],0);
  431.         sig = sig*env*amp;
  432.         Out.ar(out, sig);
  433. }).add;
  434.  
  435.  
  436.  
  437.  
  438. //SYNTHDEF FOR 'HATS'
  439.  
  440. SynthDef(\esphat,
  441.     {
  442.             arg pan=0,out=0, amp=20, atk = 0.1, buf=0, sus=0,rel=0.5, cfmin=5000, cfmax = 10000, rqmin = 0.6, rqmax = 1;
  443.         var sig, env;
  444.         env = EnvGen.kr(Env([0,5,5,0], [atk, sus, rel]), doneAction:2);
  445.             sig = {PlayBuf.ar(2, b[\hits][0], 1, startPos:768000)}!2;
  446.         sig = BPF.ar(sig,
  447.             {LFNoise1.kr(0.5).exprange(cfmin, cfmax)}!2,
  448.             {LFNoise1.kr(0.2).exprange(rqmin, rqmax)}!2);
  449.         sig = Balance2.ar(sig[0], sig[1], pan);
  450.         sig = sig*env*amp;
  451.             sig = Pan2.ar(sig, pan);
  452.         Out.ar(out, sig);
  453. }).add;
  454.  
  455.  
  456.  
  457.  
  458. //SYNTHDEF FOR MIDDY HITS
  459.  
  460. SynthDef(\espmidhit,
  461.     {
  462.         arg pan=0, out=0, amp=3, atk=0.02, buf=0, rel=0.5, cfmin = 100, cfmax = 250, rqmin=0.7, rqmax=0.9;
  463.         var sig, env;
  464.         env = EnvGen.kr(Env([0,4,0],[atk,rel]), doneAction:2);
  465.             sig = PlayBuf.ar(2,buf,0.4, doneAction:2);
  466.         sig = BPF.ar(sig,
  467.             {LFNoise1.kr(0.1).exprange(cfmin, cfmax)}!2,
  468.             {LFNoise1.kr(0.1).exprange(rqmin, rqmax)}!2);
  469.             sig = sig*env*amp;
  470.         Out.ar(out, sig);
  471. }).add;
  472.  
  473.  
  474.  
  475.  
  476. SynthDef(\simpbass,
  477.     {
  478.         arg out = 0, cutoff = 250, note = 35, atk = 0, rel = 0.6, c1 = 1, c2 = -1, amp = 0.7, cf = 120, rq = 1.0;
  479.         //HEY PS! the c1 and c2 refer to "curvature values" of the amplitude envelope. Still need to look up what positive and negative values mean here, as well as the shape of curvature when these values are close to +_1.
  480.         var sig, env;
  481.         env = EnvGen.kr(Env(
  482.             [0,1,0], [atk, rel], [c1, 0, c2]), doneAction:2);
  483.         sig = RLPF.ar(SinOsc.ar(note.midicps,0, amp),cutoff);
  484.         sig = BPF.ar(sig, cf, rq);
  485.         sig = Pan2.ar(sig, 0);
  486.         sig = sig*amp*env;
  487.         Out.ar(out, sig);
  488. }).store;
  489.  
  490.  
  491.  
  492. SynthDef(\bpfbuf, {
  493.     arg atk=0, sus=0, rel=3, c1=1, c2=(-1), buf=0, rate=1, spos=0, freq=440, rq=1, bpfmix=0, pan=0, amp=1, out=0;
  494.     var sig, env;
  495.     env = EnvGen.kr(Env([0,1,1,0], [atk, sus, rel], [c1, 0 ,c2]), doneAction:2); //doenaction 2 ends file trigger when envelope is done playing
  496.     sig = PlayBuf.ar(2, buf, rate*BufRateScale.ir(buf), startPos:spos); //playbuf = 2 bc my signals are stereo
  497.     sig = XFade2.ar(sig, BPF.ar(sig, freq, rq, 1/rq.sqrt), bpfmix*2-1);
  498.     sig = sig * env;
  499.     sig = Balance2.ar(sig[0],sig[1],pan);
  500.     Out.ar(out, sig);
  501. }).add;
  502.  
  503.  
  504.  
  505. SynthDef(\bpfswirl, {
  506.     arg atk=0.5, sus=0, rel=1, c1=1, c2=(-1), start, end, rate=0.8, spos=0, freq=1, cf=3000, rq=0.7, bpfmix=0.7, pan=0, amp=6, out=0;
  507.     var sig, env, ptr;
  508.         ptr = LFDNoise1.ar(freq).range(start,end);
  509.         sig = BufRd.ar(1, b[\hits][18], ptr);
  510.     env = EnvGen.kr(Env([0,1,1,0], [atk, sus, rel], [c1, 0 ,c2]), doneAction:2); //doenaction 2 ends file trigger when envelope is done playing
  511.         //sig = PlayBuf.ar(2, b[\hits][16], rate, startPos:spos); //playbuf = 2 bc my signals are stereo
  512.     sig = BPF.ar(sig, cf, rq, 1/rq.sqrt);
  513.  
  514.         sig = sig*env;
  515.         //sig = Balance2.ar(sig[0],sig[1],pan,amp);
  516.         sig = Pan2.ar(sig, pan, amp);
  517.         sig = sig * amp;
  518.     Out.ar(out, sig);
  519. }).add;
  520.  
  521. SynthDef(\sawcrust,
  522.     {
  523.         arg out=0, atk=1, sus=1, rel=1, c1=1, c2=(-1), pan=0, amp=1, cfmin=800, cfmax=1000, rqmin=0.5, rqmax=0.9, sfreq=10, lindur=2, linend=40, cffmin=9000, cffmax=11000, rqqmin=0.2, rqqmax=0.5;
  524.         var sig, env;
  525.         env = EnvGen.kr(Env([0,1,1,0], [atk, sus, rel], [c1, 0, c2]),doneAction:2);
  526.         sig = {Saw.ar(XLine.kr(sfreq,linend,lindur))*env}!2;
  527.         sig = {BPF.ar(sig, exprand(cfmin, cfmax), rrand(rqmin,rqmax), amp)}!2;
  528.         sig = Pan2.ar(sig, pan, amp);
  529.         Out.ar(out, sig);
  530. }).add;
  531.  
  532.  
  533. SynthDef(\sawcrust2,
  534.     {
  535.         arg out=0, atk=1, sus=1, rel=1, c1=1, c2=(-1), pan=0, amp=1, cfmin=800, cfmax=1000, rqmin=0.5, rqmax=0.9, sfreq=10, lindur=2, linend=40, cffmin=9000, cffmax=11000, rqqmin=0.2, rqqmax=0.5;
  536.         var sig, env;
  537.         env = EnvGen.kr(Env([0,1,1,0], [atk, sus, rel], [c1, 0, c2]),doneAction:2);
  538.         sig = {Saw.ar(XLine.kr(sfreq,linend,lindur))*env}!2;
  539.         sig = {BPF.ar(sig, exprand(cfmin, cfmax), rrand(rqmin,rqmax), amp)}!2;
  540.         sig = {BPF.ar(sig, rrand(cffmin,cffmax), rrand(rqqmin, rqqmax))}!2;
  541.         sig = Pan2.ar(sig, pan, amp);
  542.         Out.ar(out, sig);
  543. }).add;
  544.  
  545.  
  546.  
  547.  
  548. SynthDef(\twinklemel2, {
  549.     arg atk=0, sus=2, rel=3, c1=1, c2=(-1), buf=0, rate=1, spos=0, freq=840, rq=1, bpfmix=0, pan=0, amp=1, out=0;
  550.     var sig, env;
  551.     env = EnvGen.kr(Env([0,1,1,0], [atk, sus, rel], [c1, 0 ,c2]), doneAction:2); //doenaction 2 ends file trigger when envelope is done playing
  552.         sig = PlayBuf.ar(2, buf, rate*BufRateScale.ir(buf), startPos:spos, doneAction:2);
  553.     sig = BLowPass.ar(sig, 2500);//playbuf = 2 bc my signals are stereo
  554.     sig = XFade2.ar(sig, BPF.ar(sig, freq, rq, 1/rq.sqrt), bpfmix*2-1);
  555.     sig = sig * env;
  556.     sig = Balance2.ar(sig[0],sig[1],pan,amp);
  557.     Out.ar(out, sig);
  558. }).add;
  559.  
  560.  
  561.     SynthDef(\reverb, {
  562.         arg in, predelay=0.1, revtime=1.8, lpf=4500, mix=0.15, amp=1, out=0;
  563.         var dry, wet, temp, sig;
  564.         dry = In.ar(in, 2);
  565.         temp = In.ar(in, 2);
  566.         wet = 0;
  567.         temp = DelayN.ar(temp, 0,2, predelay);
  568.         16.do{
  569.             temp = AllpassN.ar(temp, 0.05, {Rand(0.001, 0.05)}!2, revtime);
  570.             temp = LPF.ar(temp, lpf);
  571.             wet = wet + temp;
  572.         };
  573.         sig = XFade2.ar(dry, wet, mix*2-1, amp);
  574.         Out.ar(out, sig);
  575.     }).add;
  576.  
  577.     SynthDef(\reverb2, {
  578.         arg in, out=0, pan=0.5;
  579.         var input, rev, sig;
  580.         input = In.ar(in, 2);
  581.         rev = JPverb.ar(input,
  582.             \t60.kr(1, 0.05),
  583.             \damp.kr(0, 0.05),
  584.             \size.kr(1, 0.05),
  585.             \earlyDiff.kr(0.707, 0.05),
  586.             \modDepth.kr(5, 0.05),
  587.             \modFreq.kr(2, 0.05),
  588.             \low.kr(1, 0.05),
  589.             \mid.kr(1, 0.05),
  590.             \high.kr(1, 0.05),
  591.             \lowcut.kr(200, 0.05),
  592.             \highcut.kr(2000, 0.05)
  593.         );
  594.         sig = Mix([input, rev]) *0.1;
  595.         Out.ar(out, sig);
  596.     }).add;
  597.  
  598.  
  599.  
  600. SynthDef(\delaystereo, {
  601.   |
  602.   in = 0, out = 0, amp = 1, delayTime = 0.5, maxDelayTime = 5, feedback = 0.4,
  603.   filterType = 0, cutoff = 20000, rq = 1, mix = 0.7, lagTime = 0.1
  604.   |
  605.   var input, lowPass, highPass, bandPass, filter, localIn, delay, sig;
  606.   input = In.ar(in, 2);
  607.   localIn = LocalIn.ar(2);
  608.  
  609.   lowPass = RLPF.ar(localIn, cutoff, rq);
  610.   highPass = RHPF.ar(localIn, cutoff, rq);
  611.   bandPass = BPF.ar(localIn, cutoff, rq);
  612.   filter = Select.ar(filterType, [localIn, lowPass, highPass, bandPass]);
  613.  
  614.   delay = DelayC.ar(input + (filter * feedback), maxDelayTime, delayTime.lag2(lagTime));
  615.   LocalOut.ar(delay);
  616.  
  617.   sig = (filter * mix) + (input * (1-mix));
  618.   sig = sig * amp;
  619.   Out.ar(out, sig);
  620. }).add;
  621.  
  622.  
  623.     s.sync;
  624.  
  625.     ServerTree.add(~makeNodes);
  626.     ServerTree.add(~makeEvents);
  627.     s.freeAll;
  628.  
  629.     s.sync;
  630.  
  631.     "donebitch".postln;
  632. });
  633. )
  634.  
  635.  
  636. s.quit;
  637.  
  638. //7/23/2018 - added event for twinkle, fixed timing for the mid hit buffer sampling. Added folder of buffers of random blurts from recordings. Re-mapped synths for kick, mid, and hat to refer to new bufnum of main sample. Made memo to include baby sound into melody. NEED TO: assign events for percussive fade in and out. Event for random shouts and hollers, at varying rates. Event for periodic tapping of espresso cup. Figure out how to loop events. NEED TO LOOP BASS. CREATING A PBIND ALONE DOES NOT DO IT.
  639. //7/24/2018 - Looped bass indefinitely with a pbind. NEED TO: Create another event that stops prior bass loop and induces new bass loop with note sequence change. That way I can switch between one looping sequence and the other at will.
  640.  
  641. s.meter;
  642. //a test:
  643.  
  644. /***************************************/
  645. /*THE FOLLOWING EVENTS CALL INSTRUMENTS AND FUNCTIONS IN REAL TIME*/
  646.  
  647. e[\eventcafeatmos].play;
  648. e[\randomshouts].play;//centered and clean and low amp
  649. Synth(\twinklemel2, [\buf, 19, \pan, rrand(-0.9,0.9), \out, ~bus[\delay]]);
  650.  
  651. Synth(\esphat, [\amp, 45, \out,~bus[\reverb2]], ~mainGrp);
  652.  
  653. e[\bpfswirls].play;
  654. e[\randomshouts3].play; //clean and delayed
  655.  
  656. e[\twinkle1].play;
  657. e[\twinkle1].play;
  658. ~twinkle1.stop; //does not work
  659. e[\randomshouts2].play; //delayed and verbed and warped
  660. Synth(\simpbass, [\amp, 1.5, \note, 34, \out, ~bus[\delay], ~bus[\reverb]], ~mainGrp);
  661. e[\basstap].play;
  662. ~basstap.stop;
  663. e[\basstap2].play;
  664. ~basstap2.stop;
  665. e[\basstap3].play;
  666. ~basstap3.stop;
  667. e[\lowbeat].play;
  668. ~lowbeat.stop;
  669. e[\midbeat].play;
  670. ~midbeat.stop;
  671.  
  672. ~mainGrp.stop;
  673.  
  674. (~crust = {
  675.     Pbind(
  676.         \instrument, \sawcrust2,
  677.         \dur, Pseq([1,0.5], 3),
  678.         \amp, 1.5,
  679.         \group, ~mainGrp,
  680.         \out, ~bus[\reverb2],
  681.     ).play;
  682. };)
  683.  
  684. ~crust.play;
  685.  
  686.  
  687.  
  688.  
  689. Synth(\espmidhit, [\amp, 2]);
  690. Synth(\espkik, [\amp, 10, \out, ~bus[\reverb2]], ~mainGrp);
  691.  
  692. s.meter;
  693. s.quit;
  694.  
  695. b[\hits][19].play;
  696. b[\ct][4].play;
  697. b[\hits][16].play;
  698. b[\hits][18].play;
  699. //6. anything else requiring a booted server activate
  700.  
  701. //2/6/2019: added Pfunc aspects to bass and midbeat for fading in Pbind upon activating the event.
  702.  
  703. s.record;
  704. s.record;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top