minimodem: --Xrxnoise=factor adds test noise
Injects random noise to input signal (in memory) before analysis.
This commit is contained in:
parent
664f345636
commit
b480b841da
|
@ -389,6 +389,8 @@ main( int argc, char*argv[] )
|
|||
float tx_amplitude = 1.0;
|
||||
unsigned int tx_sin_table_len = 4096;
|
||||
|
||||
float rxnoise_factor = 0.0;
|
||||
|
||||
/* validate the default system audio mechanism */
|
||||
#if !(USE_PULSEAUDIO || USE_ALSA)
|
||||
# define _MINIMODEM_NO_SYSTEM_AUDIO
|
||||
|
@ -411,6 +413,7 @@ main( int argc, char*argv[] )
|
|||
MINIMODEM_OPT_LUT,
|
||||
MINIMODEM_OPT_FLOAT_SAMPLES,
|
||||
MINIMODEM_OPT_BENCHMARKS,
|
||||
MINIMODEM_OPT_XRXNOISE,
|
||||
};
|
||||
|
||||
while ( 1 ) {
|
||||
|
@ -439,6 +442,7 @@ main( int argc, char*argv[] )
|
|||
{ "lut", 1, 0, MINIMODEM_OPT_LUT },
|
||||
{ "float-samples", 0, 0, MINIMODEM_OPT_FLOAT_SAMPLES },
|
||||
{ "benchmarks", 0, 0, MINIMODEM_OPT_BENCHMARKS },
|
||||
{ "Xrxnoise", 1, 0, MINIMODEM_OPT_XRXNOISE },
|
||||
{ 0 }
|
||||
};
|
||||
c = getopt_long(argc, argv, "Vtrc:l:a85f:b:v:M:S:T:qAR:",
|
||||
|
@ -525,6 +529,9 @@ main( int argc, char*argv[] )
|
|||
benchmarks();
|
||||
exit(0);
|
||||
break;
|
||||
case MINIMODEM_OPT_XRXNOISE:
|
||||
rxnoise_factor = atof(optarg);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
@ -698,6 +705,8 @@ main( int argc, char*argv[] )
|
|||
if ( ! sa )
|
||||
return 1;
|
||||
|
||||
if ( rxnoise_factor != 0.0 )
|
||||
simpleaudio_set_rxnoise(sa, rxnoise_factor);
|
||||
|
||||
/*
|
||||
* Prepare the input sample chunk rate
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#if USE_SNDFILE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
@ -60,6 +61,15 @@ sa_sndfile_read( simpleaudio *sa, void *buf, size_t nframes )
|
|||
sf_perror(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( sa->rxnoise != 0.0 ) {
|
||||
int i;
|
||||
float *fbuf = buf;
|
||||
float f = sa->rxnoise * 2;
|
||||
for ( i=0; i<nframes; i++ )
|
||||
fbuf[i] += (drand48() - 0.5) * f;
|
||||
}
|
||||
|
||||
// fprintf(stderr, "sf_read: nframes=%ld n=%d\n", nframes, n);
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -149,6 +149,12 @@ simpleaudio_get_samplesize( simpleaudio *sa )
|
|||
return sa->samplesize;
|
||||
}
|
||||
|
||||
void
|
||||
simpleaudio_set_rxnoise( simpleaudio *sa, float rxnoise_factor )
|
||||
{
|
||||
sa->rxnoise = rxnoise_factor;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
simpleaudio_read( simpleaudio *sa, void *buf, size_t nframes )
|
||||
{
|
||||
|
|
|
@ -75,6 +75,9 @@ simpleaudio_get_format( simpleaudio *sa );
|
|||
unsigned int
|
||||
simpleaudio_get_samplesize( simpleaudio *sa );
|
||||
|
||||
void
|
||||
simpleaudio_set_rxnoise( simpleaudio *sa, float rxnoise_factor );
|
||||
|
||||
ssize_t
|
||||
simpleaudio_read( simpleaudio *sa, void *buf, size_t nframes );
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ struct simpleaudio {
|
|||
void * backend_handle;
|
||||
unsigned int samplesize;
|
||||
unsigned int backend_framesize;
|
||||
float rxnoise; // only for the sndfile backend
|
||||
};
|
||||
|
||||
struct simpleaudio_backend {
|
||||
|
|
Loading…
Reference in New Issue