minimodem: stats report ampl={amplitude}
This commit is contained in:
parent
f8434f3c94
commit
dd6040336d
22
src/fsk.c
22
src/fsk.c
|
@ -178,7 +178,7 @@ fsk_bit_analyze( fsk_plan *fskp, float *samples, unsigned int bit_nsamples,
|
||||||
static float
|
static float
|
||||||
fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit,
|
fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit,
|
||||||
int n_bits, const char *expect_bits_string,
|
int n_bits, const char *expect_bits_string,
|
||||||
unsigned int *bits_outp )
|
unsigned int *bits_outp, float *ampl_outp )
|
||||||
{
|
{
|
||||||
unsigned int bit_nsamples = (float)(samples_per_bit + 0.5);
|
unsigned int bit_nsamples = (float)(samples_per_bit + 0.5);
|
||||||
|
|
||||||
|
@ -288,6 +288,8 @@ fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit,
|
||||||
// Frame confidence is the frame SNR
|
// Frame confidence is the frame SNR
|
||||||
confidence = snr;
|
confidence = snr;
|
||||||
|
|
||||||
|
*ampl_outp = avg_bit_sig;
|
||||||
|
|
||||||
#elif CONFIDENCE_ALGO == 4
|
#elif CONFIDENCE_ALGO == 4
|
||||||
|
|
||||||
/* compute average bit strengths: v_mark and v_space */
|
/* compute average bit strengths: v_mark and v_space */
|
||||||
|
@ -387,8 +389,8 @@ fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit,
|
||||||
for ( bitnum=0; bitnum<n_bits; bitnum++ )
|
for ( bitnum=0; bitnum<n_bits; bitnum++ )
|
||||||
*bits_outp |= bit_values[bitnum] << bitnum;
|
*bits_outp |= bit_values[bitnum] << bitnum;
|
||||||
|
|
||||||
debug_log(" frame confidence (algo #%u) = %f\n",
|
debug_log(" frame algo=%u confidence=%f ampl=%f\n",
|
||||||
CONFIDENCE_ALGO, confidence);
|
CONFIDENCE_ALGO, confidence, *ampl_outp);
|
||||||
return confidence;
|
return confidence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,6 +403,7 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
||||||
float try_confidence_search_limit,
|
float try_confidence_search_limit,
|
||||||
const char *expect_bits_string,
|
const char *expect_bits_string,
|
||||||
unsigned int *bits_outp,
|
unsigned int *bits_outp,
|
||||||
|
float *ampl_outp,
|
||||||
unsigned int *frame_start_outp
|
unsigned int *frame_start_outp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -411,7 +414,7 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
||||||
// try_step_nsamples = 1; // pedantic TEST
|
// try_step_nsamples = 1; // pedantic TEST
|
||||||
|
|
||||||
unsigned int best_t = 0;
|
unsigned int best_t = 0;
|
||||||
float best_c = 0.0;
|
float best_c = 0.0, best_a = 0.0;
|
||||||
unsigned int best_bits = 0;
|
unsigned int best_bits = 0;
|
||||||
|
|
||||||
// Scan the frame positions starting with the one try_first_sample,
|
// Scan the frame positions starting with the one try_first_sample,
|
||||||
|
@ -427,14 +430,16 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
||||||
if ( t < 0 )
|
if ( t < 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float c;
|
float c, ampl_out;
|
||||||
unsigned int bits_out = 0;
|
unsigned int bits_out = 0;
|
||||||
debug_log("try fsk_frame_analyze at t=%d\n", t);
|
debug_log("try fsk_frame_analyze at t=%d\n", t);
|
||||||
c = fsk_frame_analyze(fskp, samples+t, samples_per_bit,
|
c = fsk_frame_analyze(fskp, samples+t, samples_per_bit,
|
||||||
expect_n_bits, expect_bits_string, &bits_out);
|
expect_n_bits, expect_bits_string,
|
||||||
|
&bits_out, &l_out);
|
||||||
if ( best_c < c ) {
|
if ( best_c < c ) {
|
||||||
best_t = t;
|
best_t = t;
|
||||||
best_c = c;
|
best_c = c;
|
||||||
|
best_a = ampl_out;
|
||||||
best_bits = bits_out;
|
best_bits = bits_out;
|
||||||
// If we find a frame with confidence > try_confidence_search_limit
|
// If we find a frame with confidence > try_confidence_search_limit
|
||||||
// quit searching.
|
// quit searching.
|
||||||
|
@ -444,6 +449,7 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
||||||
}
|
}
|
||||||
|
|
||||||
*bits_outp = best_bits;
|
*bits_outp = best_bits;
|
||||||
|
*ampl_outp = best_a;
|
||||||
*frame_start_outp = best_t;
|
*frame_start_outp = best_t;
|
||||||
|
|
||||||
float confidence = best_c;
|
float confidence = best_c;
|
||||||
|
@ -458,10 +464,10 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
||||||
debug_log("FSK_FRAME bits='");
|
debug_log("FSK_FRAME bits='");
|
||||||
for ( j=0; j<expect_n_bits; j++ )
|
for ( j=0; j<expect_n_bits; j++ )
|
||||||
debug_log("%c", ( *bits_outp >> j ) & 1 ? '1' : '0' );
|
debug_log("%c", ( *bits_outp >> j ) & 1 ? '1' : '0' );
|
||||||
debug_log("' datum='%c' (0x%02x) c=%f t=%d\n",
|
debug_log("' datum='%c' (0x%02x) c=%f a=%f t=%d\n",
|
||||||
isprint(bitchar)||isspace(bitchar) ? bitchar : '.',
|
isprint(bitchar)||isspace(bitchar) ? bitchar : '.',
|
||||||
bitchar,
|
bitchar,
|
||||||
confidence, best_t);
|
confidence, best_a, best_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return confidence;
|
return confidence;
|
||||||
|
|
|
@ -66,6 +66,7 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
||||||
float try_confidence_search_limit,
|
float try_confidence_search_limit,
|
||||||
const char *expect_bits_string,
|
const char *expect_bits_string,
|
||||||
unsigned int *bits_outp,
|
unsigned int *bits_outp,
|
||||||
|
float *ampl_outp,
|
||||||
unsigned int *frame_start_outp
|
unsigned int *frame_start_outp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,8 @@ report_no_carrier( fsk_plan *fskp,
|
||||||
unsigned int nframes_decoded,
|
unsigned int nframes_decoded,
|
||||||
unsigned long long nbits_decoded,
|
unsigned long long nbits_decoded,
|
||||||
size_t carrier_nsamples,
|
size_t carrier_nsamples,
|
||||||
float confidence_total )
|
float confidence_total,
|
||||||
|
float amplitude_total )
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "nframes_decoded=%u\n", nframes_decoded);
|
fprintf(stderr, "nframes_decoded=%u\n", nframes_decoded);
|
||||||
|
@ -211,9 +212,10 @@ report_no_carrier( fsk_plan *fskp,
|
||||||
#endif
|
#endif
|
||||||
float throughput_rate =
|
float throughput_rate =
|
||||||
nbits_decoded * sample_rate / (float)carrier_nsamples;
|
nbits_decoded * sample_rate / (float)carrier_nsamples;
|
||||||
fprintf(stderr, "### NOCARRIER ndata=%u confidence=%.3f throughput=%.2f",
|
fprintf(stderr, "\n### NOCARRIER ndata=%u confidence=%.3f ampl=%.3f bps=%.2f",
|
||||||
nframes_decoded,
|
nframes_decoded,
|
||||||
confidence_total / nframes_decoded,
|
confidence_total / nframes_decoded,
|
||||||
|
amplitude_total / nframes_decoded,
|
||||||
throughput_rate);
|
throughput_rate);
|
||||||
if ( (size_t)(nbits_decoded * nsamples_per_bit + 0.5) == carrier_nsamples ) {
|
if ( (size_t)(nbits_decoded * nsamples_per_bit + 0.5) == carrier_nsamples ) {
|
||||||
fprintf(stderr, " (rate perfect) ###\n");
|
fprintf(stderr, " (rate perfect) ###\n");
|
||||||
|
@ -738,6 +740,7 @@ main( int argc, char*argv[] )
|
||||||
|
|
||||||
int carrier = 0;
|
int carrier = 0;
|
||||||
float confidence_total = 0;
|
float confidence_total = 0;
|
||||||
|
float amplitude_total = 0;
|
||||||
unsigned int nframes_decoded = 0;
|
unsigned int nframes_decoded = 0;
|
||||||
unsigned long long nbits_decoded = 0;
|
unsigned long long nbits_decoded = 0;
|
||||||
size_t carrier_nsamples = 0;
|
size_t carrier_nsamples = 0;
|
||||||
|
@ -898,7 +901,7 @@ main( int argc, char*argv[] )
|
||||||
if ( try_step_nsamples == 0 )
|
if ( try_step_nsamples == 0 )
|
||||||
try_step_nsamples = 1;
|
try_step_nsamples = 1;
|
||||||
|
|
||||||
float confidence;
|
float confidence, amplitude;
|
||||||
unsigned int bits = 0;
|
unsigned int bits = 0;
|
||||||
/* Note: frame_start_sample is actually the sample where the
|
/* Note: frame_start_sample is actually the sample where the
|
||||||
* prev_stop bit begins (since the "frame" includes the prev_stop). */
|
* prev_stop bit begins (since the "frame" includes the prev_stop). */
|
||||||
|
@ -925,6 +928,7 @@ main( int argc, char*argv[] )
|
||||||
try_confidence_search_limit,
|
try_confidence_search_limit,
|
||||||
expect_bits_string,
|
expect_bits_string,
|
||||||
&bits,
|
&bits,
|
||||||
|
&litude,
|
||||||
&frame_start_sample
|
&frame_start_sample
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -943,10 +947,11 @@ main( int argc, char*argv[] )
|
||||||
if ( !quiet_mode )
|
if ( !quiet_mode )
|
||||||
report_no_carrier(fskp, sample_rate, bfsk_data_rate,
|
report_no_carrier(fskp, sample_rate, bfsk_data_rate,
|
||||||
nsamples_per_bit, nframes_decoded, nbits_decoded,
|
nsamples_per_bit, nframes_decoded, nbits_decoded,
|
||||||
carrier_nsamples, confidence_total);
|
carrier_nsamples, confidence_total, amplitude_total);
|
||||||
carrier = 0;
|
carrier = 0;
|
||||||
carrier_nsamples = 0;
|
carrier_nsamples = 0;
|
||||||
confidence_total = 0;
|
confidence_total = 0;
|
||||||
|
amplitude_total = 0;
|
||||||
nframes_decoded = 0;
|
nframes_decoded = 0;
|
||||||
nbits_decoded = 0;
|
nbits_decoded = 0;
|
||||||
}
|
}
|
||||||
|
@ -985,6 +990,7 @@ main( int argc, char*argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
confidence_total += confidence;
|
confidence_total += confidence;
|
||||||
|
amplitude_total += amplitude;
|
||||||
nframes_decoded++;
|
nframes_decoded++;
|
||||||
nbits_decoded += frame_n_bits;
|
nbits_decoded += frame_n_bits;
|
||||||
noconfidence = 0;
|
noconfidence = 0;
|
||||||
|
@ -1033,7 +1039,7 @@ main( int argc, char*argv[] )
|
||||||
if ( !quiet_mode )
|
if ( !quiet_mode )
|
||||||
report_no_carrier(fskp, sample_rate, bfsk_data_rate,
|
report_no_carrier(fskp, sample_rate, bfsk_data_rate,
|
||||||
nsamples_per_bit, nframes_decoded, nbits_decoded,
|
nsamples_per_bit, nframes_decoded, nbits_decoded,
|
||||||
carrier_nsamples, confidence_total);
|
carrier_nsamples, confidence_total, amplitude_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleaudio_close(sa);
|
simpleaudio_close(sa);
|
||||||
|
|
|
@ -63,6 +63,7 @@ cmp "$textfile" $TMPF.out
|
||||||
|
|
||||||
{
|
{
|
||||||
read xlitcarrier
|
read xlitcarrier
|
||||||
|
read xlitblankline
|
||||||
read xlithashes xlitnocarrier stats
|
read xlithashes xlitnocarrier stats
|
||||||
stats="${stats% ###}"
|
stats="${stats% ###}"
|
||||||
} < $TMPF.err
|
} < $TMPF.err
|
||||||
|
|
Loading…
Reference in New Issue