Last active
November 11, 2019 21:07
-
-
Save madskjeldgaard/86aa4d7992a86313ba3e69cfc1d48cf2 to your computer and use it in GitHub Desktop.
notes from sc meetup november 11th 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Crazy chaotic notes from SuperCollider meetup november 11th 2019 at Notam | |
| waaaa | |
| */ | |
| // Change default synth: https://www.madskjeldgaard.dk/how-to-change-the-default-synth-in-supercollider/ | |
| // Pbindf + Pkey | |
| ( | |
| Pdef(\henrik, | |
| Pbind( | |
| \dur, 0.25, | |
| \degree, Pwhite(0,10), | |
| \cutoff, 0.5 | |
| ) | |
| ).play(quant:1); | |
| Pdef(\harald, | |
| Pbindf( | |
| Pdef(\henrik), | |
| \dur, 0.125, | |
| \degree, 1 + Pkey(\degree) | |
| ) | |
| ).play(quant:1); | |
| ) | |
| // Pdefn + Pseg = Envelopes in patterns | |
| ( | |
| Pdef(\mike, | |
| Pbind( | |
| \dur, 0.1, | |
| \freq, Pseg([7500,Pwhite(100,10000,1),250], Pwhite(0.01,1), \exp, inf), | |
| \release, Pseg([0.1,2.0], 4, \lin, inf), | |
| \cutoff, Pdefn(\hellooo, 2500) | |
| ) | |
| ).play; | |
| Pdef(\mike2nd, | |
| Pbind( | |
| \dur, 0.5, | |
| \freq, Pseg([7500,Pwhite(100,10000,1),250], Pwhite(0.01,1), \exp, inf), | |
| \release, Pseg([0.1,2.0], 4, \lin, inf), | |
| \cutoff, Pdefn(\hellooo, 2500) | |
| ) | |
| ).play | |
| ) | |
| // Changing the tempo of the default clock | |
| TempoClock.default.tempo_(1) | |
| // Sharing data between patterns | |
| ( | |
| Pdef(\share, | |
| Plambda( | |
| Ppar([ | |
| // First pattern, contains special data that will be shared with other patterns | |
| Pbind( | |
| \dur, Plet(\dur1, Prand([1.5, 0.25, 0.75, 1],inf)), // Plet defines a variable containing a pattern | |
| \degree, Pseq([0,4,5],inf) | |
| ), | |
| // Second pattern, receiving data from first pattern (wtf, wow!) | |
| Pbind( | |
| \dur, 2 * Pget(\dur1, default: 1, repeats: inf), // Pget receives that value | |
| \octave, 4, | |
| \degree, Pseq([0,4,5],inf) | |
| ), | |
| // Third pattern, receiving data from first pattern (wtf, wow!) | |
| Pbind( | |
| \dur, 0.5 * Pget(\dur1, default: 1, repeats: inf), // Pget receives that value | |
| \octave, 6, | |
| \degree, Pseq([0,4,5],inf) | |
| ) | |
| ]) | |
| ) | |
| ).play; | |
| ) | |
| /**** BEGIN CHRISTTMAS TRAPPP ***/ | |
| // Weird drum synths from Renick Bell / SOS | |
| ( | |
| SynthDef(\SOSkick, | |
| { arg out = 0, freq = 50, mod_freq = 5, mod_index = 5, sustain = 0.4, amp = 0.8, beater_noise_level = 0.025; | |
| var pitch_contour, drum_osc, drum_lpf, drum_env; | |
| var beater_source, beater_hpf, beater_lpf, lpf_cutoff_contour, beater_env; | |
| var kick_mix; | |
| pitch_contour = Line.kr(freq*2, freq, 0.02); | |
| drum_osc = PMOsc.ar( pitch_contour, | |
| mod_freq, | |
| mod_index/1.3, | |
| mul: 1, | |
| add: 0); | |
| drum_lpf = LPF.ar(in: drum_osc, freq: 1000, mul: 1, add: 0); | |
| drum_env = drum_lpf * EnvGen.ar(Env.perc(0.005, sustain), 1.0, doneAction: 2); | |
| beater_source = WhiteNoise.ar(beater_noise_level); | |
| beater_hpf = HPF.ar(in: beater_source, freq: 500, mul: 1, add: 0); | |
| lpf_cutoff_contour = Line.kr(6000, 500, 0.03); | |
| beater_lpf = LPF.ar(in: beater_hpf, freq: lpf_cutoff_contour, mul: 1, add: 0); | |
| beater_env = beater_lpf * EnvGen.ar(Env.perc, 1.0, doneAction: 2); | |
| kick_mix = Mix.new([drum_env, beater_env]) * 2 * amp; | |
| Out.ar(out, [kick_mix, kick_mix]) | |
| } | |
| ).add; | |
| SynthDef(\SOSsnare, | |
| {arg out = 0, sustain = 0.1, drum_mode_level = 0.25, | |
| snare_level = 40, snare_tightness = 1000, | |
| freq = 405, amp = 0.8; | |
| var drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc, drum_mode_mix, drum_mode_env; | |
| var snare_noise, snare_brf_1, snare_brf_2, snare_brf_3, snare_brf_4, snare_reson; | |
| var snare_env; | |
| var snare_drum_mix; | |
| drum_mode_env = EnvGen.ar(Env.perc(0.005, sustain), 1.0, doneAction: 2); | |
| drum_mode_sin_1 = SinOsc.ar(freq*0.53, 0, drum_mode_env * 0.5); | |
| drum_mode_sin_2 = SinOsc.ar(freq, 0, drum_mode_env * 0.5); | |
| drum_mode_pmosc = PMOsc.ar( Saw.ar(freq*0.85), | |
| 184, | |
| 0.5/1.3, | |
| mul: drum_mode_env*5, | |
| add: 0); | |
| drum_mode_mix = Mix.new([drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc]) * drum_mode_level; | |
| // choose either noise source below | |
| // snare_noise = Crackle.ar(2.01, 1); | |
| snare_noise = LFNoise0.ar(20000, 0.1); | |
| snare_env = EnvGen.ar(Env.perc(0.005, sustain), 1.0, doneAction: 2); | |
| snare_brf_1 = BRF.ar(in: snare_noise, freq: 8000, mul: 0.5, rq: 0.1); | |
| snare_brf_2 = BRF.ar(in: snare_brf_1, freq: 5000, mul: 0.5, rq: 0.1); | |
| snare_brf_3 = BRF.ar(in: snare_brf_2, freq: 3600, mul: 0.5, rq: 0.1); | |
| snare_brf_4 = BRF.ar(in: snare_brf_3, freq: 2000, mul: snare_env, rq: 0.0001); | |
| snare_reson = Resonz.ar(snare_brf_4, snare_tightness, mul: snare_level) ; | |
| snare_drum_mix = Mix.new([drum_mode_mix, snare_reson]) * 5 * amp; | |
| Out.ar(out, [snare_drum_mix, snare_drum_mix]) | |
| } | |
| ).add; | |
| SynthDef(\SOShats, | |
| {arg out = 0, freq = 6000, sustain = 0.1, amp = 0.8; | |
| var root_cymbal, root_cymbal_square, root_cymbal_pmosc; | |
| var initial_bpf_contour, initial_bpf, initial_env; | |
| var body_hpf, body_env; | |
| var cymbal_mix; | |
| root_cymbal_square = Pulse.ar(freq, 0.5, mul: 1); | |
| root_cymbal_pmosc = PMOsc.ar(root_cymbal_square, | |
| [freq*1.34, freq*2.405, freq*3.09, freq*1.309], | |
| [310/1.3, 26/0.5, 11/3.4, 0.72772], | |
| mul: 1, | |
| add: 0); | |
| root_cymbal = Mix.new(root_cymbal_pmosc); | |
| initial_bpf_contour = Line.kr(15000, 9000, 0.1); | |
| initial_env = EnvGen.ar(Env.perc(0.005, 0.1), 1.0); | |
| initial_bpf = BPF.ar(root_cymbal, initial_bpf_contour, mul:initial_env); | |
| body_env = EnvGen.ar(Env.perc(0.005, sustain, 1, -2), 1.0, doneAction: 2); | |
| body_hpf = HPF.ar(in: root_cymbal, freq: Line.kr(9000, 12000, sustain),mul: body_env, add: 0); | |
| cymbal_mix = Mix.new([initial_bpf, body_hpf]) * amp; | |
| Out.ar(out, [cymbal_mix, cymbal_mix]) | |
| } | |
| ).add; | |
| SynthDef(\SOStom, | |
| {arg out = 0, sustain = 0.4, drum_mode_level = 0.25, | |
| freq = 90, drum_timbre = 1.0, amp = 0.8; | |
| var drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc, drum_mode_mix, drum_mode_env; | |
| var stick_noise, stick_env; | |
| var drum_reson, tom_mix; | |
| drum_mode_env = EnvGen.ar(Env.perc(0.005, sustain), 1.0, doneAction: 2); | |
| drum_mode_sin_1 = SinOsc.ar(freq*0.8, 0, drum_mode_env * 0.5); | |
| drum_mode_sin_2 = SinOsc.ar(freq, 0, drum_mode_env * 0.5); | |
| drum_mode_pmosc = PMOsc.ar( Saw.ar(freq*0.9), | |
| freq*0.85, | |
| drum_timbre/1.3, | |
| mul: drum_mode_env*5, | |
| add: 0); | |
| drum_mode_mix = Mix.new([drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc]) * drum_mode_level; | |
| stick_noise = Crackle.ar(2.01, 1); | |
| stick_env = EnvGen.ar(Env.perc(0.005, 0.01), 1.0) * 3; | |
| tom_mix = Mix.new([drum_mode_mix, stick_env]) * 2 * amp; | |
| Out.ar(out, [tom_mix, tom_mix]) | |
| } | |
| ).add; | |
| // Swing thing from the help files (Pattern cookbook) | |
| ~swingify = Prout({ |ev| | |
| var now, nextTime = 0, thisShouldSwing, nextShouldSwing = false, adjust; | |
| while { ev.notNil } { | |
| // current time is what was "next" last time | |
| now = nextTime; | |
| nextTime = now + ev.delta; | |
| thisShouldSwing = nextShouldSwing; | |
| nextShouldSwing = ((nextTime absdif: nextTime.round(ev[\swingBase])) <= (ev[\swingThreshold] ? 0)) and: { | |
| (nextTime / ev[\swingBase]).round.asInteger.odd | |
| }; | |
| adjust = ev[\swingBase] * ev[\swingAmount]; | |
| // an odd number here means we're on an off-beat | |
| if(thisShouldSwing) { | |
| ev[\timingOffset] = (ev[\timingOffset] ? 0) + adjust; | |
| // if next note will not swing, this note needs to be shortened | |
| if(nextShouldSwing.not) { | |
| ev[\sustain] = ev.use { ~sustain.value } - adjust; | |
| }; | |
| } { | |
| // if next note will swing, this note needs to be lengthened | |
| if(nextShouldSwing) { | |
| ev[\sustain] = ev.use { ~sustain.value } + adjust; | |
| }; | |
| }; | |
| ev = ev.yield; | |
| }; | |
| } | |
| ); | |
| ) | |
| // Change the tempo clock manually | |
| TempoClock.default.tempo_(0.75) | |
| // Sharing data between patterns to make fucked up hip hop | |
| ( | |
| Pdef(\share, | |
| Pchain(~swingify, | |
| Plambda( | |
| Ppar([ | |
| Pbind(\dur, 8, \play, Pfunc({ "New tempo:".postln; TempoClock.default.tempo = rrand(0.25,1.0).postln })), | |
| // First pattern, contains special data that will be shared with other patterns | |
| Pbind( | |
| \instrument, \SOSkick, | |
| \freq, Pwrand([60, 80], [0.75, 0.25], inf), | |
| \mod_freq, 1, | |
| \amp, 0.5, | |
| \dur, Plet(\dur1, Prand([1, Rest(0.25), 0.25, 2, 0.5],inf)), // Plet defines a variable containing a pattern | |
| ), | |
| // Second pattern, receiving data from first pattern (wtf, wow!) | |
| Pbind( | |
| \instrument, \SOShats, | |
| \sustain, Pseg([1.5,1], 4, \exp, inf), | |
| \freq, Pkey(\sustain) * 1000 + 100, | |
| \dur, 0.125 * Pget(\dur1, default: 1, repeats: inf), // Pget receives that value | |
| ), | |
| // Third pattern, receiving data from first pattern (wtf, wow!) | |
| Pbind( | |
| \instrument, \SOSsnare, | |
| \freq, 805, | |
| \drum_mode_level, 0.75, | |
| \snare_tightness, 3000, | |
| \snare_level, Pseg([40,200], 16, \exp, inf), | |
| \dur, 0.5 * Pget(\dur1, default: 1, repeats: inf), // Pget receives that value | |
| \amp, 0.05 | |
| ) | |
| ]) | |
| ), (swingBase: 0.25, swingAmount: 0.2) | |
| ) | |
| ).play; | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment