From 08654e8466e974c78793007f65b9557e0203904a Mon Sep 17 00:00:00 2001 From: Kamal Mostafa Date: Sat, 4 Jun 2011 14:15:54 -0700 Subject: [PATCH] fsk: AVOID_TRANSIENTS allows for miniscule FSK_MIN_CONFIDENCE --- src/fsk.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/fsk.c b/src/fsk.c index 930a9e5..cb937ab 100644 --- a/src/fsk.c +++ b/src/fsk.c @@ -197,6 +197,15 @@ debug_log("\t\tstop "); return 0.0; v += pM - pS; +#define AVOID_TRANSIENTS 0.7 +#ifdef AVOID_TRANSIENTS + /* Compare strength of stop bit and start bit, to avoid detecting + * a transient as a start bit, as often results in a single false + * character when the mark "leader" tone begins. */ + if ( fabs( (sS - sM) - (pM - pS) ) > fabs(sS-sM) * AVOID_TRANSIENTS ) + return 0.0; +#endif + debug_log("\t\tidle "); fsk_bit_analyze(fskp, samples+begin_i_idlebit, bit_nsamples, &iM, &iS); bit = iM > iS; @@ -392,7 +401,10 @@ debug_log( "--------------------------\n"); unsigned int try_max_nsamples = nsamples_per_bit; // FIXME: explain - unsigned int try_step_nsamples = nsamples_per_bit / 4; + // THIS BREAKS ONE OF THE 1200 TESTS, WHEN I USE AVOID_TRANSIENTS... + //unsigned int try_step_nsamples = nsamples_per_bit / 4; + // BUT THIS FIXES IT AGAIN: + unsigned int try_step_nsamples = nsamples_per_bit / 8; if ( try_step_nsamples == 0 ) try_step_nsamples = 1; @@ -409,8 +421,7 @@ debug_log( "--------------------------\n"); &frame_start_sample ); -#define FSK_MIN_CONFIDENCE 0.41 -// #define FSK_MIN_CONFIDENCE 0.13 +#define FSK_MIN_CONFIDENCE 0.05 unsigned int advance;