[Stk] Using the STK's ADSR

Gary Scavone gary at ccrma.Stanford.EDU
Wed Mar 7 06:24:24 PST 2012


Hi Ariel,

Thanks for pointing out the documentation issues.  All times are in seconds.  The rates are in amplitude / sample.  So, if you specify a rate of 0.1, then the gain will increment by 0.1 for each sample.

--gary

On 2012-03-07, at 8:41 AM, Ariel Elkin wrote:

> 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
> 
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk




More information about the Stk mailing list