mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-13 09:17:20 -05:00
Raw Signal Wav File Saving; #163
This commit is contained in:
@@ -544,7 +544,7 @@ void openWavOutFileRaw (dsd_opts * opts, dsd_state * state)
|
||||
info.samplerate = 48000; //8000
|
||||
info.channels = 1;
|
||||
info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE;
|
||||
opts->wav_out_raw = sf_open (opts->wav_out_file_raw, SFM_RDWR, &info);
|
||||
opts->wav_out_raw = sf_open (opts->wav_out_file_raw, SFM_WRITE, &info);
|
||||
if (opts->wav_out_raw == NULL)
|
||||
{
|
||||
fprintf (stderr,"Error - could not open raw wav output file %s\n", opts->wav_out_file_raw);
|
||||
|
||||
@@ -1210,6 +1210,7 @@ usage ()
|
||||
printf (" -g <float> Audio Output Gain (Default: 0 = Auto; )\n");
|
||||
printf (" (Manual: 1 = 2%%; 50 = 100%%)\n");
|
||||
printf (" -w <file> Output synthesized speech to a .wav file, FDMA modes only.\n");
|
||||
printf (" -6 <file> Output raw audio .wav file (48K/1). (WARNING! Large File Sizes 1 Hour ~= 360 MB)\n");
|
||||
printf (" -7 <dir> Create/Use Custom directory for Per Call decoded .wav file saving.\n");
|
||||
printf (" (Single Nested Directory Only! Use Before the -P option!)\n");
|
||||
printf (" -8 Enable Experimental Source Audio Monitor (Pulse Audio Output Only!)\n");
|
||||
@@ -1939,6 +1940,13 @@ main (int argc, char **argv)
|
||||
openWavOutFile (&opts, &state);
|
||||
break;
|
||||
|
||||
case '6':
|
||||
strncpy(opts.wav_out_file_raw, optarg, 1023);
|
||||
opts.wav_out_file_raw[1023] = '\0';
|
||||
fprintf (stderr,"Writing raw audio to file %s\n", opts.wav_out_file_raw);
|
||||
openWavOutFileRaw (&opts, &state);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
if (optarg[0] == 'a') //
|
||||
{
|
||||
|
||||
@@ -2378,11 +2378,11 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
printw ("| Writing MBE data files to directory %s\n", opts->mbe_out_dir);
|
||||
}
|
||||
|
||||
//Redo this?
|
||||
// if (opts->wav_out_file_raw[0] != 0 && opts->audio_in_type == 0)
|
||||
// {
|
||||
// printw ("| Appending Raw Sig Audio WAV to file %s\n", opts->wav_out_file_raw);
|
||||
// }
|
||||
|
||||
if (opts->wav_out_raw)
|
||||
{
|
||||
printw ("| Raw Audio Output: %s\n", opts->wav_out_file_raw);
|
||||
}
|
||||
|
||||
if (opts->symbol_out_f) //don't display when not actively capturing
|
||||
{
|
||||
|
||||
@@ -264,9 +264,8 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
||||
|
||||
}
|
||||
|
||||
//Fixed the RTL monitoring bug, it was left active up above (very old and jank test code),
|
||||
//so it was constantly spamming pulse audio server with very small samples, then coming here as well.
|
||||
if (have_sync == 0 && opts->monitor_input_audio == 1)
|
||||
//reworked a bit to allow raw audio wav file saving without the monitoring poriton active
|
||||
if (have_sync == 0)
|
||||
{
|
||||
//sanity check to prevent an overflow
|
||||
if (state->analog_sample_counter > 959)
|
||||
@@ -277,20 +276,18 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
||||
if (state->analog_sample_counter == 960)
|
||||
{
|
||||
//get an rms value if not using the rtl built in version
|
||||
if (opts->audio_in_type != 3)
|
||||
if (opts->audio_in_type != 3 && opts->monitor_input_audio == 1)
|
||||
opts->rtl_rms = raw_rms(state->analog_out, 960, 1);
|
||||
|
||||
//debug
|
||||
// opts->rtl_rms = 101;
|
||||
|
||||
//make it a little quieter
|
||||
for (int x = 0; x < 960; x++)
|
||||
state->analog_out[x] /= 4;
|
||||
|
||||
|
||||
// for (int x = 0; x < 960; x++)
|
||||
// state->analog_out[x] /= 4;
|
||||
|
||||
//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 )
|
||||
if ( (opts->rtl_rms > opts->rtl_squelch_level) && (opts->monitor_input_audio == 1) )
|
||||
{
|
||||
if (opts->audio_out_type == 0)
|
||||
pa_simple_write(opts->pulse_raw_dev_out, state->analog_out, 960*2, NULL);
|
||||
@@ -317,17 +314,41 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
||||
state->last_vc_sync_time = time(NULL);
|
||||
}
|
||||
|
||||
//raw wav file saving -- only write when not NXDN, dPMR, or M17 due to noise that can cause tons of false positives when no sync
|
||||
if (opts->wav_out_raw != NULL && opts->frame_nxdn48 == 0 && opts->frame_nxdn96 == 0 && opts->frame_dpmr == 0 && opts->frame_m17 == 0)
|
||||
{
|
||||
sf_write_short(opts->wav_out_raw, state->analog_out, 960);
|
||||
sf_write_sync (opts->wav_out_raw);
|
||||
}
|
||||
|
||||
memset (state->analog_out, 0, sizeof(state->analog_out));
|
||||
state->analog_sample_counter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (have_sync == 1 && opts->monitor_input_audio == 1)
|
||||
if (have_sync == 1)
|
||||
{
|
||||
//zero out and reset counter
|
||||
memset (state->analog_out, 0, sizeof(state->analog_out));
|
||||
state->analog_sample_counter = 0;
|
||||
//sanity check to prevent an overflow
|
||||
if (state->analog_sample_counter > 959)
|
||||
state->analog_sample_counter = 959;
|
||||
|
||||
state->analog_out[state->analog_sample_counter++] = sample;
|
||||
|
||||
if (state->analog_sample_counter == 960)
|
||||
{
|
||||
//raw wav file saving -- file size on this blimps pretty fast 1 min ~= 6 MB; 1 hour ~= 360 MB;
|
||||
if (opts->wav_out_raw != NULL)
|
||||
{
|
||||
sf_write_short(opts->wav_out_raw, state->analog_out, 960);
|
||||
sf_write_sync (opts->wav_out_raw);
|
||||
}
|
||||
|
||||
//zero out and reset counter
|
||||
memset (state->analog_out, 0, sizeof(state->analog_out));
|
||||
state->analog_sample_counter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (opts->use_cosine_filter)
|
||||
|
||||
Reference in New Issue
Block a user