Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Getting Freq-y With It
name
code content
// ======================= // MUSC 115 Assigment 2 // ======================= // SynthDefs (AM and FM) // ======================= // Your name: Ian McDougall ( 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("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("am1", {arg freq = 440, modfreq = 2, amp = 0.2, att = 0.01, rel = 3; var carrier, modulator, env; env = Env.perc( attackTime: att, releaseTime: rel, level: amp ).kr(2); modulator = SinOsc.ar(modfreq).range(0, 1); carrier = SinOsc.ar(freq: freq, mul: env * modulator); Out.ar(0, carrier ! 2); }).add; SynthDef("am2", {arg freq = 440, modfreq = 2, amp = 0.2, att = 0.01, sus = 0.2, rel = 3, gate = 1, pos = 0; var carrier, modulator, env; env = Env.asr( attackTime: att, sustainLevel: sus, releaseTime: rel ).kr(doneAction: 2, gate: gate, mul: amp); modulator = SinOsc.ar(modfreq).range(0, 1); carrier = SinOsc.ar(freq: freq, mul: env * modulator); Out.ar(0, Pan2.ar(carrier, pos)); }).add; SynthDef("am3", {arg freq = 440, modfreq = 2, amp = 0.2, att = 0.01, sus = 0.2, rel = 3, gate = 1, pos = 0; var carrier, modulator, env; env = Env.asr( attackTime: att, sustainLevel: sus, releaseTime: rel ).kr(doneAction: 2, gate: gate, mul: amp); modulator = SinOsc.ar(modfreq).range(0, 1); freq = freq * LFNoise2.kr([2, 1/2, 1/3, 1/4, 1]).range(0.98, 1.01); carrier = Pulse.ar(freq: freq, mul: env * modulator); carrier = Mix.ar(carrier); carrier = LPF.ar(carrier, Line.kr(10000, 1000, att)); Out.ar(0, Pan2.ar(carrier, pos)); }).add; SynthDef("fm1", {arg freq = 440, modfreq = 5, modindex = 10, amp = 0.1, pos = 0, gate = 1, att = 0.01, rel = 0.3; var carrier, modulator, freqdev, env; // i = d/m, so d = m*i freqdev = modfreq * modindex; modulator = SinOsc.ar(freq: modfreq, mul: freqdev); carrier = SinOsc.ar(freq: freq + modulator); env = Env.asr( attackTime: att, sustainLevel: amp, releaseTime: rel ).kr(doneAction: 2, gate: gate); carrier = Pan2.ar(in: carrier, pos: pos, level: env); Out.ar(0, carrier * 0.5); }).add; SynthDef("fm2", {arg freq = 440, modindex = 10, amp = 0.1, pos = 0, gate = 1, att = 0.01, rel = 0.3; var carrier, modulator, freqdev, env, modfreq; // i = d/m, so d = m*i modindex = Line.kr(modindex, 1, att); modfreq = freq / 2; freqdev = modfreq * modindex; modulator = SinOsc.ar(freq: modfreq, mul: freqdev); carrier = SinOsc.ar(freq: freq + modulator); env = Env.asr( attackTime: att, sustainLevel: amp, releaseTime: rel ).kr(doneAction: 2, gate: gate); carrier = Pan2.ar(in: carrier, pos: pos, level: env); Out.ar(0, carrier * 0.5); }).add; ) // end of SynthDef code // ======================== // Pbind collection // // tip: to work on a Pbind separately, copy and paste it // into a new window, add .play at end for convenience // (change/listen/change again/listen again), // and when you are done, copy it back here, don't // forget to REMOVE the .play from it. // Also create your own variable names that make sense to you. // ======================== ( ~amx = Pbind( \instrument, "am1", \midinote, Pseq([80, 79, 78, 77, 76, 75, 74, 73, 72, 71,70, 69, 68, 67, 66, 65, 64, 63, 62, 61,60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50], 4), \dur, 0.2, \amp, 0.2, \att, 0.1, \rel, 4, \modfreq, Pseq([12, 9, 7, 5, 3], inf), \pos, Prand([-100, 100], inf) ); ~amy = Pbind( \instrument, "am1", \midinote, Prand([72, 79, 77, 79, 82, 79, 87, 86, 84, 82, 84, 79], 12), \ctranspose, [-24, -19], \dur, Pseq([Pn(0.1, 5), 0.2], inf), \amp, Pwhite(0.15, 0.2), \att, 0.01, \rel, 0.1, \modfreq, Pwhite(10, 30), \pos, 0 ); ~amz = Pbind( \instrument, "am1", \freq, Pseq([200, 180, 160, 140, 120, 100, 90, 80, 40], 3), \dur, Pseq([1, 1, 1, 0.5, 0.5, 0.25, 0.25, 0.15, 0.15], inf), \amp, Pseq([1, 4], inf), \att, 0.05, \rel, Pwhite(0.3, 3) ); ~amshort = Pbind( \instrument, "am1", \degree, Pseq([0, 1, 2, 3, 4], inf), \modfreq, Prand([130, 145, 200, 500, 300], inf), \amp, Pwhite(0.1, 0.4), \dur, Prand([0.2, 0.1, 0.1, 1], inf), \att, 0.01, \rel, Pkey(\dur), \pos, Pseq([-0.5, 0.5], inf) ); ~jumpy = Pbind( \instrument, "am1", \degree, Pseq([0, 2], inf), \modfreq, Pseq([1, 5, 10, 50, 100], inf), \amp, 0.4, \dur, 0.2, \att, 0.01, \rel, Pwhite(0.3, 0.5), \pos, Pwhite(-1, 1.0) ); ~burger = Pbind( \instrument, "am2", \freq, Pseq([1000, 820, 900, 1000], 8), \modfreq, Pseq([10000], inf), \amp, Pseq([0.5, 0.5, 0.5, 0.5, 0.7, 0.7, 0.7, 0.9, 0.9, 0.9, 1, 1, 1, 1],inf), \dur, 0.2, \att, 0, \rel, Pseq([1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,3,3, 3, 3, 3,3],inf), \pos, Pseq([-50, -25, -20, 20, 25, 50], inf) ); ~harmonics = Pbind( \instrument, "am2", \freq, Pseries(100, 50, 20), \modfreq, Pseq([1, 500, 10, 50, 100], inf), \amp, 0.2, \att, 0.02, \rel, 4, \pos, Pwhite(-1, 1), \dur, 0.1 ); ~amak = Pbind( \instrument, "am3", \midinote, Prand([72, 79, 77, 79, 82, 79, 87, 86, 84, 82, 84, 79], inf), \ctranspose, -12, \dur, Pseq([Pn(0.5, 5), Prand([1.5, 3])], inf), \amp, Pwhite(0.15, 0.5), \att, Pwhite(0.5, 1), \rel, Pwhite(1, 3.0), \modfreq, Pseq([7, 9, 10, 11], inf) ); ~amik = Pbind( \instrument, "am3", \freq, Prand([ [100, 105, 108], [220, 225, 230], [100, 110, 115], [200, 220, 225], ], 8), \dur, Pseq([1, 2, 2, 1], inf), \amp, 0.5, \att, 0, \rel, 0.8, \modfreq, Pseq([100], inf), \pos, Pseq([-0.5, 0, 0.5], inf) ); ~fmuh = Pbind( \instrument, "fm2", \dur, 1, \degree, Pseq([0, 4, 5, 6], 8), \modindex, Pseq([5, 6, 7, 10], inf), \amp, 0.1, \att, Pwhite(0.1, 0.3), \rel, Pwhite(1, 3.0), \pos, Pwhite(-1, 1.0) ); ~fmwow = Pbind( \instrument, "fm1", \dur, 0.2, \freq, Pseq([120, 240, 360, 480], 12), \modfreq, Pseq([1, 2, 4, 8], 8), \modindex, 1, // \amp, Pseq([0.3, 0.4, 0.6, 0.8], inf), \att, 0.5, \rel, 3, ); ~fmclouds = Pbind( \instrument, "fm2", \dur, Prand([1, 2, 0.5], inf), \freq, Pseq([120, 240, 80], 8), \modindex, Prand([900, 1000],inf), \amp, 0.01, \att, Pwhite(1, 4), \rel, Pseq([100, 20, 40,60,100],inf), \pos, 0 ); ~fmbass = Pbind( \instrument, "fm2", \dur, Pwhite(0.27, 0.275), \note, Pseq([ Pseq([0, 4, 7, 9, Prand([10, 12]), 9, 7, 4], 2), // I Pseq([0, 4, 7, 9, 10, 9, 7, 4], 1) + 5, // IV Pseq([0, 4, 7, 9, 10, 9, 7, 4], 1), // I 7, 11, 14, 11, 7, 5, 4, 2 // V ], inf), \ctranspose, -12, \modindex, Pseq([ 6, 7, 8, 9, 20, 9, 8, 4, 1 ], inf), \amp, Pseq([0.3, 0.35, 0.4, 0.45, 0.5, 0.45, 0.4, 0.3, 0.2], inf), \att, 0.01, \rel, 0.2, \pos, 0 ); ~fmletsdothis = Pbind( \instrument, "fm2", \dur, Pseq([1],inf), \freq, Pseq([80, 140, 100], 4), \ctranspose, 12, \modindex, Pseq([1, 5, 6, 7, 10], inf), \amp, 0.8, \att, 0.01, \rel, Pwhite(1, 2.0), \pos, 0 ); ~kick = Pbind( \instrument, "kick", \dur, Pseq([1/2, Rest(1/2), 1/2, Rest(1/2), 1/3, 1/3, 1/3, 1/2, Rest(1/2), 1/2, Rest(1/2)], inf), \att, 0.01, \rel, 0.22, \sinfreq, 60, \glissf, 0.9, \amp, 2, ); ~snare = Pbind( \instrument, "snare", \dur, Pseq([1/3, Rest(1/3), 1/3, 1, 1, 1], 4), \att, 0.01, \rel, Pseq([0.1,0.1, 0.1, 0.75, 0.75, 0.75], 4), \sinfreq, 180, \ffreq, 200, \amp, 0.1 ); ~hihat= Pbind( \instrument, "hihat", \dur, Pseq([Rest(2.5), 1/2, 1/8, 1/8, Rest(1/2)], 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 ); ~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, ); ) // end of Pbind collection // ============= // Double check your the Pbinds (listen) // Remember: some of them are inf, others are finite // you can adjust that by changing the Pbinds // ============= ~amx.play; //exfiles - good for melody ~amy.play; //good for background ~amz.play; //good for beginning ~amshort.play; //weird jittering stuff ~jumpy.play; //melodic stuff ~burger.play; //also melodic ~harmonics.play; //harmonics ~amak.play; //melodic maybe could be cool bass ~amik.play; //chordy stuff, midlevel ~fmbass.play; //pretty basic bass ~fmclouds.play; //cloudy chordy ~fmuh.play; //pretty basic notes ~fmwow.play; //weird glisandoing stuff ~fmletsdothis.play; //cool melody with bass accompaniement ~snare.play; ~kick.play; ~hihat.play; // ============= // COMPOSITION // ============= // Build your sequence here // you can use either {}.fork or Pspawner // see Pspawner help file. ( Pspawner({arg maestro; ~kickplayer = maestro.par(~kick); maestro.seq(Ppar([~amz])); maestro.par(Ppar([~snare, ~hihat])); maestro.wait(1); maestro.seq(~buildup); maestro.seq(~fmletsdothis); maestro.seq(Ppar([~fmwow, ~amik])); maestro.wait(1); maestro.seq(~buildup); maestro.seq(Ppar([~fmletsdothis, ~burger])); maestro.seq(Ppar([~fmclouds, ~amx])); maestro.suspendAll; }).play; )
code description
Assignment 2 for MUSC 115 https://soundcloud.com/user-68447368/getting-freq-y-with-it-115modulations
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change