// title: Assignment 1 115pluck // author: ianmcdougall60 // description: // assignment 1 Ian McDougall // soundcloud link: https://soundcloud.com/user-68447368 // code: ( 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("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; 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; // Basic saw synth for chords and bass 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; ) //Collection of Pbinds (no .play) ( ~hihat = Pbind( \instrument, "hihat", \dur, Pseq([1/4, Rest(1/4), 1/4, Rest(1/4), 1/4, Rest(1/4), 1/8, 1/8, 1/8, 1/8], inf), \att, Pseq([0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.04], inf), \rel, 0.1, \ffreq, 11000, \pan, 0, \amp, 0.3 ); ~snare = Pbind( \instrument, "snare", \dur, Pseq([Rest(1/2), 1/2, Rest(1/2), 1/2, Rest(1/2), 1/2, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8], inf), \att, 0.01, \rel, 0.1, \sinfreq, 180, \ffreq, 2000, \amp, 0.15 ); ~kick = Pbind( \instrument, "kick", \dur, Pseq([1/2, Rest(1/2), 1/2, Rest(1/2), 1/2, Rest(1/2), Rest(1/4), Rest(1/4), 1/4, Rest(1/4) ], inf), \att, 0.01, \rel, 0.22, \sinfreq, 60, \glissf, 0.9, \amp, 1, ); ~buildup = Pbind( //BUILD UP \instrument, "kick", \dur, Pseq([1/4, 1/4, 1/8, 1/8, 1/8, 1/8, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/16, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32, 1/32], 1), \att, 0.01, \rel, 0.025, \sinfreq, 60, \glissf, 0.9, \amp, 1.8, ); ~tom = Pbind( //THIS IS A TOM \instrument, "kick", \dur, Pseq([1/2, Rest(1/4), 1/4, Rest(1/2), 1/2 ], inf), \att, 0.001, \rel, 0.1, \sinfreq, 200, \glissf, 1, \amp, 1, ); ~chords = Pbind( \instrument, "sawSynth", \freq, Pseq([ [65.41, 82.41, 98], [87.31, 103.83, 130.81], [55, 65.41, 82.41, 98], [98, 123.47, 146.83], ], inf ) *1.5, \dur, Pseq([4, 2, 2, 4], inf), \att, Pseq([0.5, 0.2, 0.2, 0.5], inf), \rel, Pseq([2.5, 1.5, 1.5, 2.5], inf), \hifreq, 5000, \amp, 0.2 ); ~bassline = Pbind( \instrument, "sawSynth", \freq, Pseq([65.41, 82.41, 55, 82.41, 123.47, 98], inf), \dur, Pseq([1/2, 1/4, Rest(2),Rest(1/4), 1/4, 1/2, Rest(1), 1/2, 1/4], inf), \ctranspose, [0, -12], \att, 0.05, \rel, 0.1, \amp, 0.4, ); ~beginrif = Pbind( \instrument, "sawSynth", \freq, Pseq([55, 65.41, 82.41, 98].reverse, inf), \dur, Pseq([1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8], inf), \ctranspose, [0, -12], \att, 0.01, \rel, 0.2, \amp, 0.4, \lofreq, 100, \hifreq, 1000 ); ~humpty = Pbind( \instrument, "sawSynth", \freq, Pseq([98, 146.83, 123.47], inf), \dur, Pseq([1/8, Rest(1/16), 1/8], inf), \att, 0.1, \rel, 0.05, \amp, 0.4, \lofreq, 100, \hifreq, 1000 ); ~plucking1 = Pbind( \instrument, "plucking", \freq, Pseq([55, 65.41, 82.41, 98].reverse, inf), \amp, 0.2, \decay, 8, \dampen, 0.7, \dur, Pseq([1/4, 1/4, 1/4, 1/4], inf) ); ~plucking2 = Pbind( \instrument, "plucking", \freq, Pseq([55, 65.41, 82.41, 98].reverse, inf), \amp, 0.2, \decay, 8, \dampen, 0.7, \dur, Pseq([1/8, 1/8, 1/8, 1/8], inf) ); ) //Optional lines for testing Pbinds ~hihat.play; ~snare.play; ~kick.play; ~buildup.play; ~tom.play; ~chords.play; ~bassline.play: ~humpty.play; ~plucking1.play; ~plucking2.play; //FORK (where the sequencing (and the magic) happens) // //////to STOP A VARIABLE YOU NEED TO MAKE A PLAYER BY DOING: ~ffhf=~synthdef.play;and then ~ksahdfkhj.stop; ( { //all the global variables //4.wait; etc., ~killthis = ~beginrif.play; 2.wait; ~tomplayer = ~tom.play; 4.wait; ~kickplayer = ~kick.play; ~snareplayer = ~snare.play; 4.wait; ~hihatplayer = ~hihat.play; 8.wait; ~buildup.play; 2.wait; ~killthis.stop; ~chordsplayer = ~chords.play; ~basslineplayer = ~bassline.play; 8.wait; ~tomplayer.stop; ~snareplayer.stop; ~hihatplayer.stop; ~baselineplayer.stop; 2.wait; ~chordsplayer.stop; ~plucking1player = ~plucking1.play; 8.wait; ~plucking1player.stop; ~plucking2player = ~plucking2.play; 4.wait; ~plucking2player.stop; ~chordsplayer.play; ~tomplayer.play; ~snareplayer.play; ~hihatplayer.play; 4.wait; ~bassplayer.play; 4.wait; ~chordsplayer.stop; ~killthis.play; 4.wait; ~killthis.stop; ~bassplayer.stop; ~plucking1player.play; 8.wait; ~plucking1player.stop; ~plucking2player.play; 4.wait; ~plucking2player.stop; ~chordsplayer.play; 4.wait; ~hihatplayer.stop; ~snareplayer.stop; ~tomplayer.stop; ~kickplayer.stop; ~basslineplayer.stop; 2.wait; ~chordsplayer.stop; }.fork )