Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: FINAL SCRATCH2
name
code content
//SYNTH DEFS ( 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("fm2", {arg freq = 440, modindex = 10, amp = 0.1, pos = 0, gate = 1, att = 0.01, rel = 0.01; 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 = WhiteNoise.ar(freq: modfreq, mul: freqdev); carrier = Saw.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("fm3", {arg freq = 440, modindex = 10, amp = 0.1, pos = 0, gate = 1, att = 0.01, rel = 0.01; 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 = Pulse.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; ) //PBINDS ( ~amshort = Pbind( \instrument, "am1", \degree, Pseq([ [0, 2, 4, 6], 3, [7, 9, 14], 9 ], inf), \modfreq, 1, \amp, Pwhite(0.05, 0.2), \dur, 4, \att, 0.01, \pos, Pseq([-0.5, 0.5], inf) ); ~amshort.play; ) ( ~amshort2 = Pbind( \instrument, "am1", \degree, Pseq([-12, \rest, -4, \rest], inf), \modfreq, Pseq([3, \rest, 0, \rest], inf), \amp, Pwhite(0.1, 0.4), \dur, Pseq([1, Rest(1/2), 1, Rest(1/2)], inf), \att, 0.01, \pos, Pseq([-0.5, 0.5], inf) ); ~amshort2.play; ) ~fmnoise = Pbind( \instrument, "fm2", \dur, 128, \mtranspose,[0, 3, 7], \modindex, Pwhite(0.00, 1.00), \amp, 0.1, \att, 8, \rel, 24, ); ~fmclouds2 = Pbind( \instrument, "fm3", \degree, [0, 7, 12, 14], \dur, 0.5, \modindex, Pwhite(0.00, 0.00), \amp, Pwhite(0.052, 0.240), \att, 0.01, \rel, Pwhite(0.01, 0.06), \pos, Pwhite(-0.30, 0.30) ); ) ) //QUICK PLAY ~amshort.play; ~amshort2.play; ~fmnoise.play; ~fmclouds2.play; //SAMPLING ( ~buf1 = Buffer.readChannel(s, "/Users/benbates/Desktop/Ahh.wav", channels: [0]); SynthDef("1", {arg rate = 1, amp = 1, buffer, startPos = 0, attack = 0.02, release = 0.5, panning = 0; var snd, env; env = Env.perc(attackTime: attack, releaseTime: release, level: amp).kr(doneAction: 2); snd = PlayBuf.ar( numChannels: 1, bufnum: ~buf1, rate: rate, startPos: startPos.linlin(0, 1, 0, BufFrames.kr(buffer)) ); snd = snd * env; snd = Pan2.ar(snd, panning); Out.ar(0, snd); }).add; SynthDef("1b", {arg rate = 1, amp = 1, buffer, startPos = 0, attack = 0.02, release = 0.5, panning = 0, gate = 1; var snd, env; env = Env.asr( attackTime: attack, sustainLevel: amp, releaseTime: release ).kr(doneAction: 2, gate: gate); snd = PlayBuf.ar( numChannels: 1, bufnum: ~buf1, rate: 1.05946.pow(rate), startPos: startPos.linlin(0, 1, 0, BufFrames.kr(buffer)) ); snd = snd * env; snd = Pan2.ar(snd, panning); Out.ar(0, snd); }).add; SynthDef("1c", {arg rate = 1, amp = 1, buffer, startPos = 0, attack = 0.02, release = 0.5, panning = 0, gate = 1, lagTime = 0.1, mix = 0.5; var snd, env; env = Env.asr( attackTime: attack, sustainLevel: amp, releaseTime: release ).kr(doneAction: 2, gate: gate); snd = PlayBuf.ar( numChannels: 1, bufnum: ~buf1, rate: Lag.kr(in: 1.05946.pow(rate), lagTime: lagTime), startPos: startPos.linlin(0, 1, 0, BufFrames.kr(buffer)), loop: 1 ); snd = snd * env; snd = FreeVerb.ar( in: snd, mix: Lag.kr(mix), room: 0.8, damp: 0.8 ); snd = Pan2.ar(snd, panning); Out.ar(0, snd); }).add; ); ~buf1.play; ~buf1.duration; s. ( ~ahhMONO = Pmono( "1c", \rate, Pseq([ [0, 3, 7], [-3, -9, 5], [0, 4, 10], [-1, 5, 6, 8], [-9, -5, 6, 10] ], inf), \dur, 2, \amp, Pwhite(0.120, 0.190), \attack, Pwhite(0.1500, 0.1700), \release, 3, \startPos, Pwhite(0.1, 0.5), \lagTime, Pseq([0.1, 1], inf), \mix, Pwhite(0.3, 0.8) ); ~ahhMONO.trace.play; ) ( ~ahhB = Pbind( \instrument, "1b", \rate, Pseq([ [0, 3, 7], [-3, -9, 5], [6, 8, 10], ], inf), \dur, 1, \amp, Pwhite(0.120, 0.190), \attack, Pwhite(0.1500, 0.1700), \release, 0.3, \legato, 1.2, \startPos, Pwhite(0.1, 0.5) ); ~ahhB.play; ) ( ~ahh = Pbind( \instrument, "1", \degree, [0, 3, 5], \dur, 8, \amp, Pwhite(0.120, 0.190), \attack, Pwhite(0.500, 0.700), \release, 6, //Pwhite(0.100, 0.200), ); ~ahh.play; ) ( ~buf2 = Buffer.readChannel(s, "/Users/benbates/Desktop/Ooh.wav", channels: [0]); SynthDef("2", {arg rate = 1, amp = 1, buffer, startPos = 0, attack = 1, release = 0.5, panning = 0; var snd, env; env = Env.perc(attackTime: attack, releaseTime: release, level: amp).kr(doneAction: 2); snd = PlayBuf.ar( numChannels: 1, bufnum: ~buf2, rate: rate, startPos: startPos.linlin(0, 1, 0, BufFrames.kr(buffer)) ); snd = snd * env; snd = Pan2.ar(snd, panning); Out.ar(0, snd); }).add; ~ahh = Pbind( \instrument, "2", \degree, [0, 3, 5], \dur, 4, \amp, Pwhite(0.120, 0.190), \attack, Pwhite(0.500, 0.700), \release, Pwhite(0.100, 0.200), ); ~ooh.play; )
code description
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