mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-08-21 14:36:21 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user