50 lines
786 B
Plaintext
50 lines
786 B
Plaintext
#ifndef _VST_DECAY_HPP_
|
|
#define _VST_DECAY_HPP_
|
|
|
|
class Decay
|
|
{
|
|
public:
|
|
Decay(int samples,float factor=.0016);
|
|
virtual ~Decay();
|
|
float operator[](int sample);
|
|
private:
|
|
void createDecay(void);
|
|
int mSamples;
|
|
float mSeed;
|
|
float *mDecays;
|
|
};
|
|
|
|
inline
|
|
Decay::Decay(int samples,float factor)
|
|
: mSamples(samples), mSeed(factor), mDecays(0)
|
|
{
|
|
createDecay();
|
|
}
|
|
|
|
inline
|
|
Decay::~Decay()
|
|
{
|
|
if(!mDecays)return;
|
|
::delete[] mDecays;
|
|
mDecays=0;
|
|
}
|
|
|
|
inline
|
|
float Decay::operator[](int sample)
|
|
{
|
|
return mDecays[sample];
|
|
}
|
|
|
|
inline
|
|
void Decay::createDecay()
|
|
{
|
|
if(mDecays)::delete[] mDecays;
|
|
mDecays=new float[mSamples];
|
|
for(int index=0;index<mSamples;index++)
|
|
{
|
|
if(!index)mDecays[index]=(float)(1.00-mSeed);
|
|
else mDecays[index]=(float)((1.00-mSeed)*mDecays[index-1]);
|
|
}
|
|
}
|
|
#endif
|