[Stk] Voicer and Release Time
Stephen Sinclair
sinclair@music.mcgill.ca
Tue, 10 Apr 2007 11:38:25 -0400
Sounds fine to me, just remember that you can't really check for =0.0
when using floating point values. Always check < 0.0001 or something
similar.
Another approach might be to count the number of ticks from the noteOff,
and mute the voice when the release time has expired, instead of
checking the value of the envelope.
Keep in mind that you can always use the ADSR class for your envelope
instead of rolling your own. If you want an exponential envelope, Asymp
is pretty good too.
Steve
Robert Gründler wrote:
> 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
>
>
>
>
> _______________________________________________
> Stk mailing list
> Stk@ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk