Skip to content

Instantly share code, notes, and snippets.

@bgold-cosmos
Created January 25, 2017 21:28
Show Gist options
  • Save bgold-cosmos/5787f2f12aff316d4ce3300d6fbe0a40 to your computer and use it in GitHub Desktop.
Save bgold-cosmos/5787f2f12aff316d4ce3300d6fbe0a40 to your computer and use it in GitHub Desktop.
SuperDirt synths (experimental)
(
var server = server ? Server.default;
var numChannels = ~dirt.numChannels;
var synthbuf = Buffer.alloc(server, server.sampleRate * 4, 1);
var recbuf = Array.fill(9, {|x| Buffer.alloc(server, server.sampleRate*4,1)});
SynthDef(\noop, {}).add;
// to try - square wave plus FM (bassy) with sawtooth LFO on LPF cutoff
// three octave saw detuned, pitch envelope sine LFO high cutoff filter
// put some limiters on them
SynthDef(\superwobble, {|out, sustain=1, pan, speed=1, accelerate, freq, decay=0,
pitch1=4000, lfo=0, pitch2=4|
var env = EnvGen.ar(Env.pairs([[0,0],[0.07,1],[0.2,1-decay],[0.95,1-decay],[1,0]], -1), timeScale:sustain, doneAction:2);
var basefreq = freq * Line.kr(1, 1+accelerate, sustain) * [0.99, 1.01];
var sound = LPF.ar(Pulse.ar(basefreq), basefreq*4) + Saw.ar(1.99*basefreq) + Saw.ar(3.98*basefreq);
sound = LPF.ar(sound, pitch1*Saw.kr(pitch2).exprange(1,10.0**(-2.0*lfo)));
OffsetOut.ar(out, DirtPan.ar(sound, ~dirt.numChannels, pan, env));
}).add;
// pulse?
SynthDef(\superpulse, {|out, sustain=1, pan, speed=1, accelerate, freq, decay=0, slide=1 |
var env = EnvGen.ar(Env.pairs([[0,0],[0.07,1],[0.2,1-decay],[0.95,1-decay],[1,0]], -1), timeScale:sustain, doneAction:2);
var basefreq = freq * Line.kr(1, 1+accelerate, sustain) * [0.99, 1.01];
var sound = Blip.ar(basefreq, 64) + Impulse.ar(basefreq) + Saw.ar(basefreq);
OffsetOut.ar(out, DirtPan.ar(sound, ~dirt.numChannels, pan, env));
}).add;
// recording and playback as separate synths
SynthDef(\superrec, {|out, sustain=1, n |
var sound, buf;
buf = Select.kr(n, recbuf);
sound = SoundIn.ar(0);
BufWr.ar(sound, buf, Phasor.ar(0, BufRateScale.kr(buf), 0, BufFrames.kr(buf)));
}).add;
SynthDef(\superplay, {|out, sustain=1, pan, detune=1, n |
var sound, env, buf;
buf = Select.kr(n, recbuf);
env = EnvGen.ar(Env.linen(0.05, 0.9, 0.05), timeScale:sustain, doneAction:2);
sound = BufRd.ar(1, buf, Phasor.ar(0, BufRateScale.kr(buf)*detune, 0, BufFrames.kr(buf)));
OffsetOut.ar(out, DirtPan.ar(sound, ~dirt.numChannels, pan, env));
}).add;
// more saws
// original idea - http://www.attackmagazine.com/technique/synth-secrets/detuned-pad/
SynthDef(\superzzz, {|out, sustain=1, pan, freq, detune=1 |
var sound, env, freqs, osc1, osc2;
env = EnvGen.ar(Env.linen(0.05, 0.9, 0.05), timeScale:sustain, doneAction:2);
freqs = freq * ([0, 0.01*Rand(-1,1), 0.011*Rand(-1,1), 0.015*Rand(-1,1)]*detune + 1.0);
osc1 = DelayC.ar( LFSaw.ar(freqs, Rand(0,2pi)) , 0.2, freqs.reciprocal * SinOsc.ar(Rand(3,4), Rand(0,2pi)).range(0.9,1));
osc2 = DelayC.ar( LFSaw.ar(freqs/2*Rand(0.99,1.01), Rand(0,2pi)), 0.2, freqs.reciprocal * SinOsc.ar(Rand(2,3), Rand(0,2pi)).range(0.9,1));
sound = BLowPass4.ar(osc2, SinOsc.ar(Rand(2,4)).range(800,900), 1) + osc1;
OffsetOut.ar(out, DirtPan.ar(Mix.ar(0.3*sound), ~dirt.numChannels, pan, env));
}).add;
// trying out some synth voice stuff, right now starts with 'a' and glides to vowel with formants at pitch1,pitch2 (default 'i')
SynthDef(\supervoice, {|out, sustain=1, pan, freq, pitch1=240, pitch2=2400|
var sound, env, p1, p2;
env = EnvGen.ar(Env.linen(0.1, 0.8, 0.1), timeScale:sustain, doneAction:2);
sound = Impulse.ar(freq);
p1 = XLine.kr(850, pitch1, sustain*0.5);
p2 = XLine.kr(1610, pitch2, sustain*0.5);
sound = DynKlank.ar(`[[p1, p2], nil, nil], sound, decayscale:0.01);
OffsetOut.ar(out, DirtPan.ar(sound, ~dirt.numChannels, pan, env));
}).add;
// write a signal into a delay, tap it at multiple times
SynthDef(\superbuf, {|out, sustain=1, pan, freq|
var sound, env, tapPhase, tap1, tap2, tap3;
env = EnvGen.ar(Env.perc(0.005, 1, 1, 1), timeScale:sustain, doneAction:2);
sound = Mix.ar(VarSaw.ar(freq, [0, 0.5, 1], Line.kr(0,1,sustain)));
tapPhase = DelTapWr.ar(synthbuf, sound);
#tap1, tap2, tap3 = DelTapRd.ar(synthbuf, tapPhase,
[0.1, 0.27, 0.303] * Line.kr(0.48,0.52,sustain) * 0.3 * sustain, // tap times
1, // no interp
[1.0, 0.6, 0.4] // muls for each tap
);
sound = 0.5 * Balance2.ar(sound+tap2, tap1+tap3, pan*2-1);
OffsetOut.ar(out, DirtPan.ar(sound, ~dirt.numChannels, 0.5, env, {|x| x}));
}).add;
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment