From 702117e4d7fc669ec4c4a273a6bdc9d8c6f7a231 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Tue, 25 Mar 2025 17:27:59 +0100 Subject: [PATCH] damn it --- .vscode/.server-controller-port.log | 2 +- lib/filters.c | 29 ----------------------------- lib/filters.h | 10 +--------- src/fm95.c | 6 ------ 4 files changed, 2 insertions(+), 45 deletions(-) diff --git a/.vscode/.server-controller-port.log b/.vscode/.server-controller-port.log index bc13603..082c432 100644 --- a/.vscode/.server-controller-port.log +++ b/.vscode/.server-controller-port.log @@ -1,5 +1,5 @@ { "port": 13452, - "time": 1742842256267, + "time": 1742920067458, "version": "0.0.3" } \ No newline at end of file diff --git a/lib/filters.c b/lib/filters.c index ed1017c..f8fe011 100644 --- a/lib/filters.c +++ b/lib/filters.c @@ -12,33 +12,4 @@ float apply_preemphasis(ResistorCapacitor *filter, float sample) { float hard_clip(float sample, float threshold) { return fmaxf(-threshold, fminf(threshold, sample)); -} - -float sincf(float x) { - return (x == 0.0f) ? 1.0f : sinf(M_PI * x) / (M_PI * x); -} - -void init_lpf(FIRFilter *lpf, float freq) { - int m = FILTER_LEN - 1; - float sum = 0.0f; - - for(int n = 0; n < FILTER_LEN; n++) { - float x = n-m/2.0f; - lpf->filter[n] = sincf(2.0f*freq*x) * (0.54 - 0.46 * cosf(M_2PI * n / m)); - sum += lpf->filter[n]; - } - - for(int n = 0; n < FILTER_LEN; n++) { - lpf->filter[n] /= sum; - } -} - -float fir_filter(FIRFilter *fir, float sample) { - float out = 0.0f; - for(int i = 0; i < FILTER_LEN; i++) { - out += fir->filter[i] * sample; - } - fir->filter_idx++; - if(fir->filter_idx == FILTER_LEN) fir->filter_idx = 0; - return out; } \ No newline at end of file diff --git a/lib/filters.h b/lib/filters.h index e42d014..ea4aa78 100644 --- a/lib/filters.h +++ b/lib/filters.h @@ -16,12 +16,4 @@ typedef struct void init_preemphasis(ResistorCapacitor *filter, float tau, float sample_rate); float apply_preemphasis(ResistorCapacitor *filter, float sample); -float hard_clip(float sample, float threshold); - -typedef struct filters -{ - float filter[FILTER_LEN]; - int filter_idx; -} FIRFilter; -void init_lpf(FIRFilter *lpf, float freq); -float fir_filter(FIRFilter *fir, float sample); \ No newline at end of file +float hard_clip(float sample, float threshold); \ No newline at end of file diff --git a/src/fm95.c b/src/fm95.c index 8c3fa1a..2ccda40 100644 --- a/src/fm95.c +++ b/src/fm95.c @@ -414,10 +414,6 @@ int main(int argc, char **argv) { ResistorCapacitor preemp_l, preemp_r; init_preemphasis(&preemp_l, preemphasis_tau, sample_rate); init_preemphasis(&preemp_r, preemphasis_tau, sample_rate); - - FIRFilter lpf_l, lpf_r; - init_lpf(&lpf_l, 15000); - init_lpf(&lpf_r, 15000); // #endregion signal(SIGINT, stop); @@ -475,8 +471,6 @@ int main(int argc, char **argv) { float ready_l = apply_preemphasis(&preemp_l, l_in)*2; float ready_r = apply_preemphasis(&preemp_r, r_in)*2; - ready_l = fir_filter(&lpf_l, ready_l); - ready_r = fir_filter(&lpf_l, ready_r); ready_l = hard_clip(ready_l*audio_volume, clipper_threshold); ready_r = hard_clip(ready_r*audio_volume, clipper_threshold);