shithub: leaf

Download patch

ref: ae6880a654ac3f83b542e17b6b83a0a0888a767f
parent: 8733f5cc1504c08044c19f7d6c4f0dce6d39c349
author: Jeff Snyder <jeff@snyderphonics.com>
date: Mon Aug 5 12:47:31 EDT 2019

added fir

--- a/LEAF/Inc/leaf-filter.h
+++ b/LEAF/Inc/leaf-filter.h
@@ -289,7 +289,24 @@
 void        tButterworth_setFreqs   (tButterworth* const, float f1, float f2);
 
 //==============================================================================
-    
+    
+#define NUM_TAPS 29
+typedef struct _tFIR
+{
+    float past[NUM_TAPS];
+
+    float* coeff;
+
+} tFIR;
+
+void        tFIR_init       (tFIR* const, float* coeffs);
+void        tFIR_free       (tFIR* const);
+
+float       tFIR_tick       (tFIR* const, float input);
+void        tFIR_coeffs      (tFIR* const, float in);
+
+//==============================================================================
+
 #ifdef __cplusplus
 }
 #endif
--- a/LEAF/Src/leaf-filter.c
+++ b/LEAF/Src/leaf-filter.c
@@ -819,3 +819,18 @@
     
     return 0;
 }
+
+void	tFIR_init(tFIR* const fir, float* coeffs){
+	fir->coeff = coeffs;
+	for (int i = 0; i < NUM_TAPS; ++i) fir->past[i] = 0.0f;
+}
+
+float	tFIR_tick(tFIR* const fir, float input){
+	fir->past[0] = input;
+	float y = 0.0f;
+	for (int i = 0; i < NUM_TAPS; ++i) y += fir->past[i]*fir->coeff[i];
+	for (int i = NUM_TAPS-1; i > 0; --i) fir->past[i] = fir->past[i-1];
+	return y;
+}
+
+void	tFIR_free(tFIR* const fir){}