diff --git a/FM.cpp b/FM.cpp index f6da336..1aaf0be 100644 --- a/FM.cpp +++ b/FM.cpp @@ -83,8 +83,8 @@ void CFM::samples(bool cos, q15_t* samples, uint8_t length) // Only let audio through when relaying audio if (m_state == FS_RELAYING || m_state == FS_KERCHUNK) { - currentSample = m_deemphasis.filter(currentSample); - m_downsampler.addSample(currentSample); + // currentSample = m_deemphasis.filter(currentSample); + // m_downsampler.addSample(currentSample); currentSample = m_blanking.process(currentSample); currentSample *= m_rfAudioBoost; } else { @@ -106,7 +106,7 @@ void CFM::samples(bool cos, q15_t* samples, uint8_t length) currentSample = m_filterStage3.filter(m_filterStage2.filter(m_filterStage1.filter(currentSample))); - currentSample = m_preemphasis.filter(currentSample); + // currentSample = m_preemphasis.filter(currentSample); currentSample += m_ctcssTX.getAudio(); diff --git a/FMCTCSSRX.cpp b/FMCTCSSRX.cpp index 9e81d3c..f3f9047 100644 --- a/FMCTCSSRX.cpp +++ b/FMCTCSSRX.cpp @@ -93,7 +93,7 @@ m_rxLevelInverse(1) uint8_t CFMCTCSSRX::setParams(uint8_t frequency, uint8_t threshold, uint8_t level) { - m_rxLevelInverse = 511 / q15_t(level); + m_rxLevelInverse = q15Division(65535, q15_t(level * 128)); m_coeffDivTwo = 0; @@ -179,3 +179,17 @@ void CFMCTCSSRX::reset() m_result = CTS_NONE; m_count = 0U; } + +//Taken from https://en.wikipedia.org/wiki/Q_(number_format)#Division +q15_t CFMCTCSSRX::q15Division(q15_t a, q15_t divisor) +{ + q31_t a31 = q31_t(a) << 16; + + if (((a >> 31) & 1) == ((divisor >> 15) & 1)) + a31 += divisor >> 1; + else + a31 -= divisor >> 1; + + return a31 / divisor; +} + diff --git a/FMCTCSSRX.h b/FMCTCSSRX.h index 4c1dfc3..b5fea60 100644 --- a/FMCTCSSRX.h +++ b/FMCTCSSRX.h @@ -62,6 +62,8 @@ public: void reset(); private: + q15_t q15Division(q15_t a, q15_t divisor); + q63_t m_coeffDivTwo; q31_t m_threshold; uint16_t m_count; diff --git a/SerialPort.cpp b/SerialPort.cpp index c45634d..3baa55b 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -101,7 +101,7 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U; #define HW_TYPE "MMDVM" #endif -#define DESCRIPTION "20200429 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)" +#define DESCRIPTION "20200501 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)" #if defined(GITVERSION) #define concat(h, a, b, c) h " " a " " b " GitID #" c ""