minimodem: stats report ampl={amplitude}

This commit is contained in:
Kamal Mostafa 2012-08-25 09:17:05 -07:00
parent f8434f3c94
commit dd6040336d
4 changed files with 27 additions and 13 deletions

View File

@ -178,7 +178,7 @@ fsk_bit_analyze( fsk_plan *fskp, float *samples, unsigned int bit_nsamples,
static float
fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit,
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);
@ -288,6 +288,8 @@ fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit,
// Frame confidence is the frame SNR
confidence = snr;
*ampl_outp = avg_bit_sig;
#elif CONFIDENCE_ALGO == 4
/* 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++ )
*bits_outp |= bit_values[bitnum] << bitnum;
debug_log(" frame confidence (algo #%u) = %f\n",
CONFIDENCE_ALGO, confidence);
debug_log(" frame algo=%u confidence=%f ampl=%f\n",
CONFIDENCE_ALGO, confidence, *ampl_outp);
return confidence;
}
@ -401,6 +403,7 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
float try_confidence_search_limit,
const char *expect_bits_string,
unsigned int *bits_outp,
float *ampl_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
unsigned int best_t = 0;
float best_c = 0.0;
float best_c = 0.0, best_a = 0.0;
unsigned int best_bits = 0;
// 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 )
continue;
float c;
float c, ampl_out;
unsigned int bits_out = 0;
debug_log("try fsk_frame_analyze at t=%d\n", t);
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, &ampl_out);
if ( best_c < c ) {
best_t = t;
best_c = c;
best_a = ampl_out;
best_bits = bits_out;
// If we find a frame with confidence > try_confidence_search_limit
// quit searching.
@ -444,6 +449,7 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
}
*bits_outp = best_bits;
*ampl_outp = best_a;
*frame_start_outp = best_t;
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='");
for ( j=0; j<expect_n_bits; j++ )
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 : '.',
bitchar,
confidence, best_t);
confidence, best_a, best_t);
#endif
return confidence;

View File

@ -66,6 +66,7 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
float try_confidence_search_limit,
const char *expect_bits_string,
unsigned int *bits_outp,
float *ampl_outp,
unsigned int *frame_start_outp
);

View File

@ -201,7 +201,8 @@ report_no_carrier( fsk_plan *fskp,
unsigned int nframes_decoded,
unsigned long long nbits_decoded,
size_t carrier_nsamples,
float confidence_total )
float confidence_total,
float amplitude_total )
{
#if 0
fprintf(stderr, "nframes_decoded=%u\n", nframes_decoded);
@ -211,9 +212,10 @@ report_no_carrier( fsk_plan *fskp,
#endif
float throughput_rate =
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,
confidence_total / nframes_decoded,
amplitude_total / nframes_decoded,
throughput_rate);
if ( (size_t)(nbits_decoded * nsamples_per_bit + 0.5) == carrier_nsamples ) {
fprintf(stderr, " (rate perfect) ###\n");
@ -738,6 +740,7 @@ main( int argc, char*argv[] )
int carrier = 0;
float confidence_total = 0;
float amplitude_total = 0;
unsigned int nframes_decoded = 0;
unsigned long long nbits_decoded = 0;
size_t carrier_nsamples = 0;
@ -898,7 +901,7 @@ main( int argc, char*argv[] )
if ( try_step_nsamples == 0 )
try_step_nsamples = 1;
float confidence;
float confidence, amplitude;
unsigned int bits = 0;
/* Note: frame_start_sample is actually the sample where the
* prev_stop bit begins (since the "frame" includes the prev_stop). */
@ -925,6 +928,7 @@ main( int argc, char*argv[] )
try_confidence_search_limit,
expect_bits_string,
&bits,
&amplitude,
&frame_start_sample
);
@ -943,10 +947,11 @@ main( int argc, char*argv[] )
if ( !quiet_mode )
report_no_carrier(fskp, sample_rate, bfsk_data_rate,
nsamples_per_bit, nframes_decoded, nbits_decoded,
carrier_nsamples, confidence_total);
carrier_nsamples, confidence_total, amplitude_total);
carrier = 0;
carrier_nsamples = 0;
confidence_total = 0;
amplitude_total = 0;
nframes_decoded = 0;
nbits_decoded = 0;
}
@ -985,6 +990,7 @@ main( int argc, char*argv[] )
}
confidence_total += confidence;
amplitude_total += amplitude;
nframes_decoded++;
nbits_decoded += frame_n_bits;
noconfidence = 0;
@ -1033,7 +1039,7 @@ main( int argc, char*argv[] )
if ( !quiet_mode )
report_no_carrier(fskp, sample_rate, bfsk_data_rate,
nsamples_per_bit, nframes_decoded, nbits_decoded,
carrier_nsamples, confidence_total);
carrier_nsamples, confidence_total, amplitude_total);
}
simpleaudio_close(sa);

View File

@ -63,6 +63,7 @@ cmp "$textfile" $TMPF.out
{
read xlitcarrier
read xlitblankline
read xlithashes xlitnocarrier stats
stats="${stats% ###}"
} < $TMPF.err