Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class addsyn
{
ADSR env => NRev rev => Pan2 pan => dac;
( 3::second, 100::ms, .5, 3::second ) => env.set;
// an additive synth to create wavetables
fun void maketable(float root, float partials[], float amps[])
{
SinOsc s[partials.cap()];
for (0 => int j; j < partials.cap(); 1 +=> j)
{
Math.random2f(0.1,0.5) => rev.mix;
Math.random2f(-1.0,1.0) => pan.pan;
root*partials[j] => s[j].freq;
amps[j] => s[j].gain;
s[j] => env;
}
}
fun void play()
{
1 => env.keyOn;
}
fun void stop()
{
1 => env.keyOff;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.