From 7befef2f4a690761dfd569931e8f4f6e6226a40e Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Tue, 21 Apr 2020 18:41:27 +0200 Subject: [PATCH] Avoid looping samples 2 times, convert each sample on the fly --- FMCTCSSRX.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/FMCTCSSRX.cpp b/FMCTCSSRX.cpp index d6a529a..de69ff5 100644 --- a/FMCTCSSRX.cpp +++ b/FMCTCSSRX.cpp @@ -109,18 +109,19 @@ uint8_t CFMCTCSSRX::setParams(uint8_t frequency, uint8_t threshold) bool CFMCTCSSRX::process(q15_t* samples, uint8_t length) { - float32_t data[RX_BLOCK_SIZE]; - ::arm_q15_to_float(samples, data, length); + //float32_t data[RX_BLOCK_SIZE]; + //::arm_q15_to_float(samples, data, length); for (unsigned int i = 0U; i < length; i++) { float32_t q2 = m_q1; m_q1 = m_q0; - m_q0 = m_coeff * m_q1 - q2 + data[i]; + m_q0 = m_coeff * m_q1 - q2 + float32_t(samples[i]) / 32768.0F; m_count++; if (m_count == N) { float32_t value = m_q0 * m_q0 + m_q1 * m_q1 - m_q0 * m_q1 * m_coeff; m_result = value >= m_threshold; + DEBUG4("CTCSS value / threshold / result", value, m_threshold, m_result); m_count = 0U; m_q0 = 0.0F; m_q1 = 0.0F;