mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-27 03:23:54 +01:00
is this vibe coding?
This commit is contained in:
19
filter/iir.c
19
filter/iir.c
@@ -16,21 +16,16 @@ inline float apply_preemphasis(ResistorCapacitor *filter, float sample) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tilt_init(TiltCorrectionFilter* filter, float correction_strength) {
|
void tilt_init(TiltCorrectionFilter* filter, float correction_strength) {
|
||||||
filter->alpha = 0.9999f;
|
f->tilt = correction_strength;
|
||||||
filter->gain = correction_strength; // Can be > 1.0
|
f->prev_in = 0.0f;
|
||||||
filter->x_prev = 0.0f;
|
f->prev_out = 0.0f;
|
||||||
filter->y_prev = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float tilt(TiltCorrectionFilter* filter, float input) {
|
float tilt(TiltCorrectionFilter* filter, float input) {
|
||||||
// High-pass filter
|
float out = input + f->tilt * (input - f->prev_in);
|
||||||
float hp_out = filter->alpha * (filter->y_prev + input - filter->x_prev);
|
|
||||||
|
|
||||||
// Apply gain and add back to original
|
f->prev_in = input;
|
||||||
float output = input + filter->gain * hp_out;
|
f->prev_out = out;
|
||||||
|
|
||||||
filter->x_prev = input;
|
return out;
|
||||||
filter->y_prev = hp_out;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
@@ -14,10 +14,9 @@ void init_preemphasis(ResistorCapacitor *filter, float tau, float sample_rate, f
|
|||||||
float apply_preemphasis(ResistorCapacitor *filter, float sample);
|
float apply_preemphasis(ResistorCapacitor *filter, float sample);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float alpha;
|
float tilt; // Tilt amount (-1.0 to +1.0 typical)
|
||||||
float x_prev;
|
float prev_in; // Previous input sample
|
||||||
float y_prev;
|
float prev_out; // Previous output sample
|
||||||
float gain;
|
|
||||||
} TiltCorrectionFilter;
|
} TiltCorrectionFilter;
|
||||||
|
|
||||||
void tilt_init(TiltCorrectionFilter* filter, float alpha);
|
void tilt_init(TiltCorrectionFilter* filter, float alpha);
|
||||||
|
|||||||
Reference in New Issue
Block a user