Avoid looping samples 2 times, convert each sample on the fly

This commit is contained in:
Geoffrey Merck 2020-04-21 18:41:27 +02:00
parent b2dcbb2df8
commit 7befef2f4a
1 changed files with 4 additions and 3 deletions

View File

@ -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;