Skip to content

Commit

Permalink
OteyPiano: add kill_denormals, correction of templated ThirianDispersion
Browse files Browse the repository at this point in the history
  • Loading branch information
sonoro1234 committed Jun 13, 2014
1 parent 991cead commit 1b4ab3f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/DWGUGens/dwglib/DWG.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ struct ThirianDispersion{

float freq;
float B;
ThirianT<2> dispersion[4];
ThirianT<2> dispersion[M];
void setcoeffs(float freq,float B){
if(B==0){
this->B = 0.0;
Expand Down
8 changes: 8 additions & 0 deletions source/OteyPianoUGens/DWG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ void volcar(const char *_Message, const char *_File, unsigned _Line)
{
Print("assertion %s ,%s:%d\n",_Message,_File,_Line);
}

void kill_denormals(float &val)
{
static const float anti_denormal = 1e-18;
val += anti_denormal;
val -= anti_denormal;
}

float ValimakiDispersion(float B, float f, int M) {
float C1,C2,k1,k2,k3;
if(M==4) {
Expand Down
2 changes: 2 additions & 0 deletions source/OteyPianoUGens/DWG.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void volcar(const char *_Message, const char *_File, unsigned _Line);
void classname##_Ctor(classname* unit){new(unit) classname(unit);}\
void classname##_Dtor(classname* unit){unit->~classname();}

void kill_denormals(float &val);

inline bool approximatelyEqual(float a, float b, float epsilon = 1e-7f)
{
Expand Down Expand Up @@ -381,6 +382,7 @@ class LTITv
sum -= KernelA[howmany + i]*cbufout.Buffer[i];

//sum = zapgremlins(sum);
kill_denormals(sum);
cbufout.push(sum);
return sum;
}
Expand Down
2 changes: 2 additions & 0 deletions source/OteyPianoUGens/OteyPiano.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ float DWGReverb :: reverb(float in)
for(int j=0;j<8;j++) {
delay[j].push(i[j]);
o[j] = decay[j].filter(delay[j].delay(lengths[j]));
kill_denormals(o[j]);
//o[j] = zapgremlins(o[j]);
out += c[j] * o[j]*.5;
}

Expand Down

0 comments on commit 1b4ab3f

Please sign in to comment.