algoforte03a/lib/01-sdefs.scd

463 lines
13 KiB
Plaintext

// -----------------------------------------------------------------------
// recorders
SynthDef(\recBufMono, {
arg bufnum = 0, loop = 0, in=0;
RecordBuf.ar( SoundIn.ar(in),
bufnum, doneAction: Done.freeSelf, loop: loop);
}).add;
SynthDef(\recBufStereo, {
arg bufnum = 0, loop = 0;
RecordBuf.ar( SoundIn.ar([0,1]),
bufnum, doneAction: Done.freeSelf, loop: loop);
}).add;
// ex:
// Synth(\recBufMono, [\bufnum, ~pBufMono1], addAction: \addToTail);
// Synth(\recBufStereo, [\bufnum, ~pBuf1], addAction: \addToTail);
// sound generators and players //
SynthDef("gran",
{
arg out = 0, buffer = 0, amp = 1, gate = 1, atk = 10, rls = 10;
var snd = GrainBuf.ar(2,
trigger: Impulse.ar(LFNoise1.kr(1/10!3).exprange(80, 180)
* LFNoise0.ar(100).range(0.7,1.1)),
dur: LFNoise1.ar(1).range(0.08,0.1),
//sndbuf: ~pBufMono1,
sndbuf: buffer,
//rate:[1,1/2,1/4],
rate:[1,1/2,1/4,2],
pos:LFNoise1.kr(1/20!3).range(0,1),
pan: LFNoise0.ar(100).range(-1,1)
);
snd = LPF.ar(snd, LFNoise1.kr(1/10!3).exprange(500,10000));
snd = Splay.ar(snd);
snd = Limiter.ar(snd, 0.8);
snd = snd * LFPulse.kr(8).range(LFNoise1.kr(1/5).range(0.3,1),1);
snd = snd * EnvGen.ar(Env.asr( atk, 1, rls, \sqr ), gate, doneAction: Done.freeSelf);
snd = snd * Lag3.kr(amp, 10);
Out.ar(out, snd);
}
).add;
SynthDef("smpPlay",
{
arg out = 0, gate = 1, amp = 0.6, pan = 0, rls = 0.01,
bufnum = 0, rate = 1, spos = 0, lpffreq=18000, hpffreq=20;
var snd, env;
env = EnvGen.ar(Env.cutoff(rls), gate, doneAction: Done.freeSelf);
snd = PlayBuf.ar(1, bufnum, rate, gate, spos * SampleRate.ir );
snd = LPF.ar(snd, lpffreq);
snd = HPF.ar(snd, hpffreq);
snd = Pan2.ar(snd, pan);
Out.ar(out, snd * amp);
}
).add;
// darksaw // ------------------------------------------------------
// "--- dark saw synthdef...".postln;
SynthDef(\softSaw,
{
arg out = 0, freq = 40, oscdetune = 0.1, amp = 1, pan = 0,
gate = 1, attackTime = 0.1, susLevel = 1.0, releaseTime = 1.0, gainBus;
var env, snd;
oscdetune = oscdetune * 0.1;
amp = amp * 0.4;
env = Linen.kr(gate, attackTime, susLevel, releaseTime, doneAction:2);
snd = VarSaw.ar(
freq: [freq, freq * (1.003 + oscdetune)],
width: SinOsc.kr(0.01,0.2).range(0.05,0.095));
snd = snd + VarSaw.ar(
freq: [(freq*2 * (1.001 - oscdetune)),(freq*2 * (1 + oscdetune))],
width: SinOsc.kr(0.06,0.8).range(0.2,0.8));
snd = Balance2.ar(snd.at(0), snd.at(1), pos: pan);
snd = snd * amp * env ;
OffsetOut.ar(out, snd);
}
).add;
SynthDef(\akjPad,
{
arg freq=300, amp=0.1, out=0, gate=1, atk=2, rls=2;
var snd, env, cutoff;
cutoff = freq * 5;
freq = [freq,freq*1.01];
freq = freq * SinOsc.kr([4.333,8], mul:0.005, add:1);
snd = LFPar.ar(freq) * 0.3
+ (LFTri.ar(freq, mul:0.3))
+ (Pulse.ar(freq, mul:2))
+ (SinOsc.ar(freq, mul:4).clip2(0.3));
snd = snd.clip2(0.9);
snd = snd * LFPulse.kr(LFNoise1.kr(1/8).range(2,20)).range(0.6,1);
snd = snd * LFPulse.kr(LFNoise0.kr(1/8).range(2,20)).range(0.6,1);
snd = RLPF.ar( snd,
freq: cutoff * SinOsc.ar([0.3,0.4]).range(0.8,1.2),
rq: SinOsc.ar([0.4,0.3]).range(0.5,0.2) );
snd = snd + CombC.ar(snd,
delaytime: SinOsc.kr(1/25, [0, pi/2]).range(0.1,0.2),
mul:0.6);
env = EnvGen.kr( Env([0,1,0], [atk, rls], \cub, 1 ), gate, doneAction:2);
snd = Splay.ar(snd);
snd = snd * env * amp;
Out.ar(out, snd);
}
).add;
// a pretty good synth, once reworked.
// upgraded from SCLOrkSynths/.../SynthDefs/pads/sawSynth.scd
SynthDef("sawSquareSynth",
{
arg out = 0, freq = 200, amp = 0.1,
att = 0.1, rel = 2, gate = 1, pan = 0,
cutoff = 1, ssratio = 0.5;
var env, snd, loff, hiff;
cutoff = (freq * cutoff).max(40).min(20000);
env = EnvGen.kr(Env.asr(
attackTime: att,
sustainLevel: amp,
releaseTime: rel), gate, doneAction: 2);
snd = Saw.ar(freq: freq * [0.99, 1, 1.001, 1.008], mul: env * ssratio);
snd = snd + Pulse.ar(freq: freq * [1, 0.985, 1.007, 1.002], mul: env * (ssratio.neg + 1));
snd = LPF.ar(
in: snd,
freq: cutoff );
snd = Mix.ar(snd) * 0.2;
snd = Pan2.ar(snd, pan);
Out.ar(out, snd);
}).add;
SynthDef(\padVib,
{
arg
//Standard Values:
out = 0, pan = 0, freq = 400, amp = 0.5, att = 0.4, dec = 0.5, sus = 0.8, rel = 1.0, gate = 1,
//Other Controls:
vibratoRate = 4, vibratoDepth = 0.01, tremoloRate = 8,
//These controls go from 0 to 1:
tremoloDepth = 0.5, reverbMix = 0.5, roomSize = 1, damp = 0.5;
var env, snd, vibrato, tremolo, mod2, mod3;
env = Env.adsr(att, dec, sus, rel).kr(gate: gate);
vibrato = SinOsc.kr(vibratoRate).range(freq * (1 - vibratoDepth), freq * (1 + vibratoDepth));
tremolo = LFNoise2.kr(1).range(0.2, 1) * SinOsc.kr(tremoloRate).range((1 - tremoloDepth), 1);
snd = SinOsc.ar(freq: [freq, vibrato], mul:(env * tremolo * amp)).distort;
snd = Mix.ar([snd]);
//snd = FreeVerb.ar(snd, reverbMix, roomSize, damp);
DetectSilence.ar(snd, 0.0001, 0.2, doneAction: 2);
Out.ar(out, Pan2.ar(snd, pan));
},
metadata:(
credit: "Mike Hairston",
tags: [\pad, \vibrato, \sustained]
)
).add;
SynthDef(\fm5,
{
arg f=10, i=0.1, gate=1, freq=120, amp=0.1, out=0,
atk=0.01, dec=0.1, sus=0.5, rls=5;
var c, m, d, snd;
c = freq;
m = c * f;
d = m / i;
snd = SinOsc.ar( c + SinOsc.ar(m, mul: d) );
snd = LPF.ar(snd, 18000);
snd = snd * EnvGen.ar(Env.adsr(atk, dec, sus, rls, curve:-10), gate, doneAction:2);
Out.ar(out, snd!2 * amp * 3);
}
).add;
SynthDef(\pulseTriSaw,
{
arg out = 0, freq=440, gate=1, amp=0.1, pan = 0, sawamp = 0.1,
atk = 0.01, dec = 0.1, sus = 0.5, rls = 0.3, lpf=1 ;
var snd;
freq = freq * SinOsc.kr(4).range(0.998,1.002);
snd = Pulse.ar(freq) + LFTri.ar(freq / Rand(1.99,2.01))
+ Saw.ar(freq * Rand(1.99,2.01), mul:sawamp);
lpf = (freq * lpf).min(20000).max(40);
snd = LPF.ar(snd, lpf);
snd = [snd, DelayN.ar(snd, 0.1, 0.009)];
snd = snd * EnvGen.kr(Env.adsr(atk, dec, sus, rls), gate, doneAction:Done.freeSelf);
snd = snd * amp * 0.1;
snd = Balance2.ar(snd[0], snd[1], pan);
Out.ar(out, snd);
}
).add;
SynthDef(\triSinSquare,
{
arg outBus = 0, freq=440, gate=1, amp=0.1, pan = 0,
atk = 0.01, dec = 0.1, sus = 0.5, rls = 0.3,
sqamp = 0.1, lpf=1 ;
var snd;
freq = freq * SinOsc.kr(4).range(0.998,1.001);
snd = LFTri.ar(freq)
+ SinOsc.ar(freq * Rand(1.99,2.01))
+ Pulse.ar(freq / Rand(1.99,2.01), mul:sqamp);
lpf = (freq * lpf).min(20000).max(40);
snd = LPF.ar(snd, lpf);
snd = [snd, DelayN.ar(snd, 0.1, 0.001)];
snd = snd * EnvGen.kr(
Env.adsr(atk, dec, sus, rls),
gate, doneAction:Done.freeSelf);
snd = snd * amp * 0.5;
snd = Balance2.ar(snd[0], snd[1], pan);
Out.ar(outBus, snd);
}
).add;
SynthDef(\akjBaz,
{
arg freq=300, amp=0.1, out=0, gate=1,
rls=0.01, atk=0.01, cutoff=10, rq=0.5;
var snd, env;
snd = SinOsc.ar(freq, [0, pi/2.5], mul:0.7);
snd = snd * Lag.ar(LFPulse.ar(freq/2.005, 0.5).range(1,0),0.005);
snd = snd.softclip(0.5) * 1.5 ;
snd = RLPF.ar(snd, cutoff * freq, rq );
env = Linen.kr(gate, atk, amp, rls, 2);
snd = snd * env;
Splay.ar(snd);
Out.ar(out, snd);
}
).add;
SynthDef(\akjClick,
{
arg out=0, gate=1, freq=440, amp=0.1, releaseTime=0.1;
var snd, env;
snd = LFPulse.ar([freq, freq * 2], width: LFNoise1.ar(0.1).exprange(0.001,0.004));
snd = snd + (WhiteNoise.ar(1) * snd);
snd = HPF.ar(snd, 200);
env = EnvGen.ar(Env.perc(0,releaseTime));
snd = snd * env * amp * Linen.kr(gate, 0, 1, releaseTime, 2);
snd = Splay.ar(snd);
Out.ar(out, snd);
}
).add;
SynthDef(\dusty,
{
arg out = 0, amp = 0.1, gate = 1, pan = 0,
atk = 0.1, rls = 0.1, density = 10;
var snd, env;
snd = Dust2.ar(density);
env = EnvGen.ar(Env.asr(atk, amp, rls), gate, doneAction:2);
snd = Pan2.ar(snd * env, pan);
Out.ar(out, snd);
}
).add;
SynthDef( \dustyPinkClip,
{
arg out = 0, amp = 0.7, gate = 1, pan = 0,
atk = 0.1, rls = 0.1,
density = 10, maxrls = 0.2;
var dust, env, snd;
dust = Dust2.ar(density);
env = EnvGen.ar(Env.asr(atk, amp, rls), gate, doneAction:2);
snd = PinkNoise.ar + ClipNoise.ar(0.3);
snd = snd * EnvGen.ar(
Env.perc(0, LFNoise0.kr(10).exprange(0.0001, 0.2)), dust);
snd = HPF.ar(snd, LFNoise0.kr(10!2).exprange(100,500));
snd = LPF.ar(snd, LFNoise0.kr(10!2).exprange(500,15000));
snd = Pan2.ar(snd[0], LFNoise0.kr(5).range(-1,1))
+ Pan2.ar(snd[1], LFNoise0.kr(5).range(-1,1));
snd = Balance2.ar(snd[0], snd[1], pan);
snd = snd * env;
Out.ar(out, snd);
}
).add;
SynthDef(\clipyPerc,
{
arg out = 0, amp = 0.7, gate = 1, pan = 0,
hpf = 40, lpf = 18000,
atk = 0, rls = 0.1;
var snd, env;
hpf = hpf.max(40);
lpf = lpf.min(20000);
env = EnvGen.ar(Env.linen(0, rls, 0, amp, -4), gate);
snd = ClipNoise.ar(0.5) + WhiteNoise.ar(0.5);
snd = HPF.ar(snd, hpf);
snd = LPF.ar(snd, lpf);
snd = Pan2.ar(snd * env, pan);
Linen.kr(gate,0,1,0,2); // kill
Out.ar(out, snd);
}
).add;
// -----------------------------------------------------------------------
// FX synthdefs //
// reverb synthdef
SynthDef(\fxGverb,
{
arg in, out = 0, amp = 1,
dry = 1, early = 0.1, tail = 0.7, room = 100, decay = 3;
var snd, rev;
snd = In.ar(in, 2);
snd = HPF.ar(snd, 100);
rev = GVerb.ar(snd, room, decay,
drylevel: dry, earlyreflevel: early, taillevel: tail);
Out.ar(out, rev * amp);
}
).add;
// reverb synthdef
SynthDef(\fxJPverb,
{
arg in, out = 0, wet = 0.5, decay = 3, size = 1;
var snd, rev;
snd = In.ar(in, 2);
snd = HPF.ar(snd, 100);
//rev = Greyhole.ar(snd, size: size, feedback: feedback) ;
rev = JPverb.ar(snd, decay, size: size) ;
rev = rev * wet;
Out.ar(out, snd + rev);
}
).add;
// feedback delay w/ bandpass filter + stereo rotation
SynthDef(\fxFeedDelay,
{
arg in, out = 0, feedback = 0.9, time = 1, amount = 0.5;
var snd, input, local;
time = time * {Rand(0.5,1.0)}.dup;
time = time.min(2).max(0.01);
input = In.ar(in,2);
local = LocalIn.ar(2) * feedback;
local = BPF.ar(local, LFNoise1.kr(0.6).range(450,2000), LFNoise1.kr(0.1).range(0.8,1));
local = Rotate2.ar(local[0], local[1], 0.23);
local = AllpassN.ar(local, 1, time, 2);
//local = DelayN.ar(local, 0.3, [0.26,0.19]);
//local = AllpassN.ar(local, 0.05, {Rand(0.03,0.15)}.dup, 2);
local = LeakDC.ar(local);
local = local + input;
LocalOut.ar(local);
Out.ar(out, local * amount + input);
}
).add;
// delay wrangler
SynthDef(\fxDelayWarp,
{
arg out=0, in, wet=0.1;
var snd, dly2;
snd = In.ar(in, 2);
dly2 = CombN.ar(HPF.ar(snd,300), 1, [0.5,0.77], 5, mul:LFNoise1.kr(0.1).range(0.8,0.3));
snd = CombN.ar(snd, 1, Lag.ar(LFNoise0.ar(1/3).range(0.01,0.1),0.1), 3, mul:wet) + snd;
snd = Decimator.ar(snd, LFNoise1.kr(1).range(8000,22000), 0.2, 1.5) + (snd*0.5);
snd = AnalogTape.ar(snd, 1, 1);
snd = Compander.ar(
snd, snd,
thresh: 0.9,
slopeBelow: 1,
slopeAbove: 0.01,
clampTime: 0.01,
relaxTime: 0.01);
snd = BHiShelf.ar(snd, 3000, 0.2, 5);
Out.ar(out, snd);
}
).add;
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////