diff --git a/src/fsk.c b/src/fsk.c index 9d86aea..96288b4 100644 --- a/src/fsk.c +++ b/src/fsk.c @@ -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 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> 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; diff --git a/src/fsk.h b/src/fsk.h index c94f433..8089a04 100644 --- a/src/fsk.h +++ b/src/fsk.h @@ -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 ); diff --git a/src/minimodem.c b/src/minimodem.c index 4573330..8f9ab39 100644 --- a/src/minimodem.c +++ b/src/minimodem.c @@ -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, + &litude, &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); diff --git a/tests/self-test b/tests/self-test index 11ca927..9d2a969 100755 --- a/tests/self-test +++ b/tests/self-test @@ -63,6 +63,7 @@ cmp "$textfile" $TMPF.out { read xlitcarrier + read xlitblankline read xlithashes xlitnocarrier stats stats="${stats% ###}" } < $TMPF.err