OSS: Quick Bugfix for hpf_d when TDMA slot 1/2 volume issues; Updated g_dmr patch;

This commit is contained in:
lwvmobile 2024-05-27 20:02:48 -04:00
parent 5dbccaadf6
commit 319d0b9866
2 changed files with 513 additions and 0 deletions

View File

@ -0,0 +1,508 @@
diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c
index 83c11ac..a388355 100644
--- a/src/dmr_csbk.c
+++ b/src/dmr_csbk.c
@@ -463,6 +463,26 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
//rigctl
if (opts->use_rigctl == 1)
{
+
+ if (state->currentslot == 0)
+ {
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
+ }
+ else if (state->currentslot == 1)
+ {
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
+ }
+
//Guess I forgot to add this condition here
if (GetCurrentFreq(opts->rigctl_sockfd) != state->p25_cc_freq)
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away from current frequency
@@ -497,6 +517,26 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
else if (opts->audio_in_type == 3)
{
#ifdef USE_RTLSDR
+
+ if (state->currentslot == 0)
+ {
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
+ }
+ else if (state->currentslot == 1)
+ {
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
+ }
+
//Guess I forgot to add this condition here
uint32_t tempf = (uint32_t)state->p25_cc_freq;
if (opts->rtlsdr_center_freq != tempf)
diff --git a/src/dmr_flco.c b/src/dmr_flco.c
index 839b085..637debf 100644
--- a/src/dmr_flco.c
+++ b/src/dmr_flco.c
@@ -298,20 +298,7 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
if (type != 2) //VLC and EMB, set our target, source, so, and fid per channel
{
- if (state->currentslot == 0)
- {
- state->dmr_fid = fid;
- state->dmr_so = so;
- state->lasttg = target;
- state->lastsrc = source;
- }
- if (state->currentslot == 1)
- {
- state->dmr_fidR = fid;
- state->dmr_soR = so;
- state->lasttgR = target;
- state->lastsrcR = source;
- }
+ //moved per call further down past the call_string stuff
//update cc amd vc sync time for trunking purposes (particularly Con+)
if (opts->p25_is_tuned == 1)
@@ -337,6 +324,12 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
//reset gain
if (opts->floating_point == 1)
state->aout_gain = opts->audio_gain;
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
}
if (state->currentslot == 1)
{
@@ -350,6 +343,12 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
//reset gain
if (opts->floating_point == 1)
state->aout_gainR = opts->audio_gain;
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
}
}
@@ -612,6 +611,69 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
fprintf (stderr, "Key %010llX ", state->RR);
fprintf (stderr, "%s ", KNRM);
}
+
+ if (type != 2)
+ {
+ if (state->currentslot == 0)
+ {
+ state->dmr_fid = fid;
+ state->dmr_so = so;
+ state->lasttg = target;
+ state->lastsrc = source;
+ char * timestr = NULL;
+ char * datestr = NULL;
+ timestr = getTime();
+ datestr = getDate();
+
+ //setup a call string for the per call (group/private and/or emergency)
+ char cs[200]; memset (cs, 0, 200*sizeof(char));
+ int x = 0;
+ for (int i = 0; i < 200; i++)
+ {
+ //copy over non space and non termination values from call string
+ if (i != 0 && state->call_string[0][i] != ' ' && state->call_string[0][i] != 0)
+ cs[x++] = state->call_string[0][i];
+ }
+ cs[x] = 0; //terminate
+
+ //open wav file here if not already opened
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f == NULL)
+ {
+ sprintf (opts->wav_out_file, "%s/%s %s CC %d - %s - TG %d - RD %d", opts->wav_out_dir, datestr, timestr, state->dmr_color_code, cs, target, source);
+ openWavOutFileL (opts, state);
+ }
+ free (timestr); free(datestr);
+ }
+ if (state->currentslot == 1)
+ {
+ state->dmr_fidR = fid;
+ state->dmr_soR = so;
+ state->lasttgR = target;
+ state->lastsrcR = source;
+ char * timestr = NULL;
+ char * datestr = NULL;
+ timestr = getTime();
+ datestr = getDate();
+
+ //setup a call string for the per call (group/private and/or emergency)
+ char cs[200]; memset (cs, 0, 200*sizeof(char));
+ int x = 0;
+ for (int i = 0; i < 200; i++)
+ {
+ //copy over non space and non termination values from call string
+ if (i != 0 && state->call_string[1][i] != ' ' && state->call_string[1][i] != 0)
+ cs[x++] = state->call_string[1][i];
+ }
+ cs[x] = 0; //terminate
+
+ //open wav file here if not already opened
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR == NULL)
+ {
+ sprintf (opts->wav_out_fileR, "%s/%s %s CC %d - %s - TG %d - RD %d", opts->wav_out_dir, datestr, timestr, state->dmr_color_code, cs, target, source);
+ openWavOutFileR (opts, state);
+ }
+ }
+ }
}
diff --git a/src/dsd_file.c b/src/dsd_file.c
index 6f4ecaa..1a035b8 100644
--- a/src/dsd_file.c
+++ b/src/dsd_file.c
@@ -555,6 +555,19 @@ void closeWavOutFile (dsd_opts * opts, dsd_state * state)
UNUSED(state);
sf_close(opts->wav_out_f);
+ char shell[2065], newfilename[1032];
+ int result;
+ sprintf (newfilename, "%s.wav", opts->wav_out_file);
+#ifdef AERO_BUILD
+ result = rename (opts->wav_out_file, newfilename);
+ UNUSED(shell);
+#else
+ sprintf (shell, "mv '%s' '%s'", opts->wav_out_file, newfilename);
+ result = system (shell);
+#endif
+ // fprintf (stderr, "\n Close WAV FileF %s; Result: %d \n", newfilename, result);
+ UNUSED(result);
+
}
void closeWavOutFileL (dsd_opts * opts, dsd_state * state)
@@ -562,6 +575,19 @@ void closeWavOutFileL (dsd_opts * opts, dsd_state * state)
UNUSED(state);
sf_close(opts->wav_out_f);
+ char shell[2065], newfilename[1032];
+ int result;
+ sprintf (newfilename, "%s.wav", opts->wav_out_file);
+#ifdef AERO_BUILD
+ result = rename (opts->wav_out_file, newfilename);
+ UNUSED(shell);
+#else
+ sprintf (shell, "mv '%s' '%s'", opts->wav_out_file, newfilename);
+ result = system (shell);
+#endif
+ // fprintf (stderr, "\n Close WAV FileL %s; Result: %d \n", newfilename, result);
+ UNUSED(result);
+
}
void closeWavOutFileR (dsd_opts * opts, dsd_state * state)
@@ -569,6 +595,18 @@ void closeWavOutFileR (dsd_opts * opts, dsd_state * state)
UNUSED(state);
sf_close(opts->wav_out_fR);
+ char shell[2065], newfilename[1032];
+ int result;
+ sprintf (newfilename, "%s.wav", opts->wav_out_fileR);
+#ifdef AERO_BUILD
+ result = rename (opts->wav_out_fileR, newfilename);
+ UNUSED(shell);
+#else
+ sprintf (shell, "mv '%s' '%s'", opts->wav_out_fileR, newfilename);
+ result = system (shell);
+#endif
+ // fprintf (stderr, "\n Close WAV FileR %s; Result: %d \n", newfilename, result);
+ UNUSED(result);
}
void closeWavOutFileRaw (dsd_opts * opts, dsd_state * state)
diff --git a/src/dsd_main.c b/src/dsd_main.c
index 98f2ead..14add0f 100644
--- a/src/dsd_main.c
+++ b/src/dsd_main.c
@@ -107,6 +107,32 @@ void
noCarrier (dsd_opts * opts, dsd_state * state)
{
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
+ //end perCall wav file close
+
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
+ //end perCall wav file close
+
// #ifdef AERO_BUILD //NOTE: Blame seems to be synctest8 not being initialized (will continue to test)
// //TODO: Investigate why getSymbol needs to be run first in this context...truly confused here
// if(opts->frame_m17 == 1) //&& opts->audio_in_type == 5
@@ -1687,9 +1713,9 @@ main (int argc, char **argv)
}
#ifdef AERO_BUILD
- fprintf (stderr, "Build Version: AW (20231015) \n");
+ fprintf (stderr, "Build Version: AW (20240601) G Build\n");
#else
- fprintf (stderr, "Build Version: AW %s \n", GIT_TAG);
+ fprintf (stderr, "Build Version: AW %s G Build\n", GIT_TAG);
#endif
fprintf (stderr,"MBElib Version: %s\n", versionstr);
diff --git a/src/dsd_mbe.c b/src/dsd_mbe.c
index fe71539..2702b5d 100644
--- a/src/dsd_mbe.c
+++ b/src/dsd_mbe.c
@@ -1197,7 +1197,8 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
if (state->dmr_encL == 0 || opts->dmr_mute_encL == 0)
{
//write wav to per call on left channel Slot 1
- writeSynthesizedVoice (opts, state);
+ if (opts->wav_out_f != NULL)
+ writeSynthesizedVoice (opts, state);
}
}
@@ -1207,7 +1208,8 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
if (state->dmr_encR == 0 || opts->dmr_mute_encR == 0)
{
//write wav to per call on right channel Slot 2
- writeSynthesizedVoiceR (opts, state);
+ if (opts->wav_out_fR != NULL)
+ writeSynthesizedVoiceR (opts, state);
}
}
diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c
index a5442af..0cd538d 100644
--- a/src/dsd_ncurses.c
+++ b/src/dsd_ncurses.c
@@ -1071,7 +1071,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
if (choicec == 12)
{
//flesh out all closewavs and sprint "" wav filenames
- closeWavOutFile (opts, state);
+ // closeWavOutFile (opts, state);
closeWavOutFileL (opts, state);
closeWavOutFileR (opts, state);
//closeWavOutFileRaw (opts, state);
@@ -2153,7 +2153,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
char cs[200]; memcpy (cs, state->call_string[0], 200*sizeof(char));
//close old first, assign name based on time and radio, open wav file
- closeWavOutFileL (opts, state);
+ if (opts->wav_out_f != NULL)
+ closeWavOutFileL (opts, state);
// sprintf (opts->wav_out_file, "%s/%s %s NXDN - RAN %d - DST %d - SRC %d.wav", opts->wav_out_dir, datestr, timestr, rn, tgn, src); //original
sprintf (opts->wav_out_file, "%s/%s %s NXDN - RAN %d - %s - DST %d - SRC %d.wav", opts->wav_out_dir, datestr, timestr, rn, cs, tgn, src); //with call string
@@ -2198,27 +2199,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
call_matrix[9][5] = time(NULL);
//open wav file if enabled and both rd and tg are not 0
- if (opts->dmr_stereo_wav == 1 && rd != 0 && tg != 0)
- {
- //setup a call string for the per call (group/private and/or emergency)
- char cs[200]; memset (cs, 0, 200*sizeof(char));
- int x = 0;
- for (int i = 0; i < 200; i++)
- {
- //copy over non space and non termination values from call string
- if (i != 0 && state->call_string[0][i] != ' ' && state->call_string[0][i] != 0)
- cs[x++] = state->call_string[0][i];
- }
- cs[x] = 0; //terminate
-
- //close old first, assign name based on time and radio, open wav file
- closeWavOutFileL (opts, state);
-
- // sprintf (opts->wav_out_file, "%s/%s %s MS - CC %d - TG %d - RD %d.wav", opts->wav_out_dir, datestr, timestr, dcc, tg, rd); //original
- sprintf (opts->wav_out_file, "%s/%s %s MS - CC %d - %s - DST %d - SRC %d.wav", opts->wav_out_dir, datestr, timestr, dcc, cs, tg, rd); //with cs call string
-
- openWavOutFileL (opts, state); //testing for now, will want to move to per call later
- }
+ // if (opts->dmr_stereo_wav == 1 && rd != 0 && tg != 0)
+ // {
+ // //close old first, assign name based on time and radio, open wav file
+ // if (opts->wav_out_f != NULL)
+ // closeWavOutFileL (opts, state);
+ // sprintf (opts->wav_out_file, "./%s/%s %s MS - CC %d - TG %d - RD %d.wav", opts->wav_out_dir, getDateN(), timestr, dcc, tg, rd);
+ // openWavOutFileL (opts, state); //testing for now, will want to move to per call later
+ // }
if (opts->call_alert == 1 && rd != 0 && tg != 0)
{
@@ -2233,7 +2221,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
}
//DMR BS Slot 1 - matrix 0-4
- if ( call_matrix[4][2] != rd && (lls == 11 || lls == 12 || lls == 10 || lls == 13 || lls == 35 || lls == 36) )
+ if ( call_matrix[4][2] != rd && (lls == 11 || lls == 12 || lls == 10 || lls == 13 ) ) //|| lls == 35 || lls == 36
{
for (short int k = 0; k < 4; k++)
@@ -2254,27 +2242,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
call_matrix[4][5] = time(NULL);
//open wav file if enabled and both rd and tg are not 0
- if (opts->dmr_stereo_wav == 1 && rd != 0 && tg != 0)
- {
- //setup a call string for the per call (group/private and/or emergency)
- char cs[200]; memset (cs, 0, 200*sizeof(char));
- int x = 0;
- for (int i = 0; i < 200; i++)
- {
- //copy over non space and non termination values from call string
- if (i != 0 && state->call_string[0][i] != ' ' && state->call_string[0][i] != 0)
- cs[x++] = state->call_string[0][i];
- }
- cs[x] = 0; //terminate
-
- //close old first, assign name based on time and radio, open wav file
- closeWavOutFileL (opts, state);
-
- // sprintf (opts->wav_out_file, "%s/%s %s CC %d - TG %d - RD %d.wav", opts->wav_out_dir, datestr, timestr, dcc, tg, rd); //original
- sprintf (opts->wav_out_file, "%s/%s %s CC %d - %s - DST %d - SRC %d.wav", opts->wav_out_dir, datestr, timestr, dcc, cs, tg, rd); //with call string
-
- openWavOutFileL (opts, state); //testing for now, will want to move to per call later
- }
+ // if (opts->dmr_stereo_wav == 1 && rd != 0 && tg != 0)
+ // {
+ // //close old first, assign name based on time and radio, open wav file
+ // if (opts->wav_out_f != NULL)
+ // closeWavOutFileL (opts, state);
+ // sprintf (opts->wav_out_file, "./%s/%s %s CC %d - TG %d - RD %d", opts->wav_out_dir, getDateN(), timestr, dcc, tg, rd);
+ // openWavOutFileL (opts, state); //testing for now, will want to move to per call later
+ // }
if (opts->call_alert == 1 && rd != 0 && tg != 0)
{
@@ -2310,34 +2285,21 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
call_matrix[9][5] = time(NULL);
//open wav file if enabled and both rdR and tgR are not 0
- if (opts->dmr_stereo_wav == 1 && rdR != 0 && tgR != 0)
- {
- //setup a call string for the per call (group/private and/or emergency)
- char cs[200]; memset (cs, 0, 200*sizeof(char));
- int x = 0;
- for (int i = 0; i < 200; i++)
- {
- //copy over non space and non termination values from call string
- if (i != 0 && state->call_string[1][i] != ' ' && state->call_string[1][i] != 0)
- cs[x++] = state->call_string[1][i];
- }
- cs[x] = 0; //terminate
-
- //close old first, assign name based on time and radio, open wav file
- closeWavOutFileR (opts, state);
-
- // sprintf (opts->wav_out_fileR, "%s/%s %s CC %d - TG %d - RD %d.wav", opts->wav_out_dir, datestr, timestr, dcc, tgR, rdR); //original
- sprintf (opts->wav_out_fileR, "%s/%s %s CC %d - %s - DST %d - SRC %d.wav", opts->wav_out_dir, datestr, timestr, dcc, cs, tgR, rdR); //with call string
-
- openWavOutFileR (opts, state); //testing for now, will want to move to per call later
- }
+ // if (opts->dmr_stereo_wav == 1 && rdR != 0 && tgR != 0)
+ // {
+ // //close old first, assign name based on time and radio, open wav file
+ // if (opts->wav_out_fR != NULL)
+ // closeWavOutFileR (opts, state);
+ // sprintf (opts->wav_out_fileR, "./%s/%s %s CC %d - TG %d - RD %d", opts->wav_out_dir, getDateN(), timestr, dcc, tgR, rdR);
+ // openWavOutFileR (opts, state); //testing for now, will want to move to per call later
+ // }
- if (opts->call_alert == 1 && rdR != 0 && tgR != 0)
- {
- //fprintf (stderr, "BEEP 1 BS RIGHT\n");
- beeper (opts, state, 1);
- state->dmr_end_alert[1] = 0; //new voice frame, okay to beep at the end of it
- }
+ // if (opts->call_alert == 1 && rdR != 0 && tgR != 0)
+ // {
+ // //fprintf (stderr, "BEEP 1 BS RIGHT\n");
+ // beeper (opts, state, 1);
+ // state->dmr_end_alert[1] = 0; //new voice frame, okay to beep at the end of it
+ // }
memset(state->dmr_alias_block_segment[1], 0, sizeof(state->dmr_alias_block_segment[1]));
sprintf (state->dmr_embedded_gps[1], "%s", "");
@@ -2423,8 +2385,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->ncurses_compact == 1)
{
printw ("------------------------------------------------------------------------------\n");
- printw ("| Digital Speech Decoder: Florida Man Edition - Aero %s \n", "AW (20231015)");
- printw ("------------------------------------------------------------------------------\n");
+ printw ("| Digital Speech Decoder: Florida Man Edition - Aero %s \n", "AW (20240601)");
+ printw ("------------------------------------------------------------------------------\n");
}
#elif LIMAZULUTWEAKS
if (opts->ncurses_compact == 1)
@@ -2462,13 +2424,13 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (i == 4 && opts->frame_m17 == 1) printw (" CODEC2");
#endif
#ifdef AERO_BUILD
- if (i == 5) printw (" %s ", "Aero Build");
- if (i == 6) printw (" AW (20231015) \n");
+ if (i == 5) printw (" %s ", "G Build");
+ if (i == 6) printw (" AW (20240601) \n");
#elif ZDEV_BUILD
- if (i == 5) printw (" %s ", "AW ");
+ if (i == 5) printw (" %s ", "AW G Build");
if (i == 6) printw (" %s \n", GIT_TAG);
- #else
- if (i == 5) printw (" %s ", "AW ");
+ #else
+ if (i == 5) printw (" %s ", "AW G Build");
if (i == 6) printw (" %s \n", GIT_TAG);
#endif
else printw ("\n");
@@ -4426,7 +4388,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (c == 112) //'p' key - stop all per call wav files
{
//hope this one doesn't cause random crashing or garbage writing
- closeWavOutFile (opts, state);
+ // closeWavOutFile (opts, state);
closeWavOutFileL (opts, state);
closeWavOutFileR (opts, state);
sprintf (opts->wav_out_file, "%s", "");

View File

@ -786,6 +786,11 @@ initOpts (dsd_opts * opts)
opts->use_pbf = 1;
opts->use_hpf_d = 1;
//this is a quick bugfix for issues with OSS and TDMA slot 1/2 audio level mismatch
#ifdef AERO_BUILD
opts->use_hpf_d = 0;
#endif
//dsp structured file
opts->dsp_out_file[0] = 0;
opts->use_dsp_output = 0;