From 979db74ca5768f6757a82ac2654e40caf183a66b Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 4 Jun 2023 15:10:35 +0100 Subject: util/spkmodem-recv: simplify pulse check Signed-off-by: Leah Rowe --- util/spkmodem_recv/spkmodem-recv.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c index d13d8c7d..1dcf5f18 100644 --- a/util/spkmodem_recv/spkmodem-recv.c +++ b/util/spkmodem_recv/spkmodem-recv.c @@ -98,16 +98,11 @@ fetch_sample(void) != sizeof(frame[0])) err(errno = ECANCELED, "Could not read frame."); - if (abs(frame[ringpos]) > THRESHOLD) { /* rising/falling edge(pulse) */ - pulse[ringpos] = 1; - f2++; - } else { - pulse[ringpos] = 0; - } - - ringpos++; + pulse[ringpos] = (abs(frame[ringpos]) > THRESHOLD) ? 1 : 0; + if (pulse[ringpos++]) + ++f2; ringpos %= 2 * SAMPLES_PER_FRAME; - lp++; + ++lp; } void -- cgit v1.2.1