[Stk] Using the STK's ADSR

Ariel Elkin arielelkin at gmail.com
Wed Mar 7 05:41:23 PST 2012


I am having trouble using the STK's ADSR class. All I'm trying to implement is a basic envelope like this one:http://en.wikiaudio.org/File:ADSR_parameter.png on a sine wave. 

In my audio callback I have this:
   output = ( data->sine->tick() * data->adsr->tick() );

and I set up my ADSR like this:
   audioData.adsr = new ADSR();
   audioData.adsr->setValue(0);
   audioData.adsr->setAttackTime(10.0);
   audioData.adsr->setSustainLevel(0.1);
   audioData.adsr->setDecayTime(50.0);
   audioData.adsr->setReleaseTime(50.0);

When I call keyOn() on the ADSR, the tone takes much longer than 10.0ms to come, and sustains at a volume much louder than 0.1. When I call keyOff(), the tone just keeps playing…

I guess I'm having trouble understanding the online documentation for the ADSR… Are the time parameters in milliseconds, seconds, or samples? What is the decay rate in? In other words, what would be example values that would allow us to generate an envelope like the one in the image above?

Cheers

Ariel



More information about the Stk mailing list