ref: 3ae7064aeb7485aed70048f8dc622282a5012a0c
parent: 6db1777c89302524bdbec4c0e909d3c93ab76523
author: Matthew Wang <mjw7@princeton.edu>
date: Tue Jun 29 12:25:11 EDT 2021
svf setFreqAndQ
--- a/leaf/Inc/leaf-filters.h
+++ b/leaf/Inc/leaf-filters.h
@@ -722,6 +722,7 @@
float tEfficientSVF_tick (tEfficientSVF* const, float v0);
void tEfficientSVF_setFreq (tEfficientSVF* const, uint16_t controlFreq);
void tEfficientSVF_setQ (tEfficientSVF* const, float Q);
+ void tEfficientSVF_setFreqAndQ (tEfficientSVF* const, uint16_t controlFreq, float Q);
//==============================================================================
--- a/leaf/Src/leaf-filters.c
+++ b/leaf/Src/leaf-filters.c
@@ -995,6 +995,17 @@
svf->a2 = svf->g * svf->a1;
svf->a3 = svf->g * svf->a2;
}
+
+void tEfficientSVF_setFreqAndQ (tEfficientSVF* const svff, uint16_t input, float Q)
+{
+ _tEfficientSVF* svf = *svff;
+
+ svf->g = __leaf_table_filtertan[input];
+ svf->k = 1.0f/Q;
+ svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
+ svf->a2 = svf->g * svf->a1;
+ svf->a3 = svf->g * svf->a2;
+}
#endif // LEAF_INCLUDE_FILTERTAN_TABLE
/* Highpass */