Version 4.2.0

This commit is contained in:
Gary Scavone
2009-03-24 23:02:14 -04:00
committed by Stephen Sinclair
parent cf06b7598b
commit a6381b9d38
281 changed files with 17152 additions and 12000 deletions

View File

@@ -9,19 +9,18 @@
\e keyOff messages, ramping to 1.0 on
keyOn and to 0.0 on keyOff.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#include "Envelope.h"
#include <stdio.h>
Envelope :: Envelope(void) : Stk()
Envelope :: Envelope(void) : Generator()
{
target = (MY_FLOAT) 0.0;
value = (MY_FLOAT) 0.0;
rate = (MY_FLOAT) 0.001;
state = 0;
target_ = 0.0;
value_ = 0.0;
rate_ = 0.001;
state_ = 0;
}
Envelope :: ~Envelope(void)
@@ -30,85 +29,85 @@ Envelope :: ~Envelope(void)
void Envelope :: keyOn(void)
{
target = (MY_FLOAT) 1.0;
if (value != target) state = 1;
target_ = 1.0;
if (value_ != target_) state_ = 1;
}
void Envelope :: keyOff(void)
{
target = (MY_FLOAT) 0.0;
if (value != target) state = 1;
target_ = 0.0;
if (value_ != target_) state_ = 1;
}
void Envelope :: setRate(MY_FLOAT aRate)
void Envelope :: setRate(StkFloat rate)
{
if (aRate < 0.0) {
printf("Envelope: negative rates not allowed ... correcting!\n");
rate = -aRate;
if (rate < 0.0) {
errorString_ << "Envelope::setRate: negative rates not allowed ... correcting!";
handleError( StkError::WARNING );
rate_ = -rate;
}
else
rate = aRate;
rate_ = rate;
}
void Envelope :: setTime(MY_FLOAT aTime)
void Envelope :: setTime(StkFloat time)
{
if (aTime < 0.0) {
printf("Envelope: negative times not allowed ... correcting!\n");
rate = 1.0 / (-aTime * Stk::sampleRate());
if (time < 0.0) {
errorString_ << "Envelope::setTime: negative times not allowed ... correcting!";
handleError( StkError::WARNING );
rate_ = 1.0 / (-time * Stk::sampleRate());
}
else
rate = 1.0 / (aTime * Stk::sampleRate());
rate_ = 1.0 / (time * Stk::sampleRate());
}
void Envelope :: setTarget(MY_FLOAT aTarget)
void Envelope :: setTarget(StkFloat target)
{
target = aTarget;
if (value != target) state = 1;
target_ = target;
if (value_ != target_) state_ = 1;
}
void Envelope :: setValue(MY_FLOAT aValue)
void Envelope :: setValue(StkFloat value)
{
state = 0;
target = aValue;
value = aValue;
state_ = 0;
target_ = value;
value_ = value;
}
int Envelope :: getState(void) const
{
return state;
return state_;
}
MY_FLOAT Envelope :: tick(void)
StkFloat Envelope :: tick(void)
{
if (state) {
if (target > value) {
value += rate;
if (value >= target) {
value = target;
state = 0;
if (state_) {
if (target_ > value_) {
value_ += rate_;
if (value_ >= target_) {
value_ = target_;
state_ = 0;
}
}
else {
value -= rate;
if (value <= target) {
value = target;
state = 0;
value_ -= rate_;
if (value_ <= target_) {
value_ = target_;
state_ = 0;
}
}
}
return value;
lastOutput_ = value_;
return value_;
}
MY_FLOAT *Envelope :: tick(MY_FLOAT *vector, unsigned int vectorSize)
StkFloat *Envelope :: tick(StkFloat *vector, unsigned int vectorSize)
{
for (unsigned int i=0; i<vectorSize; i++)
vector[i] = tick();
return vector;
return Generator::tick( vector, vectorSize );
}
MY_FLOAT Envelope :: lastOut(void) const
StkFrames& Envelope :: tick( StkFrames& frames, unsigned int channel )
{
return value;
return Generator::tick( frames, channel );
}