diff --git a/lib/filters.c b/lib/filters.c index a767549..d13eafe 100644 --- a/lib/filters.c +++ b/lib/filters.c @@ -13,20 +13,4 @@ float apply_preemphasis(ResistorCapacitor *filter, float sample) { float hard_clip(float sample, float threshold) { // Branchless clipping return fmaxf(-threshold, fminf(threshold, sample)); -} - -float voltage_db_to_voltage(float db) { - return powf(10.0f, db / 20.0f); -} - -float power_db_to_voltage(float db) { - return powf(10.0f, db / 10.0f); -} - -float voltage_to_voltage_db(float linear) { - return 20.0f * log10f(fmaxf(linear, 1e-10f)); // Avoid log(0) -} - -float voltage_to_power_db(float linear) { - return 10.0f * log10f(fmaxf(linear, 1e-10f)); // Avoid log(0) -} +} \ No newline at end of file diff --git a/lib/filters.h b/lib/filters.h index cf4d3b4..53bdaca 100644 --- a/lib/filters.h +++ b/lib/filters.h @@ -1,5 +1,4 @@ #pragma once -#define FILTER_TAPS 256 #include #include #include @@ -14,8 +13,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); -float voltage_db_to_voltage(float db); -float power_db_to_voltage(float db); -float voltage_to_voltage_db(float linear); -float voltage_to_power_db(float linear); \ No newline at end of file +float hard_clip(float sample, float threshold); \ No newline at end of file diff --git a/lib/fm_modulator.c b/lib/fm_modulator.c index 0294084..8bdc904 100644 --- a/lib/fm_modulator.c +++ b/lib/fm_modulator.c @@ -11,6 +11,6 @@ float modulate_fm(FMModulator *fm, float sample) { float inst_freq = fm->frequency+(sample*fm->deviation); if (inst_freq < 0.0f) inst_freq = 0.0f; float out = sinf(fm->osc_phase); - fm->osc_phase += fmodf(fm->osc_phase + ((M_2PI * inst_freq) / fm->sample_rate), M_2PI); + fm->osc_phase = fmodf(fm->osc_phase + ((M_2PI * inst_freq) / fm->sample_rate), M_2PI); return out; } \ No newline at end of file