Anti-alias filter before RF->network downsampling in FM mode

The 24kHz->8kHz decimation in CFMDownSampler had no lowpass ahead of
it, aliasing everything above 4kHz back into the audio band. Reuse
the existing 300-2700Hz filter design (separate instance/state) ahead
of all three addSample() call sites in FM.cpp.

Also: reset() wasn't clearing the ring buffer or in-progress sample
pack, so stale audio could bleed into the next transmission. And
addSample() packed samples into 12 bits with no saturation, so an
out-of-range value corrupted the neighbouring sample.
This commit is contained in:
Cort Buffington
2026-08-11 09:57:47 -05:00
parent 894ba76432
commit 4c7e8fbe46
3 changed files with 23 additions and 6 deletions
+3
View File
@@ -34,6 +34,7 @@ m_sampleIndex(0U)
void CFMDownSampler::addSample(q15_t sample)
{
sample = __SSAT(sample, 12);//clamp before packing to 12 bits
uint32_t usample = uint32_t(int32_t(sample) + 2048);
//only take one of three samples
switch(m_sampleIndex){
@@ -74,6 +75,8 @@ uint16_t CFMDownSampler::getData()
void CFMDownSampler::reset()
{
m_sampleIndex = 0U;
m_samplePack = 0U;
m_ringBuffer.reset();
}
#endif