From dc1bb6a55eae34f5f713d5dc3204a8990609f9fa Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Mon, 1 Apr 2024 13:11:23 -0400 Subject: [PATCH] CLI Options for Audio Filtering; --- include/dsd.h | 2 +- src/dsd_main.c | 39 +++++++++++++++++++++++++++------------ src/dsd_ncurses.c | 12 +++--------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/include/dsd.h b/include/dsd.h index bc5acac..484ef20 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -810,7 +810,7 @@ typedef struct //Remus DMR End Call Alert Beep int dmr_end_alert[2]; //dmr TLC end call alert beep has already played once flag - //Upsampled Audio Smoothing + //Bitmap Filtering Options uint8_t audio_smoothing; //YSF Fusion Call Strings and Info diff --git a/src/dsd_main.c b/src/dsd_main.c index 3ca7788..72a293d 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -805,7 +805,7 @@ initState (dsd_state * state) //dmr buffer end state->repeat = 0; - //Upsampled Audio Smoothing + //Bitmap Filtering Options state->audio_smoothing = 0; memset (state->audio_out_temp_buf, 0.0f, sizeof(state->audio_out_temp_buf)); @@ -1302,6 +1302,8 @@ usage () // printf (" (Audio Smoothing is now disabled on all upsampled output by default -- fix crackle/buzz bug)\n"); printf (" -z Set TDMA Voice Slot Preference when using /dev/dsp audio output (prevent lag and stuttering)\n"); printf (" -y Enable Experimental Pulse Audio Float Audio Output\n"); + printf (" -v Set Filtering Bitmap Options (Advanced Option)\n"); + printf (" 1 1 1 1 (0xF): PBF/LPF/HPF/HPFD on\n"); printf ("\n"); printf ("RTL-SDR options:\n"); printf (" Usage: rtl:dev:freq:gain:ppm:bw:sq:vol\n"); @@ -1785,10 +1787,10 @@ main (int argc, char **argv) fprintf (stderr, "TDMA (DMR and P2) Slot Voice Preference is Slot %d. \n", opts.slot_preference+1); break; - //Enable Audio Smoothing for Upsampled Audio -- Perm Disable? - // case 'V': - // state.audio_smoothing = 1; - // break; + + + + case 'V': sscanf (optarg, "%d", &slotson); @@ -1886,13 +1888,26 @@ main (int argc, char **argv) state.symbolCenter = state.symbolCenter * opts.wav_interpolator; break; - // case 'v': - // sscanf (optarg, "%d", &opts.verbose); - // break; + case 'v': //set filters via bitmap values 0b1111 + sscanf (optarg, "%X", &state.audio_smoothing); + if (state.audio_smoothing & 1) opts.use_hpf_d = 1; + else opts.use_hpf_d = 0; - // case 'n': //disable or reclaim? - // state.use_throttle = 1; - // break; + if (state.audio_smoothing & 2) opts.use_hpf = 1; + else opts.use_hpf = 0; + + if (state.audio_smoothing & 4) opts.use_lpf = 1; + else opts.use_lpf = 0; + + if (state.audio_smoothing & 8) opts.use_pbf = 1; + else opts.use_pbf = 0; + + if (opts.use_hpf_d == 1) fprintf (stderr, "High Pass Filter on Digital Enabled\n"); + if (opts.use_hpf == 1) fprintf (stderr, "High Pass Filter on Analog Enabled\n"); + if (opts.use_lpf == 1) fprintf (stderr, "Low Pass Filter on Analog Enabled\n"); + if (opts.use_pbf == 1) fprintf (stderr, "Pass Band Filter on Analog Enabled\n"); + + break; case 'b': //formerly Capital 'K' sscanf (optarg, "%lld", &state.K); @@ -2840,7 +2855,7 @@ main (int argc, char **argv) if (opts.tcp_sockfd != 0) { opts.audio_in_type = 8; - state.audio_smoothing = 0; //disable smoothing to prevent random crackling/buzzing + fprintf (stderr, "TCP Connection Success!\n"); // openAudioInDevice(&opts); //do this to see if it makes it work correctly } diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index ec898cc..24855f3 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -951,7 +951,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) } - state->audio_smoothing = 0; //disable smoothing to prevent random crackling/buzzing + TCP_END: ; //do nothing @@ -2420,7 +2420,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if (opts->audio_gain > 0) printw (" (+|-) Manual"); if (opts->use_hpf_d == 1) printw (" HPF"); if (opts->call_alert == 1) printw (" *CA!"); //Call Alert - // if (state->audio_smoothing == 1 && opts->floating_point == 0) printw (" Smoothing On;"); //only on short + printw (" \n"); } @@ -2444,7 +2444,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if (opts->audio_gain > 0) printw (" (+/-) Manual"); if (opts->use_hpf_d == 1) printw (" HPF"); if (opts->call_alert == 1) printw (" *CA!"); //Call Alert - // if (state->audio_smoothing == 1 && opts->floating_point == 0) printw (" Smoothing On;"); //only on short + if ( (opts->audio_out_type == 5 && opts->pulse_digi_rate_out == 48000 && opts->pulse_digi_out_channels == 1) && (opts->frame_provoice == 1 || opts->monitor_input_audio == 1) ) printw (" - Monitor RMS: %04ld ", opts->rtl_rms); printw (" \n"); @@ -4327,12 +4327,6 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) } - // if (c == 48) //'0' key, toggle upsampled audio smoothing - // { - // if (state->audio_smoothing == 1) state->audio_smoothing = 0; - // else state->audio_smoothing = 1; - // } - if (opts->p25_trunk == 1 && c == 119) //'w' key, toggle white list/black list mode { if (opts->trunk_use_allow_list == 1) opts->trunk_use_allow_list = 0;