Append WAV Files

Append to WAV files as opposed to overwriting them each time
Minor Tweaks to NCURSES terminal in regards to NXDN, update call log on systems with RAN of 0
This commit is contained in:
lwvmobile
2022-02-25 15:09:06 -05:00
committed by GitHub
parent 71be900630
commit b996d95b1c
3 changed files with 22 additions and 18 deletions

View File

@@ -89,7 +89,10 @@ saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
fputc (b, opts->mbe_out_f);
}
//fprintf(stderr, "\n");
if (opts->payload == 1)
{
fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2);
}
b = ambe_d[48];
fputc (b, opts->mbe_out_f);
fflush (opts->mbe_out_f);
@@ -237,8 +240,12 @@ closeMbeOutFile (dsd_opts * opts, dsd_state * state)
fclose (opts->mbe_out_f);
opts->mbe_out_f = NULL;
strftime (datestr, 31, "%Y-%m-%d-%H%M%S", &timep);
//sprintf (newfilename, "nac%X-%s-tg%i%s", state->nac, datestr, talkgroup, ext);
sprintf (newfilename, "%s%s", datestr, ext); //this one
if (state->lastsynctype == 0 || state->lastsynctype)
{
sprintf (newfilename, "%s-nac%X-tg%i%s", datestr, state->nac, talkgroup, ext);
}
sprintf (new_path, "%s%s", opts->mbe_out_dir, newfilename);
#ifdef _WIN32
sprintf (shell, "move %s %s", opts->mbe_out_path, new_path);
@@ -307,13 +314,12 @@ void
openWavOutFile (dsd_opts * opts, dsd_state * state)
{
// opts->wav_out_f = fopen (opts->wav_out_file, "w");
SF_INFO info;
info.samplerate = 8000; //8000
info.channels = 1;
info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE;
opts->wav_out_f = sf_open (opts->wav_out_file, SFM_WRITE, &info);
//opts->wav_out_f = sf_open (opts->wav_out_file, SFM_WRITE, &info);
opts->wav_out_f = sf_open (opts->wav_out_file, SFM_RDWR, &info); //RDWR will append to file instead of overwrite file
if (opts->wav_out_f == NULL)
{

View File

@@ -294,7 +294,7 @@ initState (dsd_state * state)
state->debug_header_errors = 0;
state->debug_header_critical_errors = 0;
state->nxdn_last_ran = 0;
state->nxdn_last_ran = -1;
#ifdef TRACE_DSD
state->debug_sample_index = 0;
@@ -328,17 +328,14 @@ usage ()
fprintf (stderr," -z <num> Frame rate for datascope\n");
fprintf (stderr,"\n");
fprintf (stderr,"Input/Output options:\n");
//fprintf (stderr," -i <device> Audio input device (default is /dev/audio, - for piped stdin, rtl for rtl device)\n");
fprintf (stderr," -i <device> Audio input device (default is pulse audio, - for piped stdin, rtl for rtl device)\n");
//fprintf (stderr," -o <device> Audio output device (default is /dev/audio)\n");
fprintf (stderr," -o <device> Audio output device (default is pulse audio)\n");
fprintf (stderr," -d <dir> Create mbe data files, use this directory\n");
fprintf (stderr," -r <files> Read/Play saved mbe data from file(s)\n");
fprintf (stderr," -g <num> Audio output gain (default = 0 = auto, disable = -1)\n");
//fprintf (stderr," -n Do not send synthesized speech to audio output device\n");
fprintf (stderr," -w <file> Output synthesized speech to a .wav file\n");
fprintf (stderr," -a Display port audio devices\n");
fprintf (stderr," -W Monitor Source Audio When No Sync Detected (WIP!)\n");
//fprintf (stderr," -a Display port audio devices\n");
//fprintf (stderr," -W Monitor Source Audio When No Sync Detected (WIP!)\n");
fprintf (stderr,"\n");
fprintf (stderr,"RTL-SDR options:\n");
fprintf (stderr," -c <hertz> RTL-SDR Frequency\n");
@@ -382,8 +379,8 @@ usage ()
fprintf (stderr," (default=36)\n");
fprintf (stderr," -M <num> Min/Max buffer size for QPSK decision point tracking\n");
fprintf (stderr," (default=15)\n");
fprintf (stderr," -n Reset P25 Heuristics and initState variables on mixed decoding signal\n");
fprintf (stderr," Helps when decoding multiple signal types at same time\n");
fprintf (stderr," -n Reset P25 Heuristics and initState variables on mixed signal decoding\n");
fprintf (stderr," Helps when decoding mixed signal types at same time\n");
fprintf (stderr," (WiP! May Cause Slow Memory Leak - Experimental)\n");
fprintf (stderr," -Z Log MBE Payload to console\n");
fprintf (stderr,"\n");
@@ -786,7 +783,7 @@ main (int argc, char **argv)
case 'w':
strncpy(opts.wav_out_file, optarg, 1023);
opts.wav_out_file[1023] = '\0';
fprintf (stderr,"Writing audio to file %s\n", opts.wav_out_file);
fprintf (stderr,"Writing + Appending audio to file %s\n", opts.wav_out_file);
openWavOutFile (&opts, &state);
break;
case 'B':

View File

@@ -106,6 +106,7 @@ void ncursesOpen ()
init_pair(5, COLOR_MAGENTA, COLOR_BLACK); //Magenta for no frame sync/signal
noecho();
cbreak();
//fprintf (stderr, "Opening NCurses Terminal. \n");
}
@@ -164,7 +165,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
//if ( (state->nxdn_last_rid != src && src > 0) || (state->nxdn_last_ran != rn && rn > 0) ) //find condition to make this work well, probably if last != local last variables
//if ( (call_matrix[9][2] != src && src > 0) || (call_matrix[9][1] != rn && rn > 0) ) //NXDN working well now with this, updates immediately and only once
if ( call_matrix[9][2] != src && src > 0 && rn > 0 ) //NXDN working well now with this, updates immediately and only once
if ( call_matrix[9][2] != src && src > 0 && rn > -1 ) //NXDN working well now with this, updates immediately and only once
{
for (short int k = 0; k < 9; k++)
{
@@ -260,7 +261,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
}
if (opts->wav_out_file[0] != 0)
{
printw ("| Writing Audio WAV to file %s\n", opts->wav_out_file);
printw ("| Appending Audio WAV to file %s\n", opts->wav_out_file);
}
printw ("------------------------------------------------------------------------------\n");
@@ -295,7 +296,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
src = state->nxdn_last_rid;
//rn = state->nxdn_last_ran;
}
if (state->nxdn_last_ran > 0 && state->nxdn_last_rid != rn);
if (state->nxdn_last_ran > -1 && state->nxdn_last_rid != rn);
{
//src = state->nxdn_last_rid;
rn = state->nxdn_last_ran;
@@ -344,7 +345,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw("| ALG: [0x%02X] ", state->payload_algid);
printw("KEY: [0x%04X] ", state->payload_keyid);
//printw("MFG: [0x%X] ", state->payload_mfid); //no way of knowing if this is accurate info yet
if (state->payload_keyid != 0 && state->carrier == 1)
if (state->payload_algid != 0x80 && state->carrier == 1)
{
attron(COLOR_PAIR(2));
printw("**ENC**");