[Stk] Ramping with ADSR
Ariel Elkin
arielelkin at gmail.com
Mon Sep 17 07:39:33 PDT 2012
Hi all,
I would like to have a sine wave's frequency smoothly go from 0 to 400 over 10 seconds.
I've tried implementing that with a function that updates the wave's frequency every 20 milliseconds, but there are audible bumps in the sound. So I need something that can create a smoother ramp, and I thought of ADSR.
But I noticed that calling ADSR::keyOn() automatically sets the attack target to 1.0, and I want it to be an arbitrary value (400.0 in my case). So I added the function below to ADSR:
void ADSR:: keyTo( StkFloat target )
{
target_ = target;
state_ = ATTACK;
}
Here's how I setup my ADSR object:
audioData.adsr = new ADSR();
audioData.adsr->setValue(0);
audioData.adsr->setAttackTime(10);
audioData.adsr->setDecayTime(1);
audioData.adsr->setReleaseTime(1);
I've then been calling ADSR::lastOut() every 500ms to check its value, and I notice that it goes from 0.0 to about 1.5 in the first 10 seconds. Can anybody see why? Is it possible/a good idea to implement a ramp with ADSR?
Cheers
Ariel
More information about the Stk
mailing list