Skip to content

Commit

Permalink
Improved normalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
jngpng authored and LFSaw committed May 24, 2013
1 parent 5aaa1dd commit 2db2a59
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/DEINDUGens/complexRes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void ComplexRes_Ctor(ComplexRes* unit)
unit->mX = 0.0; // First state (real part)
unit->mY = 0.0; // Second state (imaginary part)
unit->mFreq = 10;
unit->mNormCoeff = 1/(2*(1-unit->mRes));
unit->mNormCoeff = unit->mRes/(1.0-unit->mRes*unit->mRes);
unit->mcoeffX = unit->mRes * cos(TWOPI * unit->mFreq / SAMPLERATE);
unit->mcoeffY = unit->mRes * sin(TWOPI * unit->mFreq / SAMPLERATE);

Expand Down Expand Up @@ -80,7 +80,7 @@ void ComplexRes_next_a(ComplexRes *unit, int inNumSamples)

if (decay != unit->mDecay){
res = exp(-1.0/(decay*SAMPLERATE));
normCoeff = 1/(2*(1-res));
normCoeff = res/(1.0-res*res);
unit->mDecay = decay;
unit->mRes = res;
unit->mNormCoeff = normCoeff;
Expand Down Expand Up @@ -130,7 +130,7 @@ void ComplexRes_next_k(ComplexRes *unit, int inNumSamples)

if (decay != unit->mDecay || freq != unit->mFreq){
res = exp(-1.0/(decay*SAMPLERATE));
normCoeff = 1/(2*(1-res));
normCoeff = res/(1.0-res*res);
ang = freq * TWOPI / SAMPLERATE;
coeffX = res*cos(ang);
coeffY = res*sin(ang);
Expand Down

0 comments on commit 2db2a59

Please sign in to comment.