[Stk] Voicer and Release Time
Robert Gründler
doobre@gmail.com
Tue, 10 Apr 2007 13:49:52 +0200
Hi fellow list members,
as far as i've understood, when voicer receives a noteOff, it
immediately turns off the corresponding voice:
void Voicer :: noteOff( StkFloat noteNumber, StkFloat amplitude, int
channel )
{
for ( unsigned int i=0; i<voices_.size(); i++ ) {
if ( voices_[i].noteNumber == noteNumber && voices_[i].channel ==
channel ) {
voices_[i].instrument->noteOff( amplitude * ONE_OVER_128 );
voices_[i].sounding = -muteTime_;
}
}
}
Now i've written an Instrument that implements a flexible envelope,
which can have an arbitrary numbers of breakpoints
after the release of a key. The problem was, when noteOff was called,
the voice was turned off regardless of the release time.
My attempt was to modify the noteOff method and take out the line:
voices_[i].sounding = -muteTime_;
Then i've added a method to my instrument, that returns true if the last
breakpoint of the envelope is reached and the value of
that point is 0.0.
I call this method in the tick() function of voicer, and then set
"voices_[i]sounding = -muteTime_" if it returns true.
Is there a better way to achieve this ?
thanks for your help,
-robert