From aada4848c15e14560df7b652dcbdd447be094ee8 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 13 Mar 2026 01:45:17 +0000 Subject: spkmodem-decode: fix single-tone learning bug enforce at least two tones. this mitigates the chance of random noise being treated as a real tone, and reduces the chance of broken thresholds versus freq min/max e.g. freq min 31, max 32 and threshold 31 Signed-off-by: Leah Rowe --- util/spkmodem_decode/spkmodem-decode.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util') diff --git a/util/spkmodem_decode/spkmodem-decode.c b/util/spkmodem_decode/spkmodem-decode.c index af60f997..a1a197bc 100644 --- a/util/spkmodem_decode/spkmodem-decode.c +++ b/util/spkmodem_decode/spkmodem-decode.c @@ -571,6 +571,14 @@ detect_tone(struct decoder_state *st) if (st->learn_frames != LEARN_FRAMES) return; + /* + * If the observed frequencies are too close, + * learning likely failed (only one tone seen). + * Keep the default threshold. + */ + if (st->freq_max - st->freq_min < 2) + return; + st->freq_threshold = (st->freq_min + st->freq_max) / 2; -- cgit v1.2.1