minimodem: use sine lookup table of 1024, or --lut={tx_sin_table_len}

This commit is contained in:
Kamal Mostafa 2012-08-13 21:17:03 -07:00
parent e2225d6098
commit a9c2258706
2 changed files with 44 additions and 4 deletions

View File

@ -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 \-\-lut={tx_sin_table_len}
Minimodem uses a precomputed sine wave lookup table of 1024 elements,
or the size specified here. Use \-\-lut=0 to disable the use of
the sine wave lookup table. (This option applies to \-\-tx mode only).
.TP
.B \-\-float-samples .B \-\-float-samples
Generate 32-bit floating-point format audio samples, instead of the Generate 32-bit floating-point format audio samples, instead of the
default 16-bit signed integer format (applies to \-\-tx mode only; default 16-bit signed integer format (applies to \-\-tx mode only;

View File

@ -254,22 +254,47 @@ benchmarks()
simpleaudio *sa_out; simpleaudio *sa_out;
// enable the sine wave LUT
simpleaudio_tone_init(1024);
sa_out = simpleaudio_open_stream(backend, SA_STREAM_PLAYBACK, sa_out = simpleaudio_open_stream(backend, SA_STREAM_PLAYBACK,
SA_SAMPLE_FORMAT_S16, sample_rate, 1, SA_SAMPLE_FORMAT_S16, sample_rate, 1,
program_name, "generate-tones-S16-mono"); program_name, "generate-tones-lut1024-S16-mono");
if ( ! sa_out ) if ( ! sa_out )
return 0; return 0;
generate_test_tones(sa_out, 10); generate_test_tones(sa_out, 10);
simpleaudio_close(sa_out); simpleaudio_close(sa_out);
sa_out = simpleaudio_open_stream(backend, SA_STREAM_PLAYBACK, sa_out = simpleaudio_open_stream(backend, SA_STREAM_PLAYBACK,
SA_SAMPLE_FORMAT_FLOAT, sample_rate, 1, SA_SAMPLE_FORMAT_FLOAT, sample_rate, 1,
program_name, "generate-tones-FLOAT-mono"); program_name, "generate-tones-lut1024-FLOAT-mono");
if ( ! sa_out ) if ( ! sa_out )
return 0; return 0;
generate_test_tones(sa_out, 10); generate_test_tones(sa_out, 10);
simpleaudio_close(sa_out); simpleaudio_close(sa_out);
// disable the sine wave LUT
simpleaudio_tone_init(0);
sa_out = simpleaudio_open_stream(backend, SA_STREAM_PLAYBACK,
SA_SAMPLE_FORMAT_S16, sample_rate, 1,
program_name, "generate-tones-nolut-S16-mono");
if ( ! sa_out )
return 0;
generate_test_tones(sa_out, 10);
simpleaudio_close(sa_out);
sa_out = simpleaudio_open_stream(backend, SA_STREAM_PLAYBACK,
SA_SAMPLE_FORMAT_FLOAT, sample_rate, 1,
program_name, "generate-tones-nolut-FLOAT-mono");
if ( ! sa_out )
return 0;
generate_test_tones(sa_out, 10);
simpleaudio_close(sa_out);
return 1; return 1;
} }
@ -308,6 +333,7 @@ usage()
" -R, --samplerate {rate}\n" " -R, --samplerate {rate}\n"
" -V, --version\n" " -V, --version\n"
" -A, --alsa\n" " -A, --alsa\n"
" --lut={tx_sin_table_len}\n"
" --float-samples\n" " --float-samples\n"
" --benchmarks\n" " --benchmarks\n"
" {baudmode}\n" " {baudmode}\n"
@ -341,6 +367,8 @@ main( int argc, char*argv[] )
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
unsigned int tx_sin_table_len = 4096;
/* validate the default system audio mechanism */ /* validate the default system audio mechanism */
#if !(USE_PULSEAUDIO || USE_ALSA) #if !(USE_PULSEAUDIO || USE_ALSA)
# define _MINIMODEM_NO_SYSTEM_AUDIO # define _MINIMODEM_NO_SYSTEM_AUDIO
@ -360,6 +388,7 @@ main( int argc, char*argv[] )
enum { enum {
MINIMODEM_OPT_UNUSED=256, // placeholder MINIMODEM_OPT_UNUSED=256, // placeholder
MINIMODEM_OPT_LUT,
MINIMODEM_OPT_FLOAT_SAMPLES, MINIMODEM_OPT_FLOAT_SAMPLES,
MINIMODEM_OPT_BENCHMARKS, MINIMODEM_OPT_BENCHMARKS,
}; };
@ -385,6 +414,7 @@ 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' },
{ "lut", 1, 0, MINIMODEM_OPT_LUT },
{ "float-samples", 0, 0, MINIMODEM_OPT_FLOAT_SAMPLES }, { "float-samples", 0, 0, MINIMODEM_OPT_FLOAT_SAMPLES },
{ "benchmarks", 0, 0, MINIMODEM_OPT_BENCHMARKS }, { "benchmarks", 0, 0, MINIMODEM_OPT_BENCHMARKS },
{ 0 } { 0 }
@ -453,6 +483,9 @@ main( int argc, char*argv[] )
exit(1); exit(1);
#endif #endif
break; break;
case MINIMODEM_OPT_LUT:
tx_sin_table_len = atoi(optarg);
break;
case MINIMODEM_OPT_FLOAT_SAMPLES: case MINIMODEM_OPT_FLOAT_SAMPLES:
sample_format = SA_SAMPLE_FORMAT_FLOAT; sample_format = SA_SAMPLE_FORMAT_FLOAT;
break; break;
@ -587,6 +620,8 @@ main( int argc, char*argv[] )
*/ */
if ( TX_mode ) { if ( TX_mode ) {
simpleaudio_tone_init(tx_sin_table_len);
int tx_interactive = 0; int tx_interactive = 0;
if ( ! stream_name ) { if ( ! stream_name ) {
tx_interactive = 1; tx_interactive = 1;