Last active
October 22, 2015 17:59
-
-
Save marcan/f59af2202514f4a9780c to your computer and use it in GitHub Desktop.
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
// Get the sample here: https://mrcn.st/t/a_duck.wav | |
// This is what it sounds like: https://soundcloud.com/marcan42/deep-duck | |
s = Server.local; | |
"SC_JACK_DEFAULT_OUTPUTS".setenv("system:playback_1,system:playback_2"); | |
s.waitForBoot({ | |
b = Buffer.read(s,"a_duck.wav"); | |
SynthDef("deepduck", { arg out=0,bufnum=0; | |
var numVoices = 15; | |
var fundamentals = ({rrand(350.0, 500.0)}!numVoices).sort.reverse; | |
var finalPitches = (numVoices.collect({|nv| (nv/(numVoices/6)).round * 12; }) + 14.5).midicps; | |
var outerEnv = EnvGen.kr(Env([0, 0.1, 1], [8, 4], [2, 4])); | |
var ampEnvelope = EnvGen.kr(Env([0, 1, 1, 0], [3, 21, 3], [2, 0, -4]), doneAction: 2); | |
var snd = Mix | |
({|numTone| | |
var initRandomFreq = fundamentals[numTone] + LFNoise2.kr(2.5, 6 * (numVoices - (numTone + 1))); | |
var destinationFreq = finalPitches[numTone] + LFNoise2.kr(0.1, (numTone / 3)); | |
var sweepEnv = | |
EnvGen.kr( | |
Env([0, rrand(0.1, 0.2), 1], [rrand(5.5, 6), rrand(8.5, 9)], | |
[rrand(2.0, 3.0), rrand(4.0, 5.0)])); | |
var freq = ((1 - sweepEnv) * initRandomFreq) + (sweepEnv * destinationFreq); | |
//var note = Saw.ar(freq); | |
var note = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum) * freq / 491.0 , 1, 0, 1) / 2.0; | |
Pan2.ar | |
( | |
//BLowPass.ar(note, freq * 11, 0.6), | |
note, | |
rrand(-0.5, 0.5), | |
(1 - (1/(numTone + 1))) * 1.5 | |
) / numVoices | |
}!numVoices); | |
Out.ar(out,Limiter.ar(BLowPass.ar(snd, 2000 + (outerEnv * 18000), 0.5, (2 + outerEnv) * ampEnvelope))); | |
//}).send(s, ["/s_new", "deepduck", -1, 1, s.asTarget.nodeID]); | |
}).play(s,[\out, 0, \bufnum, b.bufnum]); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment