Skip to content

Instantly share code, notes, and snippets.

@unclewalter
Last active August 29, 2015 14:23
Show Gist options
  • Save unclewalter/96cf5774f923821e6c02 to your computer and use it in GitHub Desktop.
Save unclewalter/96cf5774f923821e6c02 to your computer and use it in GitHub Desktop.
// Select all and press shift-return
s = Server.local;
s.meter;
s.waitForBoot({
// Instantiate variables to hold tasks for this scope.
var masterSequence;
// Runs the following task once the server is booted
Task {
// Loads SynthDefs
SynthDef(
"chime",
{
|
baseFreq = 40,
freqSpread = 0.2,
len = 0.5,
oct = 4
|
var sig, freq, env;
freq = 40*pow(2,(IRand(0, (25*oct))/24));
env = EnvGen.kr(Env.perc(attackTime: 0.01, releaseTime: len), 1, doneAction:2);
sig = LFSaw.ar(freq*IRand(1, 10))*ExpRand(0.01, 0.7);
6.do {
sig = LFSaw.ar((LinRand(0.8, 1.2)*freq*IRand(1, 10)))*ExpRand(0.01, 0.7) + sig;
};
sig = env * sig;
sig = sig * SinOsc.kr(LinRand(1, 100));
Out.ar(IRand(5, 6), sig);
}).add;
SynthDef(
"pad",
{
|
attack = 4,
release = 8,
level = 0.4,
lowerBound = 400,
upperBound = 567
|
var sig, env;
sig = SinOsc.ar(ExpRand(lowerBound, upperBound), mul: 0.3);
5.do {
sig = sig + SinOsc.ar(LinRand(lowerBound, upperBound), mul: 0.3);
};
env = EnvGen.kr(Env.new([0,1,1,0],[attack,1,release],[1,0,-1]),doneAction:2);
sig = sig * env * level;
sig = sig!2;
Out.ar(5, sig);
}).add;
SynthDef(
"fx",
{
|
freq=1200,
res=1,
mul=1,
mix=0.5,
room=0.9
|
var sig;
sig = In.ar(5, 2);
sig = BLowPass4.ar(sig, freq, res, mul);
sig = sig * 0.5;
sig = FreeVerb.ar(sig, mix, room);
Out.ar(0, sig);
}).add;
// Loads all SynthDefs before continuing
s.sync;
// Patterns
~chimes = Pbind(
\instrument, "chime",
\dur, Pdefn(\chimesDur, Pwhite(0, 1.5, inf)),
\baseFreq, Pdefn(\chimesBaseFreq, 20),
\freqSpread, Pdefn(\chimesFreqSpread, 0.2),
\len, Pdefn(\chimesLen, Pwhite(0.05, 3, inf)),
\oct, Pdefn(\chimesOct, 4)
);
~pad = Pbind(
\instrument, "pad",
\dur, Pdefn(\padDur, Pseq([1], 1)),
\attack, Pdefn(\padAttack, 17),
\release, Pdefn(\padRelease, 8),
\level, Pdefn(\padLevel, 0.4),
\lowerBound, Pdefn(\padLowerBound, 400),
\upperBound, Pdefn(\padUpperBound, 567)
);
// Single Task to organize Patterns chronologically
masterSequence = Task({
// Activate effects.
~seqFx = Synth.new(\fx);
~seqFx.set(
\freq, 200,
\res, 1,
\mul, 1,
\mix, 0.8,
\room, 0.9
);
0.1.wait;
~pad.play;
20.wait;
~chimes.play;
5.wait;
~pad.play;
6.wait;
~seqFx.set(
\freq, 18000,
\res, 120,
\mix, 0.3
);
Pdefn(\chimesDur, Pwhite(0, 0.01, inf));
Pdefn(\chimesBaseFreq, 1000);
Pdefn(\chimesFreqSpread, 0.2);
Pdefn(\chimesLen, Pwhite(0.05, 0.3, inf));
3.wait;
~seqFx.set(
\freq, 200,
\res, 1,
\mix, 0.9,
);
Pdefn(\chimesDur, Pwhite(0, 3, inf));
Pdefn(\chimesBaseFreq, 50);
10.wait;
Pdefn(\padAttack, 4);
Pdefn(\padRelease, 0.1);
Pdefn(\padLevel, 0.7);
~pad.play;
4.wait;
~seqFx.set(
\freq, 10000,
\res, 50,
\mix, 0.7,
);
Pdefn(\chimesDur, Pwhite(0, 0.1, inf));
Pdefn(\chimesBaseFreq, 400);
Pdefn(\chimesFreqSpread, 0.6);
Pdefn(\chimesLen, Pwhite(0.01, 0.04, inf));
Pdefn(\padAttack, 10);
Pdefn(\padRelease, 15);
Pdefn(\padLevel, 0.5);
~pad.play;
3.wait;
~seqFx.set(
\freq, 200,
\res, 1,
\mix, 0.9,
);
Pdefn(\chimesDur, Pwhite(0, 3, inf));
Pdefn(\chimesFreqSpread, 0.2);
Pdefn(\chimesBaseFreq, 50);
Pdefn(\padAttack, 10);
Pdefn(\padRelease, 15);
Pdefn(\padLevel, 0.5);
~pad.play;
6.wait;
~seqFx.set(
\freq, 8000,
\res, 50,
\mix, 0.3
);
Pdefn(\chimesDur, Pwhite(0, 0.01, inf));
Pdefn(\chimesBaseFreq, 1000);
Pdefn(\chimesFreqSpread, 0.2);
Pdefn(\chimesLen, Pwhite(0.05, 0.3, inf));
3.wait;
~pad.play;
~seqFx.set(
\freq, 200,
\res, 1,
\mix, 0.9,
);
Pdefn(\chimesDur, Pwhite(0, 3, inf));
Pdefn(\chimesBaseFreq, 50);
25.wait;
// B SECT
~seqFx.set(
\freq, 800,
\res, 1,
\mix, 0.6,
);
Pdefn(\padAttack, 30);
Pdefn(\padRelease, 25);
Pdefn(\padLevel, 0.03);
~pad.play;
0.1.wait;
Pdefn(\chimesDur, Pseq([1],1));
Pdefn(\padLowerBound, 4000);
Pdefn(\padUpperBound, 5067);
Pdefn(\padLevel, 0.9);
Pdefn(\padAttack, 0.5);
Pdefn(\padRelease, 0.04);
Pdefn(\padDur, Pseq([2,2.7,2,2,1.7,2,2,2.2,1.9],inf));
~pad.play;
23.wait;
Pdefn(\chimesFreqSpread, 0.8);
Pdefn(\chimesBaseFreq, 500);
~chimes.play();
Pdefn(\padLowerBound, 3000);
Pdefn(\padUpperBound, 4000);
~pad.play;
23.wait;
Pdefn(\chimesFreqSpread, 0.8);
Pdefn(\chimesBaseFreq, 4000);
~chimes.play();
Pdefn(\padDur, Pseq([0.1],1));
Pdefn(\padLowerBound, 80);
Pdefn(\padUpperBound, 120);
Pdefn(\padAttack, 20);
Pdefn(\padRelease, 25);
Pdefn(\padLevel, 0.7);
~pad.play;
0.1.wait;
Pdefn(\padLowerBound, 2000);
Pdefn(\padUpperBound, 3000);
Pdefn(\padAttack, 0.5);
Pdefn(\padRelease, 0.04);
Pdefn(\padDur, Pseq([2,2.7,2,2,1.7,2,2,2.2,1.9],inf));
~pad.play;
23.wait;
Pdefn(\chimesFreqSpread, 0.9);
Pdefn(\chimesBaseFreq, 10);
~chimes.play();
Pdefn(\padLowerBound, 1000);
Pdefn(\padUpperBound, 2000);
~pad.play;
10.wait;
// A SECT
Pdefn(\chimesDur, Pwhite(0, 1.5, inf));
Pdefn(\chimesBaseFreq, 20);
Pdefn(\chimesFreqSpread, 0.2);
Pdefn(\chimesLen, Pwhite(0.05, 3, inf));
Pdefn(\chimesOct, 4);
Pdefn(\padDur, Pseq([1], 1));
Pdefn(\padAttack, 17);
Pdefn(\padRelease, 8);
Pdefn(\padLevel, 0.4);
Pdefn(\padLowerBound, 400);
Pdefn(\padUpperBound, 567);
~seqFx.set(
\freq, 200,
\res, 1,
\mul, 1,
\mix, 0.8,
\room, 0.9
);
~chimes.play();
10.wait;
~pad.play;
6.wait;
~seqFx.set(
\freq, 15000,
\res, 50
);
Pdefn(\chimesDur, Pwhite(0, 0.01, inf));
Pdefn(\chimesBaseFreq, 2000);
Pdefn(\chimesFreqSpread, 0.5);
Pdefn(\chimesLen, Pwhite(0.01, 0.05, inf));
10.wait;
~seqFx.set(
\freq, 200,
\res, 1,
\mix, 0.9,
);
Pdefn(\chimesDur, Pwhite(0, 3, inf));
Pdefn(\chimesBaseFreq, 50);
10.wait;
Pdefn(\padAttack, 4);
Pdefn(\padRelease, 0.1);
Pdefn(\padLevel, 0.7);
~pad.play;
4.wait;
~seqFx.set(
\freq, 10000,
\res, 50,
\mix, 0.7,
);
Pdefn(\chimesDur, Pwhite(0, 0.1, inf));
Pdefn(\chimesBaseFreq, 400);
Pdefn(\chimesFreqSpread, 0.6);
Pdefn(\chimesLen, Pwhite(0.01, 0.04, inf));
Pdefn(\padAttack, 10);
Pdefn(\padRelease, 15);
Pdefn(\padLevel, 0.5);
~pad.play;
3.wait;
~seqFx.set(
\freq, 200,
\res, 1,
\mix, 0.9,
);
Pdefn(\chimesDur, Pseq([2,2.7,2,2,1.7,2,2,2.2,1.9],inf));
Pdefn(\chimesFreqSpread, 0.05);
Pdefn(\chimesBaseFreq, 100);
~chimes.play;
Pdefn(\padAttack, 10);
Pdefn(\padRelease, 35);
Pdefn(\padLevel, 0.5);
~pad.play;
45.wait;
Pdefn(\chimesDur, Pseq([1], 1));
Pdefn(\chimesBaseFreq, 10);
Pdefn(\chimesFreqSpread, 0.005);
Pdefn(\chimesLen, 10);
10.wait;
"uhh".postln;
//free all synths on server
s.freeAll;
//stop Task
masterSequence.stop;
});
1.wait;
//start the piece
masterSequence.start;
}.start;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment