Advertisement
Guest User

Untitled

a guest
May 9th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (
  2. ~direct = Group.new();
  3. ~effect = Group.after(~direct);
  4.  
  5. ~effectReverb = Bus.audio(s, 2);
  6. ~effectReverbD = Bus.audio(s, 2);
  7. )
  8.  
  9.  
  10. (
  11. //Sound out of Sine waves of the whole tones of the major scale
  12. SynthDef(\ScaleSound, {arg freq = 440, amp = 0.5, pan = 0.5, time = 1,
  13.     effectBus = ~effectReverb, directsound = 0.5;
  14.     var source, envelope, toneMult;
  15.     //Variables for the sound source
  16.     toneMult = [1, 3/2, 4/3, 5/4, 6/5, 7/6, 8/7];
  17.     amp = amp/7;
  18.     //Envelope and sound source
  19.     envelope =  EnvGen.ar(Env([0, amp*0.5, amp, amp*0.6, 0], [time*0.3, time*0.1, time*0.2, time*0.4], 'lin'), doneAction: 2);
  20.     source = Mix.fill(7, {| iterate |
  21.         SinOsc.ar([freq*toneMult[iterate]+Rand(1, 5),
  22.             freq*toneMult[iterate]+Rand(1, 5)], 0, envelope);});
  23.     //Panning and outs
  24.     source = Pan2.ar(source, pan, 1);
  25.     Out.ar(effectBus, source-(source*directsound));
  26.     Out.ar(0, source*directsound);
  27. }).add;
  28.  
  29. //Filter shaped fluty (maybe) tones
  30. SynthDef(\GrainFlute, {arg freq = 440, amp = 0.5, pan = 0.5, att = 1,
  31.     rel = 1, curve = 0, effectBus = ~effectReverb, directsound = 0.5;
  32.     var source, envelope, time, vibration, rq, bwr;
  33.     //Envelope and sound source
  34.     envelope = EnvGen.ar(Env.perc(att, rel, amp, curve), doneAction: 2);
  35.     source   = PinkNoise.ar([envelope, envelope]);
  36.     time = att+rel;
  37.     //Filter variables
  38.     vibration  = Dust2.kr(1/time, 0.6, 0.25);
  39.     freq      = SinOsc.kr(vibration, 0.1, Rand(1, 10), freq);
  40.     vibration  = Dust2.kr(1/time, 0.6, 0.25);
  41.     rq        = SinOsc.kr(vibration, 0.1, Rand(0.01, 0.05), 0.1);
  42.     source    = BPF.ar(source, freq, rq);
  43.     bwr       = EnvGen.kr(Env([0.0001, 0.5, 0.0001], [att, rel], 'welch'));
  44.     source    = Resonz.ar(source, freq, bwr);
  45.     source     = source*6;
  46.     //Filter variables end
  47.     //Panning and outs
  48.     source = Pan2.ar(source, pan);
  49.     Out.ar(effectBus, source-(source*directsound));
  50.     Out.ar(0, source*directsound);
  51. }).add;
  52.  
  53. //Deep, soft wide bass, not too complicated
  54. SynthDef(\WideBass, {arg freq = 110, amp = 1, pan = 0.5, time = 1, directsound =
  55.     0.5, effectbus = ~effectReverb;
  56.     var source, env;
  57.     //Envelope
  58.     amp = amp/10;
  59.     env = EnvGen.ar(Env.perc(time*0.1, time*0.9, amp, -10),
  60.         doneAction: 2);
  61.     //Source signal with filter
  62.     source = Mix.fill(20, {|iterate|
  63.         VarSaw.ar(freq+Rand(0.1, 10), Rand(0, pi*2), Rand(0.0, 1.0),
  64.             env);});
  65.     source = LPF.ar(source, EnvGen.ar(Env([500, 400, freq], [time*0.1,
  66.         time*0.9], 'lin')));
  67.     //Panning and output
  68.     source = Pan2.ar(source, pan);
  69.     Out.ar(effectbus, source-(source*directsound));
  70.     Out.ar(0, source*directsound);
  71. }).add;
  72.  
  73. //Plays a chord or a riff out of a base note
  74. //440, 440, 550, 582.7, 550, 440, 880
  75. SynthDef(\RunChord, {arg freq = 440, amp = 2, pan = 0.5, time = 1,
  76.     directsound = 0.5, effectbus = ~effectReverb;
  77.     var source,
  78.     //Frequence, envelope and filter multipliers
  79.     run  = [1, 1, 1.25, 1.324, 1.25, 1, 2],
  80.     runt = [0.1, 0.1, 0.2, 0.2, 0.1, 0.3],
  81.     runf = [1,1,1,1,1, 200];
  82.     //Source signal out of 7 frequencies
  83.     source = Mix.fill(6, { |iterate|
  84.         LPF.ar(Saw.ar(freq*run[iterate]+Line.kr(0, runf[iterate] ! 2,
  85.             time),
  86.         EnvGen.ar(Env.perc(time*runt[iterate],
  87.             time-(time*runt[iterate]), 1/7*amp, -10), doneAction: 2)),
  88.         Line.ar(50, 800, time))});
  89.     source = SinOsc.ar(freq)*source;
  90.     //Panning and output
  91.     source = Pan2.ar(source, pan);
  92.     Out.ar(effectbus, source-(source*directsound));
  93.     Out.ar(0, source*directsound);
  94. }).add;
  95.  
  96.  
  97. //A  melodic synth built out of fourths
  98. SynthDef(\Fourth, {arg freq = 440, amp = 1, pan = 0.5, time = 1, directsound =
  99.     0.5, effectbus = ~effectReverb;
  100.     var source, env;
  101.     //4 sources grouped into 2 fourths;
  102.     env = EnvGen.ar(Env.perc(0.01, time, 1, 5), doneAction: 2);
  103.     source = SinOsc.ar(freq, 0, env)*(1/2);
  104.     source = source + SinOsc.ar(freq*(4/3),  0.1, env)*(1/3);
  105.     source = source + SinOsc.ar(freq*(18/8), 0.1, env)*(1/4);
  106.     source = source + SinOsc.ar(freq*3,      0.1, env)*(1/5);
  107.     source = source * amp;
  108.  
  109.     //Panning and output
  110.     source = Pan2.ar(source, pan);
  111.     Out.ar(effectbus, source-(source*directsound));
  112.     Out.ar(0, source*directsound);
  113. }).add;
  114. )
  115.  
  116. (
  117. //The low bassy drum
  118. SynthDef(\Bdrum, {arg freq = 440, amp = 1, pan = 0.5, directsound =
  119.     0.5, effectbus = ~effectReverbD;
  120.     var source, env;
  121.  
  122.     env = EnvGen.ar(Env.perc(0.05, 0.3, amp, 10), doneAction: 2);
  123.     source = PinkNoise.ar(env);
  124.     source = LPF.ar(source, Line.kr(freq, 100, 0.1));
  125.  
  126.     source = Pan2.ar(source, pan);
  127.     Out.ar(effectbus, source-(source*directsound));
  128.     Out.ar(0, source*directsound);
  129. }).add;
  130.  
  131. //The kick
  132. SynthDef(\Kick, {arg freq = 880, amp = 1, pan = 0.5, directsound =
  133.     0.5, effectbus = ~effectReverbD;
  134.     var source, env;
  135.     env = EnvGen.ar(Env.perc(0.05, 0.2, amp, 20), doneAction: 2);
  136.     source = WhiteNoise.ar(env);
  137.     source = Resonz.ar(BPF.ar(source, Line.kr(freq, 50, 0.1), Line.kr(4, 0.01, 0.15)), 440, 1);
  138.     source = source * Saw.ar(Rand(10, 100), 0, 1);
  139.  
  140.     source = Pan2.ar(source, pan);
  141.     Out.ar(effectbus, source-(source*directsound));
  142.     Out.ar(0, source*directsound);
  143. }).add;
  144.  
  145. //The high hat
  146. SynthDef(\HighHat, {arg freq = 1000, amp = 1, pan = 0.5, directsound =
  147.     0.5, effectbus = ~effectReverbD;
  148.     var source, env;
  149.     env = EnvGen.ar(Env.perc(0.05, 0.3, amp/10, -5), doneAction: 2);
  150.     source = Mix.fill(10,{SinOsc.ar(freq+Rand(0, 200), 0, env)});
  151.     source = source * BPF.ar(PinkNoise.ar(2), 1000, SinOsc.ar(0.5, 0, 1.4, 1.5));
  152.     source = Resonz.ar(source, 2000, 3);
  153.  
  154.     source = Pan2.ar(source, pan);
  155.     Out.ar(effectbus, source-(source*directsound));
  156.     Out.ar(0, source*directsound);
  157. }).add;
  158. )
  159.  
  160. //Interesting noise thing
  161. SynthDef(\Backwardnoise, {arg freq = 440, amp = 1/7, pan = 0.5
  162.  
  163.  
  164. }).add;
  165.  
  166. (
  167. //Reverb
  168. SynthDef(\Reverb, {arg room = 1, damp = 0.5, sourceBus = ~effectReverb;
  169.     var source;
  170.     source = In.ar(sourceBus, 2);
  171.     source = FreeVerb.ar(source, 1, room, damp);
  172.     Out.ar(0, source);
  173. }).add;
  174.  
  175. //Reverb
  176. SynthDef(\ReverbD, {arg room = 1, damp = 1, sourceBus = ~effectReverbD;
  177.     var source;
  178.     source = In.ar(sourceBus, 2);
  179.     source = FreeVerb.ar(source, 1, room, damp);
  180.     Out.ar(0, source);
  181. }).add;
  182.  
  183.  
  184. Synth(\Reverb, [\room, 0.5], ~effect);
  185. Synth(\ReverbD, [\room, 0.5], ~effect);
  186. )
  187.  
  188. Synth(\GrainFlute, [\freq, 1000, \amp, 0.1, \pan, 0.5, \att, 5,
  189.         \rel, 6, \directsound, 0.5], ~direct);
  190.  
  191. //Main theme
  192. //Rythms [0.5, 0.5, 1, 0.2, 0.8, 0.5, 0.5, 0.5, 4.5]
  193. j = Routine({var freqs =
  194.     [440, 440, 550, 582.7, 550, 440, 880, 830, 932.3, 987.74, 1975.47, 1975.47];
  195.  
  196.     loop { Synth(\GrainFlute, [\freq, freqs[0], \amp, 0.1, \pan, 0.5, \att, 0.6,
  197.         \rel, 0.1, \directsound, 0.5], ~direct);
  198.         0.5.yield;
  199.         Synth(\GrainFlute, [\freq, freqs[1], \amp, 0.1, \pan, 0.5, \att, 0.5,
  200.         \rel, 0.1, \directsound, 0.5], ~direct);
  201.         0.5.yield;
  202.         Synth(\GrainFlute, [\freq, freqs[2], \amp, 0.3, \pan, 0.5, \att, 1,
  203.             \rel, 1, \directsound, 0.5], ~direct);
  204.         Synth(\WideBass, [\freq, 55, \amp, 1, \pan, 0.5, \time, 10,
  205.         \directsound, 0.5], ~direct);
  206.         1.yield;
  207.         Synth(\GrainFlute, [\freq, freqs[3], \amp, 0.1, \pan, 0.6, \att, 1,
  208.         \rel, 1, \directsound, 0.5], ~direct);
  209.         0.2.yield;
  210.         Synth(\RunChord, [\freq, 582.7, \amp, 2, \pan, 0.4, \time, 5,
  211.         \directsound, 0.5], ~direct);
  212.         0.8.yield;
  213.         Synth(\GrainFlute, [\freq, freqs[4], \amp, 0.2, \pan, 0.5, \att, 1,
  214.         \rel, 1, \directsound, 0.5], ~direct);
  215.         0.5.yield;
  216.         Synth(\ScaleSound, [\freq, freqs[5], \amp, 0.1, \pan, 0.5, \time, 3,
  217.         \directsound, 0.5], ~direct);
  218.         0.5.yield;
  219.         Synth(\GrainFlute, [\freq, freqs[6], \amp, 0.05, \pan, 0.5, \att, 2,
  220.         \rel, 2, \directsound, 0.5], ~direct);
  221.         0.5.yield;
  222.         Synth(\WideBass, [\freq, 110, \amp, 0.5, \pan, 0.5, \time, 10,
  223.         \directsound, 0.5], ~direct);
  224.         4.5.yield;
  225. }});
  226.  
  227. j.play(quant: 4);
  228. j.stop;
  229.  
  230. //Melodic content
  231. p = Routine({var freq =
  232.     [440, 440, 550, 582.7, 550, 440, 880, 830, 932.3, 987.74, 1975.47, 1975.47];
  233.  
  234.     loop {
  235.         Synth(\Fourth, [\freq, freq[0], \amp, 0.3, \pan, 0.55, \time, 2
  236.             ,\directsound, 0.7], ~direct);
  237.         1.yield;
  238.         Synth(\Fourth, [\freq, freq[1], \amp, 0.3, \pan, 0.45, \time, 2
  239.             ,\directsound, 0.7], ~direct);
  240.         1.yield;
  241.         Synth(\Fourth, [\freq, freq[2], \amp, 0.1, \pan, 0.65, \time, 2
  242.             ,\directsound, 0.7], ~direct);
  243.         2.yield;
  244.         Synth(\Fourth, [\freq, freq[3], \amp, 0.2, \pan, 0.35, \time, 0.5
  245.             ,\directsound, 0.7], ~direct);
  246.         0.5.yield;
  247.         Synth(\Fourth, [\freq, freq[4], \amp, 0.2, \pan, 0.5, \time, 3
  248.             ,\directsound, 0.7], ~direct);
  249.         1.5.yield;
  250. }});
  251.  
  252. p.play;
  253. p.stop;
  254.  
  255. u = Routine({
  256.     var amp = 1;
  257.     loop {
  258.         amp.postln;
  259.         //if (amp<1){amp = amp + 0.1}{amp};
  260.         Synth(\Bdrum, [\amp, amp],target: ~direct);
  261.         0.5.yield;
  262. }});
  263.  
  264. j.play;
  265. u.play;
  266. u.stop;
  267. j.stop;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement