0
1
mirror of https://github.com/radio95-rnt/fm95.git synced 2026-02-26 19:23:51 +01:00
Files
fm95/lib/filters.h
2025-03-27 19:25:04 +01:00

33 lines
696 B
C

#pragma once
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "constants.h"
#include "oscillator.h"
#define LPF_ORDER 10
typedef struct
{
float alpha;
float prev_sample;
float gain;
} ResistorCapacitor;
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
{
float A[LPF_ORDER];
float d1[LPF_ORDER];
float d2[LPF_ORDER];
float w0[LPF_ORDER];
float w1[LPF_ORDER];
float w2[LPF_ORDER];
} LPFFilter;
void init_lpf(LPFFilter *filter, float cutoff, int sample_rate);
float process_lpf(LPFFilter *filter, float x);