History

clip freq setting tSVF

Matthew Wang committed 6 years ago

Commit f2d7e1a1 parent d594c1a1 file · +11 −3Browse files

Unified · Split

leaf/Src/leaf-filters.c+11−3
@@ -791,8 +791,10 @@ void tSVF_initToPool (tSVF* const svff, SVFType type, float freq, float Q · 790 unmodified lines
791 svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));791 svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
792 svf->a2 = svf->g*svf->a1;792 svf->a2 = svf->g*svf->a1;
793 svf->a3 = svf->g*svf->a2;793 svf->a3 = svf->g*svf->a2;
794
794 svf->cH = 0.0f;795 svf->cH = 0.0f;
795 svf->cB = 0.0f;796 svf->cB = 0.0f;
797 svf->cBK = 0.0f;
796 svf->cL = 1.0f;798 svf->cL = 1.0f;
797 799
798 if (type == SVFTypeLowpass)800 if (type == SVFTypeLowpass)
@@ -854,6 +856,11 @@ float tSVF_tick(tSVF* const svff, float v0) · 55 unmodified lines
854 svf->ic1eq = (2.0f * v1) - svf->ic1eq;856 svf->ic1eq = (2.0f * v1) - svf->ic1eq;
855 svf->ic2eq = (2.0f * v2) - svf->ic2eq;857 svf->ic2eq = (2.0f * v2) - svf->ic2eq;
856 858
859 if (isnan(svf->ic1eq))
860 {
861 return 0.0f;
862 }
863
857 return (v0 * svf->cH) + (v1 * svf->cB) + (svf->k * v1 * svf->cBK) + (v2 * svf->cL);864 return (v0 * svf->cH) + (v1 * svf->cB) + (svf->k * v1 * svf->cBK) + (v2 * svf->cL);
858}865}
859 866
@@ -862,8 +869,8 @@ void tSVF_setFreq(tSVF* const svff, float freq) · 2 unmodified lines
862 _tSVF* svf = *svff;869 _tSVF* svf = *svff;
863 LEAF* leaf = svf->mempool->leaf;870 LEAF* leaf = svf->mempool->leaf;
864 871
865 svf->cutoff = freq;872 svf->cutoff = LEAF_clip(0.0f, freq, leaf->sampleRate * 0.5f);
866 svf->g = tanf(PI * freq * leaf->invSampleRate);873 svf->g = tanf(PI * svf->cutoff * leaf->invSampleRate);
867 svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));874 svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
868 svf->a2 = svf->g * svf->a1;875 svf->a2 = svf->g * svf->a1;
869 svf->a3 = svf->g * svf->a2;876 svf->a3 = svf->g * svf->a2;
@@ -885,8 +892,9 @@ void tSVF_setFreqAndQ(tSVF* const svff, float freq, float Q) · 15 unmodified lines
885 _tSVF* svf = *svff;892 _tSVF* svf = *svff;
886 LEAF* leaf = svf->mempool->leaf;893 LEAF* leaf = svf->mempool->leaf;
887 894
895 svf->cutoff = LEAF_clip(0.0f, freq, leaf->sampleRate * 0.5f);
888 svf->k = 1.0f/Q;896 svf->k = 1.0f/Q;
889 svf->g = tanf(PI * freq * leaf->invSampleRate);897 svf->g = tanf(PI * svf->cutoff * leaf->invSampleRate);
890 svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));898 svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
891 svf->a2 = svf->g * svf->a1;899 svf->a2 = svf->g * svf->a1;
892 svf->a3 = svf->g * svf->a2;900 svf->a3 = svf->g * svf->a2;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t