mirror of https://github.com/g4klx/MMDVM.git
Avoid looping samples 2 times, convert each sample on the fly
This commit is contained in:
parent
b2dcbb2df8
commit
7befef2f4a
|
@ -109,18 +109,19 @@ uint8_t CFMCTCSSRX::setParams(uint8_t frequency, uint8_t threshold)
|
||||||
|
|
||||||
bool CFMCTCSSRX::process(q15_t* samples, uint8_t length)
|
bool CFMCTCSSRX::process(q15_t* samples, uint8_t length)
|
||||||
{
|
{
|
||||||
float32_t data[RX_BLOCK_SIZE];
|
//float32_t data[RX_BLOCK_SIZE];
|
||||||
::arm_q15_to_float(samples, data, length);
|
//::arm_q15_to_float(samples, data, length);
|
||||||
|
|
||||||
for (unsigned int i = 0U; i < length; i++) {
|
for (unsigned int i = 0U; i < length; i++) {
|
||||||
float32_t q2 = m_q1;
|
float32_t q2 = m_q1;
|
||||||
m_q1 = m_q0;
|
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++;
|
m_count++;
|
||||||
if (m_count == N) {
|
if (m_count == N) {
|
||||||
float32_t value = m_q0 * m_q0 + m_q1 * m_q1 - m_q0 * m_q1 * m_coeff;
|
float32_t value = m_q0 * m_q0 + m_q1 * m_q1 - m_q0 * m_q1 * m_coeff;
|
||||||
m_result = value >= m_threshold;
|
m_result = value >= m_threshold;
|
||||||
|
DEBUG4("CTCSS value / threshold / result", value, m_threshold, m_result);
|
||||||
m_count = 0U;
|
m_count = 0U;
|
||||||
m_q0 = 0.0F;
|
m_q0 = 0.0F;
|
||||||
m_q1 = 0.0F;
|
m_q1 = 0.0F;
|
||||||
|
|
Loading…
Reference in New Issue