From 0debcc647eef3701bf889926f792d5ead246d314 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Thu, 21 Mar 2024 08:49:51 -0400 Subject: [PATCH] Filtering Misc Cleanup; --- src/dsd_audio2.c | 73 ++++-------------------------------------------- src/dsd_symbol.c | 12 ++++---- src/edacs-fme.c | 4 ++- 3 files changed, 13 insertions(+), 76 deletions(-) diff --git a/src/dsd_audio2.c b/src/dsd_audio2.c index 0f4bdc5..87c821c 100644 --- a/src/dsd_audio2.c +++ b/src/dsd_audio2.c @@ -1349,68 +1349,6 @@ void agf (dsd_opts * opts, dsd_state * state, float samp[160], int slot) } -//the previous version, not quite as good at audio gain normalization, but keeping it just in case -// void agf (dsd_opts * opts, dsd_state * state, float samp[160], int slot) -// { -// int i, run; -// run = 1; -// float empty[160]; -// memset (empty, 0.0f, sizeof(empty)); - -// float mmax = 0.75f; -// float mmin = -0.75f; -// float aavg = 0.0f; //average of the absolute value -// float df; //decimation value -// df = 8000.0f; //test value -- this would be the ideal perfect value if everybody spoke directly into the mic at a reasonable volume - -// if (slot == 0) -// df = (384.0f / (float)opts->pulse_digi_out_channels) * (50.0f - state->aout_gain); -// if (slot == 1) -// df = (384.0f / (float)opts->pulse_digi_out_channels) * (50.0f - state->aout_gainR); - -// //this comparison is to determine whether or not to run gain on 'empty' samples (2v last 2, silent frames, etc) -// if (memcmp(empty, samp, sizeof(empty)) == 0) run = 0; -// if (run == 0) goto AGF_END; - -// for (i = 0; i < 160; i++) -// { - -// samp[i] = samp[i] / df; - -// aavg += fabsf(samp[i]); - -// //simple clipping -// if (samp[i] > mmax) -// samp[i] = mmax; -// if (samp[i] < mmin) -// samp[i] = mmin; - -// //may have been a tad too loud on the high end -// // samp[i] *= 0.5f; //testing various values here - -// } - -// aavg /= 160.0f; - -// if (slot == 0) -// { -// if (aavg < 0.075f && state->aout_gain < 42.0f) state->aout_gain += 1.0f; -// if (aavg >= 0.075f && state->aout_gain > 1.0f) state->aout_gain -= 1.0f; -// } - -// if (slot == 1) -// { -// if (aavg < 0.075f && state->aout_gainR < 42.0f) state->aout_gainR += 1.0f; -// if (aavg >= 0.075f && state->aout_gainR > 1.0f) state->aout_gainR -= 1.0f; -// } - -// //debug -// // fprintf (stderr, "\nS%d - DF = %f AAVG = %f", slot, df, aavg); - -// AGF_END: ; //do nothing - -// } - //automatic gain short mono for analog audio and some digital mono (WIP) void agsm (dsd_opts * opts, dsd_state * state, short * input, int len) { @@ -1418,10 +1356,10 @@ void agsm (dsd_opts * opts, dsd_state * state, short * input, int len) UNUSED(state); - float avg = 0.0f; //will float be suffient? + float avg = 0.0f; //average of 20 samples float coeff = 0.0f; //gain coeffiecient - float max = 0.0f; //the highest sample value he wave - float den = 1500.0f; //denominator value + float max = 0.0f; //the highest sample value + float nom = 1500.0f; //nominator value float gain = (25.0f / opts->audio_gain); UNUSED(gain); float samp[960]; memset (samp, 0.0f, 960*sizeof(float)); @@ -1449,7 +1387,7 @@ void agsm (dsd_opts * opts, dsd_state * state, short * input, int len) avg /= 20; - coeff = fabsf (den / max); + coeff = fabsf (nom / max); //apply the coefficient to bring the max value to our desired maximum value @@ -1481,14 +1419,13 @@ void agsm (dsd_opts * opts, dsd_state * state, short * input, int len) } //until analog agc is fixed, going to use a manual gain control on this -//that scales a bit differently on the 1-50 index values void analog_gain (dsd_opts * opts, dsd_state * state, short * input, int len) { int i; UNUSED(state); - float gain = 1.0f + (opts->audio_gain / 25.0f); //range is 1 - 3? + float gain = 1.0f + (opts->audio_gain / 25.0f); for (i = 0; i < len; i++) input[i] *= gain; diff --git a/src/dsd_symbol.c b/src/dsd_symbol.c index a22190c..5579383 100644 --- a/src/dsd_symbol.c +++ b/src/dsd_symbol.c @@ -278,20 +278,18 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) sf_write_sync (opts->wav_out_raw); } - //manual gain control -- seems to work better if applied before filtering + //manual gain control analog_gain (opts, state, state->analog_out, 960); - // analog audio filtering + //low pass filter // lpf(state, state->analog_out, 960); + + //high pass filter hpf (state, state->analog_out, 960); - //analog sounds really good now + //pass band filter pbf(state, state->analog_out, 960); - //unsure if this one helps anymore or not, probably not be setup correctly - // if (opts->audio_in_type == 3) //notch filter if using rtl_fm - // nf(state, state->analog_out, 960); - //seems to be working now, but RMS values are lower on actual analog signal than on no signal but noise if ( (opts->rtl_rms > opts->rtl_squelch_level) && opts->monitor_input_audio == 1 && state->carrier == 0 ) //added carrier check here in lieu of disabling it above { diff --git a/src/edacs-fme.c b/src/edacs-fme.c index 362f944..dd5f8a9 100644 --- a/src/edacs-fme.c +++ b/src/edacs-fme.c @@ -207,15 +207,17 @@ void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn analog_gain (opts, state, analog2, 960); analog_gain (opts, state, analog3, 960); - // analog audio filtering + // low pass filter // lpf (state, analog1, 960); // lpf (state, analog2, 960); // lpf (state, analog3, 960); + //high pass filter hpf (state, analog1, 960); hpf (state, analog2, 960); hpf (state, analog3, 960); + //pass band filter pbf (state, analog1, 960); pbf (state, analog2, 960); pbf (state, analog3, 960);