mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
remove tilt, and add a non-mpx output
This commit is contained in:
22
filter/iir.c
22
filter/iir.c
@@ -13,26 +13,4 @@ inline float apply_preemphasis(ResistorCapacitor *filter, float sample) {
|
||||
float out = (sample - filter->alpha * filter->prev_sample) * filter->gain;
|
||||
filter->prev_sample = sample;
|
||||
return out;
|
||||
}
|
||||
|
||||
void tilt_init(TiltCorrectionFilter* f, float correction_strength, float sr) {
|
||||
float cutoff = 1000.0f; // fixed split point
|
||||
|
||||
// one-pole lowpass setup
|
||||
float alpha = expf(-2.0f * (float)M_PI * cutoff / sr);
|
||||
f->a1 = alpha;
|
||||
f->a0 = 1.0f - alpha;
|
||||
f->lp = 0.0f;
|
||||
|
||||
// simple low/high gains from tilt
|
||||
float t = (correction_strength < -1.0f) ? -1.0f : (correction_strength > 1.0f ? 1.0f : correction_strength);
|
||||
f->low_gain = 1.0f - t;
|
||||
f->high_gain = 1.0f + t;
|
||||
}
|
||||
|
||||
float tilt(TiltCorrectionFilter* f, float in) {
|
||||
// lowpass
|
||||
f->lp = f->a0 * in + f->a1 * f->lp;
|
||||
float hp = in - f->lp;
|
||||
return f->lp * f->low_gain + hp * f->high_gain;
|
||||
}
|
||||
12
filter/iir.h
12
filter/iir.h
@@ -11,14 +11,4 @@ typedef struct
|
||||
} ResistorCapacitor;
|
||||
|
||||
void init_preemphasis(ResistorCapacitor *filter, float tau, float sample_rate, float ref_freq);
|
||||
float apply_preemphasis(ResistorCapacitor *filter, float sample);
|
||||
|
||||
typedef struct {
|
||||
float a0, a1; // lowpass coeffs
|
||||
float lp; // lowpass state
|
||||
float low_gain; // gain for low frequencies
|
||||
float high_gain; // gain for high frequencies
|
||||
} TiltCorrectionFilter;
|
||||
|
||||
void tilt_init(TiltCorrectionFilter* f, float correction_strength, float sr);
|
||||
float tilt(TiltCorrectionFilter *f, float in);
|
||||
float apply_preemphasis(ResistorCapacitor *filter, float sample);
|
||||
Reference in New Issue
Block a user