diff --git a/source/DWGUGens/dwglib/DWG.hpp b/source/DWGUGens/dwglib/DWG.hpp index bf97e865c8..c526f609ef 100644 --- a/source/DWGUGens/dwglib/DWG.hpp +++ b/source/DWGUGens/dwglib/DWG.hpp @@ -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; diff --git a/source/DWGUGens/sc/HelpSource/Classes/DWGPluckedStiff.schelp b/source/DWGUGens/sc/HelpSource/Classes/DWGPluckedStiff.schelp new file mode 100644 index 0000000000..5f90056740 --- /dev/null +++ b/source/DWGUGens/sc/HelpSource/Classes/DWGPluckedStiff.schelp @@ -0,0 +1,80 @@ +class:: DWGPluckedStiff +summary:: Plucked physical model. +categories:: UGens>PhysicalModels + + +Description:: + +Digital wave guide physical model of a plucked instrument. +It implements inharmonicity due to string stiffness acording to J. Rauhala and V. Välimäki, Tunable dispersion filter design for piano synthesis, IEEE +Signal Processing Letters, vol. 13, no. 5, pp. 253256, +2006. + +Classmethods:: + +method::ar + +argument::freq +Sound frequency. + +argument::amp +Key pulsation strenght. Betwen 0 and 1. + +argument::gate +Releases synth when value changes from >0 to 0. + +argument::pos +Relative pluck position from 0 to 1. + +argument::c1 +Inverse of DC decay time. + +argument::c3 +Hight frequency loss factor. + +argument::inp +Plucking signal. Could be first part of plucked sample for doing conmuted synthesis. + +argument::release +Release time in seconds. + +argument::fB +Inharmonicity factor. + + +Examples:: + +code:: +//Define pluck synthdef +( +SynthDef(\help_dwgpluckedstiff, { |out=0, freq=440, amp=0.5, gate=1, c3=20, pan=0,fB = 80| + var env = Env.new([0,1, 1, 0],[0.001,0.006, 0.0005],[5,-5, -8]); + var inp = amp * LFClipNoise.ar(2000) * EnvGen.ar(env,gate); + var son = DWGPluckedStiff.ar(freq, amp, gate,0.1,1,c3,inp,fB); + DetectSilence.ar(son, 0.001, doneAction:2); + Out.ar(out, Pan2.ar(son * 0.1, pan)); +}).add; +) + +//Use it. +( +a = Scale.new( + #[0, 1, 3, 5, 7, 8, 10], + 12, + Tuning.new([0, 0.75, 2, 3.5, 4, 5, 6, 7, 8, 9, 10, 11]), + "Custom" +); + +Pbind( + \instrument, \help_dwgpluckedstiff, + \scale ,a, + \delta , Pseq([1,0.5,0.5,0.5,0.5,0.5,0.5,1,0.5,0.5,1,1]*0.25,inf), + \dur , 2, + \degree, Pseq([1,8,8,8,8,8,8,-6,Prand([9,10,11],1),1,7,8]-8, inf), + \amp , Pwhite(0.2,0.8), + \c3 , Pseq([Pseq([1400],24),Pseq([300],24)],inf), + \pan , Pwhite(-1,1), + \fB , Pseq([0,80,400],inf), +).play; +) +:: diff --git a/source/OteyPianoUGens/DWG.cpp b/source/OteyPianoUGens/DWG.cpp index 6305c03bad..df32ee57a2 100644 --- a/source/OteyPianoUGens/DWG.cpp +++ b/source/OteyPianoUGens/DWG.cpp @@ -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) { diff --git a/source/OteyPianoUGens/DWG.hpp b/source/OteyPianoUGens/DWG.hpp index fbce00d5f2..70d1b232a9 100644 --- a/source/OteyPianoUGens/DWG.hpp +++ b/source/OteyPianoUGens/DWG.hpp @@ -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) { @@ -381,6 +382,7 @@ class LTITv sum -= KernelA[howmany + i]*cbufout.Buffer[i]; //sum = zapgremlins(sum); + kill_denormals(sum); cbufout.push(sum); return sum; } diff --git a/source/OteyPianoUGens/OteyPiano.cpp b/source/OteyPianoUGens/OteyPiano.cpp index dc9c2c4e9b..e781410c36 100644 --- a/source/OteyPianoUGens/OteyPiano.cpp +++ b/source/OteyPianoUGens/OteyPiano.cpp @@ -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; }