diff --git a/lib/filters.c b/lib/filters.c index a531e99..ddf751c 100644 --- a/lib/filters.c +++ b/lib/filters.c @@ -119,33 +119,4 @@ float voltage_to_voltage_db(float linear) { float voltage_to_power_db(float linear) { return 10.0f * log10f(fmaxf(linear, 1e-10f)); // Avoid log(0) -} - -void init_compressor(Compressor *compressor, float attack, float release) { - compressor->attack = attack; - compressor->release = release; - compressor->max = 0.0f; -} - -float peak_compress(Compressor *compressor, float sample) { - float sample_abs = fabsf(sample); - if(sample_abs > compressor->max) { - compressor->max += (sample_abs - compressor->max) * compressor->attack; - } else { - compressor->max *= compressor->release; - } - return sample/(compressor->max+0.01); -} - -float peak_compress_stereo(Compressor *compressor, float l, float r, float *output_r) { - float l_abs = fabsf(l); - float r_abs = fabsf(r); - float max = (l_abs > r_abs) ? l_abs : r_abs; - if(max > compressor->max) { - compressor->max += (max - compressor->max) / compressor->attack; - } else { - compressor->max *= compressor->release; - } - *output_r = r/(compressor->max+0.01); - return l/(compressor->max+0.01); -} +} \ No newline at end of file diff --git a/lib/filters.h b/lib/filters.h index 6a69db7..d9321f2 100644 --- a/lib/filters.h +++ b/lib/filters.h @@ -29,13 +29,4 @@ 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); - -typedef struct { - float attack; - float release; - float max; -} Compressor; -void init_compressor(Compressor *compressor, float attack, float release); -float peak_compress(Compressor *compressor, float sample); -float peak_compress_stereo(Compressor *compressor, float l, float r, float *output_r); +float voltage_to_power_db(float linear); \ No newline at end of file diff --git a/src/fm95.c b/src/fm95.c index b89018b..e5d38cb 100644 --- a/src/fm95.c +++ b/src/fm95.c @@ -34,7 +34,7 @@ #include #define MASTER_VOLUME 1.0f // Volume of everything combined, for calibration -#define AUDIO_VOLUME 1.0f // Audio volume, before clipper +#define AUDIO_VOLUME 1.5f // Audio volume, before clipper #define MONO_VOLUME 0.45f // L+R Signal #define PILOT_VOLUME 0.09f // 19 KHz Pilot #define STEREO_VOLUME 0.45f // L-R signal, should be same as MONO @@ -374,9 +374,6 @@ int main(int argc, char **argv) { BiquadFilter lpf_l, lpf_r; init_lpf(&lpf_l, LPF_CUTOFF, 1.25f, SAMPLE_RATE); init_lpf(&lpf_r, LPF_CUTOFF, 1.25f, SAMPLE_RATE); - - Compressor comp; - init_compressor(&comp, 0.9995f, 0.8f); // #endregion signal(SIGINT, stop); @@ -417,10 +414,8 @@ int main(int argc, char **argv) { float current_mpx_in = mpx_in[i]; float current_sca_in = sca_in[i]; - float ready_r; - float ready_l = peak_compress_stereo(&comp, l_in, r_in, &ready_r); - ready_l = apply_frequency_filter(&lpf_l, l_in); - ready_r = apply_frequency_filter(&lpf_r, r_in); + float ready_l = apply_frequency_filter(&lpf_l, l_in); + float ready_r = apply_frequency_filter(&lpf_r, r_in); ready_l = apply_preemphasis(&preemp_l, ready_l)*4; ready_r = apply_preemphasis(&preemp_r, ready_r)*4; ready_l = hard_clip(ready_l*audio_volume, clipper_threshold);