Created
August 18, 2013 17:46
-
-
Save andrewcsmith/6262946 to your computer and use it in GitHub Desktop.
Random envelope selection
This file contains 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(\cloudin, { | |
arg freq = 440, env_input = 0; | |
var signal, envs; | |
// env_input is the number of the control-rate channel with the env signal | |
signal = Saw.ar(400 * 1) * In.kr(env_input); | |
Out.ar(0, signal); | |
}).add; | |
) | |
( | |
SynthDef(\envSine, { | |
// the output of the env must be the same as the input to the synthdef | |
arg out = 0; | |
Out.kr(out, EnvGen.kr(Env.sine(1), levelScale: 0.5, doneAction:2)); | |
}).add; | |
) | |
( | |
SynthDef(\envHard, { | |
arg out = 0; | |
Out.kr(out, EnvGen.kr(Env.new([0.6, 1, 0.9, 0], [0.2, 0.6, 2], [-5, 0, -5]), levelScale: 0.5, timeScale: 1, doneAction:2)); | |
}).add; | |
) | |
x = Synth(\cloudin, [\env_input, 64]); | |
// the x.get(\env_input) gets the current \env_input value for the \cloudin Synth | |
( | |
x.get(\env_input, { | |
arg value; | |
var env_array = [\envSine, \envHard]; | |
Synth.after(x, env_array[2.rand], [\out, value]); | |
}); | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment