Last active
August 29, 2015 14:01
-
-
Save brianfay/c0650fbcfdfed3872e50 to your computer and use it in GitHub Desktop.
Drooooooone
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
( | |
SynthDef(\sineGrain, {|out, freq=440, sustain=0.02, amp=0.1, pan| | |
var wavetable = Buffer.alloc(s, 512, 1, { |buf| buf.chebyMsg([1,0,1,1,0,1])}); | |
var env = EnvGen.ar(Env.sine(sustain, amp), doneAction: 2); | |
var sound = SinOsc.ar(freq) * env; | |
sound = Shaper.ar(wavetable, sound) * 0.1; | |
Out.ar(out, Pan2.ar(sound, LFNoise1.kr(40, 2, -1))) | |
}).add; | |
SynthDef(\verb, { arg outBus = 0, inBus; | |
var input; | |
input = In.ar(inBus, 1); | |
// a low-rent reverb | |
// aNumber.do will evaluate its function argument a corresponding number of times | |
// {}.dup(n) will evaluate the function n times, and return an Array of the results | |
// The default for n is 2, so this makes a stereo reverb | |
16.do({ input = AllpassC.ar(input, 0.04, { Rand(0.001,0.04) }.dup, 3)}); | |
Out.ar(outBus, input); | |
}).add; | |
) | |
//FX STUFF: | |
( | |
b = Bus.audio(s,2); | |
~verb = Synth.new(\verb, [\inBus, b]); | |
) | |
//SEQUENCING STUFF: | |
( | |
//closure to make a counter, because even though there is probably an easier way of doing this, this is pretty cool. | |
//the counter will control the amplitude, which in turn determines the level of distortion in the waveshaper | |
//counter goes up and down | |
var counterMaker = { arg maxCount; | |
Routine({ | |
var val = 0 - (maxCount * 0.5); | |
maxCount.do{ | |
val = val + 1; | |
//(val.abs - (maxCount * 0.5)).abs.postln; | |
(val.abs - (maxCount * 0.5)).abs.yield; //somehow it took me an age and a half to come up with this line. | |
}; | |
});}; | |
//closure that returns a new taskDiskOut.ar() | |
var taskMaker = { arg maxCount, rootFreq; | |
var ampCounter = counterMaker.(maxCount); | |
Task({ | |
maxCount.do({ | |
var sustain = (1..500).choose * 0.001; | |
var dur = (1..30).choose * 0.001; | |
var freq = (1..6).choose * rootFreq; | |
var amp = ampCounter.next; | |
amp = amp + 1; | |
amp = amp * 0.001; | |
//Synth(\sineGrain, [\freq, freq, \sustain, sustain, \amp, amp, \out, b]); | |
Synth.before(~verb, \sineGrain, [\freq, freq, \sustain, sustain, \amp, amp, \out, b]); | |
dur.wait; | |
}) | |
});}; | |
//this is supposed to return a task that plays back drones in octaves - each new one has a duration | |
//at a golden ratio to the previous drone. | |
var goldenRatioAscending = {arg rootNote, numOctaves; Task({ | |
var baseDur = rrand(900, 2000); | |
var phiDur = baseDur; | |
numOctaves.do{arg i; | |
var droneTask = taskMaker.(phiDur.postln, (rootNote+(i * 12)).midicps); | |
phiDur = (0.61803398875.pow(i+1)*baseDur); | |
droneTask.start; | |
(phiDur*0.001).wait; | |
}; | |
});}; | |
//Try descending rather than ascending | |
var goldenRatioDescending = {arg upperNote, numOctaves; Task({ | |
var baseDur = rrand(300, 900); | |
var phiDur = baseDur; | |
numOctaves.do{arg i; | |
var droneTask = taskMaker.(phiDur.postln, (upperNote-(i * 12)).midicps); | |
phiDur = (1.61803398875.pow(i+1)*baseDur); | |
droneTask.start; | |
(phiDur*0.001).wait; | |
}; | |
});}; | |
var metaTask = Task({ | |
inf.do{ | |
var task; | |
if([false, true].choose, | |
{task = goldenRatioAscending.([20,27].choose,(1..4).choose)}, | |
{task = goldenRatioDescending.([56, 63].choose,(1..4).choose)} | |
); | |
task.start; | |
(6..10).choose.wait; | |
} | |
}); | |
metaTask.start; | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment