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