From 02a27111d33afa23268f7fd32dbc785a2472d477 Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Tue, 3 May 2022 15:48:15 -0400 Subject: [PATCH] Fix Upsampling Fix Upsampling --upsample audio on all input types to the proper output rate required for mono and stereo output. --Allows for 48000/1 or 24000/2 output when using RTL or STDIN input --MBE file playback still at 8000 due to random crackling when upscaled --WAV file still recorded at 8000 mono --MBE file saving and WAV saving disabled when using the -T Stereo TDMA option until both can be reworked. --- src/dsd_audio.c | 6 ++++-- src/dsd_main.c | 26 +++++++++++++------------- src/dsd_ncurses.c | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/dsd_audio.c b/src/dsd_audio.c index a080257..ea1644f 100644 --- a/src/dsd_audio.c +++ b/src/dsd_audio.c @@ -156,7 +156,8 @@ processAudio (dsd_opts * opts, dsd_state * state) // copy audio data to output buffer and upsample if necessary state->audio_out_temp_buf_p = state->audio_out_temp_buf; - if (opts->split == 0) + //the only time we don't want to upsample is when playing back MBE files, upsampling them seems to cause random crackling + if (opts->playfiles == 0) //opts->split == 0 { for (n = 0; n < 160; n++) { @@ -295,7 +296,8 @@ processAudioR (dsd_opts * opts, dsd_state * state) // copy audio data to output buffer and upsample if necessary state->audio_out_temp_buf_pR = state->audio_out_temp_bufR; - if (opts->split == 0) //shouldn't need splitR + //the only time we don't want to upsample is when playing back MBE files, upsampling them seems to cause random crackling + if (opts->playfiles == 0) //opts->split == 0 { for (n = 0; n < 160; n++) { diff --git a/src/dsd_main.c b/src/dsd_main.c index 1edf06c..6517858 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -499,19 +499,19 @@ usage () void liveScanner (dsd_opts * opts, dsd_state * state) { -//need to use this area to configure audio rates for different sources if not pulse -if (opts->audio_in_type == 1) //if stdin, switch to 8000 and single channel audio +//not sure this section is needed now that I've worked out the issue, wasn't upsampling due to split == 1 +if (opts->audio_in_type == 1) { - opts->pulse_digi_rate_out = 8000; //stdin needs 8000 output for single channel + opts->pulse_digi_rate_out = 48000; opts->pulse_digi_out_channels = 1; if (opts->dmr_stereo == 1) { - opts->pulse_digi_rate_out = 4000; //stdin needs 4000 by 2 channel for DMR TDMA Stereo output + opts->pulse_digi_rate_out = 24000; //stdin needs 24000 by 2 channel for DMR TDMA Stereo output opts->pulse_digi_out_channels = 2; - fprintf (stderr, "STDIN Audio Rate Out set to 4000 Khz/2 Channel \n"); + fprintf (stderr, "STDIN Audio Rate Out set to 24000 Khz/2 Channel \n"); } - else fprintf (stderr, "STDIN Audio Rate Out set to 8000 Khz/1 Channel \n"); + else fprintf (stderr, "STDIN Audio Rate Out set to 48000 Khz/1 Channel \n"); opts->pulse_raw_rate_out = 48000; opts->pulse_raw_out_channels = 1; @@ -533,16 +533,16 @@ if (opts->audio_in_type == 1) //if stdin, switch to 8000 and single channel audi #ifdef USE_RTLSDR if(opts->audio_in_type == 3) { - //test to see if this is still necessary - opts->pulse_digi_rate_out = 8000; //rtl needs 8000 and 1 channel is mono system + //not sure this section is needed now that I've worked out the issue, wasn't upsampling due to split == 1 + opts->pulse_digi_rate_out = 48000; //rtl needs 8000 and 1 channel is mono system opts->pulse_digi_out_channels = 1; if (opts->dmr_stereo == 1) { - opts->pulse_digi_rate_out = 4000; //rtl needs 4000 by 2 channel for DMR TDMA Stereo output + opts->pulse_digi_rate_out = 24000; //rtl needs 4000 by 2 channel for DMR TDMA Stereo output opts->pulse_digi_out_channels = 2; - fprintf (stderr, "RTL Audio Rate Out set to 4000 Khz/2 Channel \n"); + fprintf (stderr, "RTL Audio Rate Out set to 24000 Khz/2 Channel \n"); } - else fprintf (stderr, "RTL Audio Rate Out set to 8000 Khz/1 Channel \n"); + else fprintf (stderr, "RTL Audio Rate Out set to 48000 Khz/1 Channel \n"); opts->pulse_raw_rate_out = 48000; opts->pulse_raw_out_channels = 1; @@ -1308,7 +1308,7 @@ main (int argc, char **argv) openAudioInDevice (&opts); - fprintf (stderr,"Press CTRL + C twice to close.\n"); //Kindly remind user to double tap CTRL + C + fprintf (stderr,"Press CTRL + C twice to close.\n"); } else @@ -1323,7 +1323,7 @@ main (int argc, char **argv) if (opts.playfiles == 1) { - opts.pulse_digi_rate_out = 8000; //need set to 8000 for amb/imb playback + opts.pulse_digi_rate_out = 8000; //need set to 8000 for amb/imb playback, upsamling seems to cause random crackles opts.pulse_digi_out_channels = 1; openPulseOutput(&opts); //need to open it up for output playMbeFiles (&opts, &state, argc, argv); diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index b828665..733c829 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -456,7 +456,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) } if (opts->audio_in_type == 1) { - printw ("| STDIN - Input\n"); + printw ("| STDIN Standard Input: - \n"); } if (opts->audio_in_type == 3) {