[music-dsp] My first IIR - The vocoder works
Bram de Jong
Bram.DeJong at rug.ac.be
Wed Aug 30 11:55:06 EDT 2000
Hiya.
Someone needed an env-detector...
...
env detector with attack & release:
class CEnvFolower
{
public:
inline float GetVal(float in);
void SetParams(float attack, float release);
CEnvFolower();
virtual ~CEnvFolower();
private:
float ga,gr,tmp;
};
inline float CEnvFolower::GetVal(float in)
{
float a = in<0.f ? -in : in;
//or float a = in*in;
if(tmp < a)
tmp = ga*(tmp-a) + a;
else
tmp = gr*(tmp-a) + a;
return tmp;
}
//attack & release in millisecs
void CEnvFolower::SetParams(float attack, float release)
{
ga = (float) exp(-1/(SampleRateF*attack/1000));
gr = (float) exp(-1/(SampleRateF*release/1000));
tmp=0;
}
Oh, and by the way, everyone: PLEASE edit your mails before replying!
Edit out the parts that are no longer needed!!!!
cheers,
B.
dupswapdrop -- the music-dsp mailing list and website: subscription info,
FAQ, source code archive, list archive, book reviews, dsp links
http://shoko.calarts.edu/musicdsp/
More information about the music-dsp
mailing list