// title: Assignment #1 // author: hwright // description: // https://soundcloud.com/user-665612115/db-assignment-1-musc115 // code: //SynthDefs ( SynthDef("riser", {arg out = 0, amp = 0.5, pan = 0; var env, snd; env = Env.linen( 10, 0.000001, 0.0001, 0.5).kr(doneAction: 2); snd = LPF.ar( in: WhiteNoise.ar(env), freq: 2000, mul: amp ); Out.ar(out, Pan2.ar(snd, pan)); }).add; SynthDef("hihat", {arg out = 0, amp = 0.5, att = 0.01, rel = 0.2, ffreq = 6000, pan = 0; var env, snd; env = Env.perc(att, rel, amp).kr(doneAction: 2); snd = WhiteNoise.ar; snd = HPF.ar(in: snd, freq: ffreq, mul: env); Out.ar(out, Pan2.ar(snd, pan)); }).add; SynthDef("snare", {arg out = 0, amp = 0.1, sinfreq = 180, att = 0.01, rel = 0.2, ffreq = 2000, pan = 0; var env, snd1, snd2, sum; env = Env.perc(att, rel, amp).kr(doneAction: 2); snd1 = HPF.ar( in: WhiteNoise.ar, freq: ffreq, mul: env ); snd2 = SinOsc.ar(freq: sinfreq, mul: env); sum = snd1 + snd2; Out.ar(out, Pan2.ar(sum, pan)); }).add; SynthDef("kick", {arg out = 0, amp = 0.3, sinfreq = 60, glissf = 0.9, att = 0.01, rel = 0.45, pan = 0; var env, snd, ramp; env = Env.perc(att, rel, amp).kr(doneAction: 2); ramp = XLine.kr( start: sinfreq, end: sinfreq * glissf, dur: rel ); snd = SinOsc.ar(freq: ramp, mul: env); snd = Pan2.ar(snd, pan); Out.ar(out, snd); }).add; SynthDef("sub", {arg out = 0, amp = 0.3, sinfreq = 60, sus = 0.1, glissf = 0.005, att = 0.01, rel = 0.45, pan = 0; var env, snd, ramp; env = Env.linen(attackTime: 0.25, sustainTime: sus, releaseTime: rel, level: amp).kr(doneAction: 2); ramp = XLine.kr( start: sinfreq, end: sinfreq, dur: rel ); snd = SinOsc.ar(freq: ramp, mul: env); snd = Pan2.ar(snd, pan); Out.ar(out, snd); }).add; SynthDef("sawSynth", { arg freq = 440, amp = 0.1, att = 0.1, rel = 2, lofreq = 1000, hifreq = 3000; var env, snd; env = Env.perc( attackTime: att, releaseTime: rel, level: amp ).kr(doneAction: 2); snd = Saw.ar(freq: freq * [0.99, 1, 1.001, 1.008], mul: env); snd = LPF.ar( in: snd, freq: LFNoise2.kr(1).range(lofreq, hifreq) ); snd = Splay.ar(snd); Out.ar(0, snd); }).add; SynthDef("plucking", {arg amp = 0.1, freq = 440, decay = 5, dampen = 0.1; var env, snd; env = Env.linen(0, decay, 0).kr(doneAction: 2); snd = Pluck.ar( in: WhiteNoise.ar(amp), trig: Impulse.kr(0), maxdelaytime: 0.1, delaytime: freq.reciprocal, decaytime: decay, coef: dampen); Out.ar(0, [snd, snd]); }).add; ) //Pbinds ( a = Pbind( \instrument, "plucking", \midinote, Pseq([ 82, 81, 75, 77, 69, 70, 72, 81, 82, 81, 75, 77, 81, 77, 79, 81, 77], inf), \amp, 0.1, \decay, 4, \dampen, 0.01, \dur, Pseq([12/4, 12/4, 4/8, 16/4, 4/8, 9/4, 10/8, 4/8, 14/4, 14/4, 4/8, 24/8, 4/8, 4/8, 12/4, 4/8, 4/8], inf), \ctranspose, [-24, -12, 0] ); c =Pbind( \instrument, "snare", \degree, 0, \dur, 2, \amp, 0.25, \rel, 0.7, ); d = Pbind( \instrument, "kick", \dur, Pseq([ 0.5, 1.8, 1.7],inf), \att, 0.01, \rel, 0.01, \sinfreq, 150, \glissf, 0.5, \amp, 0.5, ); f = Pbind( \instrument, "hihat", \dur, Pseq([ 0.5, 1.8, 1.7],inf), \att, 0.01, \rel, 0.2, \sinfreq, 120, \glissf, 0.5, \amp, 0.5, ); g = Pbind( \instrument, "hihat", \dur, 0.25, \att, 0.01, \rel, 0.2, \sinfreq, 120, \glissf, 0.5, \amp, 0.4, ); e = Pbind( \instrument, "sub", \dur, Pseq([ 24/4, 14/2, 32/2, 28/4, 8, 14/2, 18/2],inf), \att, 20, \sus, Pseq([ 8/4, 4/2, 8/2, 6/4, 5/2, 4/2, 6/2 ], inf), \rel, Pseq([ 2/4, 3/2, 8/2, 7/4, 4/2, 1/2, 2/2], inf), \sinfreq, Pseq([ 49, 44, 73, 49, 44, 73, 78], inf), \amp, 0.2, ); h = Pbind( \instrument, "riser", \dur, 4, \degree, Pseq([1], 1), \amp, 1 ); i =Pbind( \instrument, "sawSynth", \midinote, Pseq([ 82, 81, 75, 77, 69, 70, 72, 81, 82, 81, 75, 77, 81, 77, 79, 81, 77], inf), \dur, Pseq([12/4, 12/4, 4/8, 16/4, 4/8, 9/4, 10/8, 4/8, 14/4, 14/4, 4/8, 24/8, 4/8, 4/8, 12/4, 4/8, 4/8], inf), \ctranspose, [0, -12], \att, 0.01, \rel, 1, \amp, 0.3, \lofreq, 500, \hifreq, 1500 ); ) //Play ( { ~pluck = a.play(TempoClock(170/60)); 43.wait; ~riser = h.play(TempoClock(170/60)); 2.25.wait; ~sawsynth = i.play(TempoClock(170/60)); ~kick = d.play(TempoClock(170/60)); ~hihat = f.play(TempoClock(170/60)); ~fasthat = g.play(TempoClock(170/60)); ~sub = e.play(TempoClock(170/60)); 0.75.wait; ~snare = c.play(TempoClock(170/60)); 44.5.wait; ~fasthat.stop; ~hihat.stop; ~sub.stop; ~sawsynth.stop; 20.375.wait; ~riser = h.play(TempoClock(170/60)); 2.25.wait; ~sawsynth = i.play(TempoClock(170/60)); ~hihat = f.play(TempoClock(170/60)); ~fasthat = g.play(TempoClock(170/60)); ~sub = e.play(TempoClock(170/60)); 45.25.wait; ~hihat.stop; ~fasthat.stop; ~kick.stop; ~snare.stop; 22.625.wait; ~sawsynth.stop; ~sub.stop; ~pluck.stop; }.fork )