Add de and pre emphasis

This commit is contained in:
Geoffrey Merck 2020-04-29 20:42:20 +02:00
parent da87afc8d4
commit b23620ede3
4 changed files with 68 additions and 2 deletions

8
FM.cpp
View file

@ -36,9 +36,11 @@ m_kerchunkTimer(),
m_ackMinTimer(),
m_ackDelayTimer(),
m_hangTimer(),
m_filterStage1( 724, 1448, 724, 32768, -37895, 21352),//3rd order Cheby Filter 300 to 2700Hz, 0.2dB passband ripple
m_filterStage1( 724, 1448, 724, 32768, -37895, 21352),//3rd order Cheby Filter 300 to 2700Hz, 0.2dB passband ripple, sampling rate 24kHz
m_filterStage2(32768, 0,-32768, 32768, -50339, 19052),
m_filterStage3(32768, -65536, 32768, 32768, -64075, 31460),
m_preemphasis(32768, 13967, 0, 32768, -18801, 0),//75µS 24kHz sampling rate
m_deemphasis (32768, -18801, 0, 32768, 13967, 0),//75µS 24kHz sampling rate
m_blanking(),
m_useCOS(true),
m_rfAudioBoost(1U),
@ -79,6 +81,8 @@ void CFM::samples(bool cos, q15_t* samples, uint8_t length)
stateMachine(validCTCSS && cos, i + 1U);
}
currentSample = m_deemphasis.filter(currentSample);
// Only let audio through when relaying audio
if (m_state == FS_RELAYING || m_state == FS_KERCHUNK) {
m_downsampler.addSample(currentSample);
@ -104,6 +108,8 @@ 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_ctcssTX.getAudio();
samples[i] = currentSample;