minimodem: --tx uses S16 samples by default, --float-samples overrides

This commit is contained in:
Kamal Mostafa 2012-08-12 15:47:59 -07:00
parent 6671138471
commit 9948e7c7dd
3 changed files with 20 additions and 7 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1) .\" other parameters are allowed: see man(7), man(1)
.TH MINIMODEM 1 "August 11, 2011" .TH MINIMODEM 1 "August 12, 2011"
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.\" .\"
.\" Some roff macros, for reference: .\" Some roff macros, for reference:
@ -78,6 +78,11 @@ Set the audio sample rate (default rate is 48000 Hz).
Use ALSA as the audio output system instead of the default Use ALSA as the audio output system instead of the default
PulseAudio (depending on build configuration options). PulseAudio (depending on build configuration options).
.TP .TP
.B \-F, \-\-float-samples
Generate 32-bit floating-point format audio samples, instead of the
default 16-bit signed integer format (applies to \-\-tx mode only;
\-\-rx mode always uses 32-bit floating-point).
.TP
.B \-V, \-\-version .B \-V, \-\-version
print program version print program version
.SH {baudmode} .SH {baudmode}

View File

@ -257,6 +257,7 @@ usage()
" -R, --samplerate {rate}\n" " -R, --samplerate {rate}\n"
" -V, --version\n" " -V, --version\n"
" -A, --alsa\n" " -A, --alsa\n"
" -F, --float-samples\n"
" {baudmode}\n" " {baudmode}\n"
" 1200 Bell202 1200 bps --ascii\n" " 1200 Bell202 1200 bps --ascii\n"
" 300 Bell103 300 bps --ascii\n" " 300 Bell103 300 bps --ascii\n"
@ -285,7 +286,7 @@ main( int argc, char*argv[] )
float bfsk_confidence_threshold = 0.6; float bfsk_confidence_threshold = 0.6;
sa_backend_t sa_backend = SA_BACKEND_SYSDEFAULT; sa_backend_t sa_backend = SA_BACKEND_SYSDEFAULT;
sa_format_t sample_format = SA_SAMPLE_FORMAT_S16;
unsigned int sample_rate = 48000; unsigned int sample_rate = 48000;
unsigned int nchannels = 1; // FIXME: only works with one channel unsigned int nchannels = 1; // FIXME: only works with one channel
@ -327,9 +328,10 @@ main( int argc, char*argv[] )
{ "quiet", 0, 0, 'q' }, { "quiet", 0, 0, 'q' },
{ "alsa", 0, 0, 'A' }, { "alsa", 0, 0, 'A' },
{ "samplerate", 1, 0, 'R' }, { "samplerate", 1, 0, 'R' },
{ "float-samples", 0, 0, 'F' },
{ 0 } { 0 }
}; };
c = getopt_long(argc, argv, "Vtrc:a85f:b:M:S:T:qAR:", c = getopt_long(argc, argv, "Vtrc:a85f:b:M:S:T:qAR:F",
long_options, &option_index); long_options, &option_index);
if ( c == -1 ) if ( c == -1 )
break; break;
@ -393,6 +395,9 @@ main( int argc, char*argv[] )
exit(1); exit(1);
#endif #endif
break; break;
case 'F':
sample_format = SA_SAMPLE_FORMAT_FLOAT;
break;
default: default:
usage(); usage();
} }
@ -400,6 +405,10 @@ main( int argc, char*argv[] )
if ( TX_mode == -1 ) if ( TX_mode == -1 )
TX_mode = 0; TX_mode = 0;
/* The receive code requires floating point samples to feed to the FFT */
if ( TX_mode == 0 )
sample_format = SA_SAMPLE_FORMAT_FLOAT;
if ( filename ) { if ( filename ) {
#if !USE_SNDFILE #if !USE_SNDFILE
fprintf(stderr, "E: This build of minimodem was configured without sndfile,\nE: so the --file flag is not supported.\n"); fprintf(stderr, "E: This build of minimodem was configured without sndfile,\nE: so the --file flag is not supported.\n");
@ -524,8 +533,7 @@ main( int argc, char*argv[] )
simpleaudio *sa_out; simpleaudio *sa_out;
sa_out = simpleaudio_open_stream(sa_backend, SA_STREAM_PLAYBACK, sa_out = simpleaudio_open_stream(sa_backend, SA_STREAM_PLAYBACK,
SA_SAMPLE_FORMAT_FLOAT, sample_format, sample_rate, nchannels,
sample_rate, nchannels,
program_name, stream_name); program_name, stream_name);
if ( ! sa_out ) if ( ! sa_out )
return 1; return 1;
@ -553,8 +561,7 @@ main( int argc, char*argv[] )
simpleaudio *sa; simpleaudio *sa;
sa = simpleaudio_open_stream(sa_backend, SA_STREAM_RECORD, sa = simpleaudio_open_stream(sa_backend, SA_STREAM_RECORD,
SA_SAMPLE_FORMAT_FLOAT, sample_format, sample_rate, nchannels,
sample_rate, nchannels,
program_name, stream_name); program_name, stream_name);
if ( ! sa ) if ( ! sa )
return 1; return 1;

View File

@ -0,0 +1 @@
exec ./self-test testcases/self-test-ascii.txt --float-samples 12000