mirror of https://github.com/g4klx/MMDVM.git
Merge remote-tracking branch 'upstream/FM_Ext' into FM_Ext
This commit is contained in:
commit
2b3df4e901
20
FM.cpp
20
FM.cpp
|
@ -54,9 +54,11 @@ m_extAudioBoost(1U),
|
||||||
m_downsampler(1200U),// 100 ms of audio
|
m_downsampler(1200U),// 100 ms of audio
|
||||||
m_extEnabled(false),
|
m_extEnabled(false),
|
||||||
m_rxLevel(1),
|
m_rxLevel(1),
|
||||||
|
m_inputRFRB(4800U), // 200ms of audio
|
||||||
m_outputRFRB(2400U), // 100ms of audio
|
m_outputRFRB(2400U), // 100ms of audio
|
||||||
m_inputExtRB(2400U) //100ms of Audio
|
m_inputExtRB(2400U) // 100ms of Audio
|
||||||
{
|
{
|
||||||
|
insertDelay(100U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
|
void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
|
||||||
|
@ -76,6 +78,10 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
|
||||||
q15_t currentRFSample = q15_t((q31_t(samples[i]) << 8) / m_rxLevel);
|
q15_t currentRFSample = q15_t((q31_t(samples[i]) << 8) / m_rxLevel);
|
||||||
uint8_t ctcssState = m_ctcssRX.process(currentRFSample);
|
uint8_t ctcssState = m_ctcssRX.process(currentRFSample);
|
||||||
|
|
||||||
|
// Delay the audio by 100ms to better match the CTCSS detector output
|
||||||
|
m_inputRFRB.put(currentRFSample);
|
||||||
|
m_inputRFRB.get(currentRFSample);
|
||||||
|
|
||||||
q15_t currentExtSample;
|
q15_t currentExtSample;
|
||||||
bool inputExt = m_inputExtRB.get(currentExtSample);//always consume the external input data so it does not overflow
|
bool inputExt = m_inputExtRB.get(currentExtSample);//always consume the external input data so it does not overflow
|
||||||
|
|
||||||
|
@ -296,7 +302,7 @@ void CFM::stateMachine(bool validRFSignal, bool validExtSignal)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_state == FS_LISTENING && m_modemState == STATE_FM) {
|
if (m_state == FS_LISTENING && m_modemState == STATE_FM) {
|
||||||
if (!m_callsign.isRunning() && !m_rfAck.isRunning() && !m_extAck.isRunning()) {
|
if (!m_callsign.isRunning() && !m_rfAck.isRunning() && !m_extAck.isRunning() && m_outputRFRB.getData() == 0U) {
|
||||||
DEBUG1("Change to STATE_IDLE");
|
DEBUG1("Change to STATE_IDLE");
|
||||||
m_modemState = STATE_IDLE;
|
m_modemState = STATE_IDLE;
|
||||||
m_callsignTimer.stop();
|
m_callsignTimer.stop();
|
||||||
|
@ -336,6 +342,8 @@ void CFM::listeningState(bool validRFSignal, bool validExtSignal)
|
||||||
sendCallsign();
|
sendCallsign();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
insertSilence(50U);
|
||||||
|
|
||||||
beginRelaying();
|
beginRelaying();
|
||||||
|
|
||||||
m_callsignTimer.start();
|
m_callsignTimer.start();
|
||||||
|
@ -698,6 +706,14 @@ uint8_t CFM::writeData(const uint8_t* data, uint8_t length)
|
||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFM::insertDelay(uint16_t ms)
|
||||||
|
{
|
||||||
|
uint32_t nSamples = ms * 24U;
|
||||||
|
|
||||||
|
for (uint32_t i = 0U; i < nSamples; i++)
|
||||||
|
m_inputRFRB.put(0);
|
||||||
|
}
|
||||||
|
|
||||||
void CFM::insertSilence(uint16_t ms)
|
void CFM::insertSilence(uint16_t ms)
|
||||||
{
|
{
|
||||||
uint32_t nSamples = ms * 24U;
|
uint32_t nSamples = ms * 24U;
|
||||||
|
|
3
FM.h
3
FM.h
|
@ -95,6 +95,7 @@ private:
|
||||||
CFMDownsampler m_downsampler;
|
CFMDownsampler m_downsampler;
|
||||||
bool m_extEnabled;
|
bool m_extEnabled;
|
||||||
q15_t m_rxLevel;
|
q15_t m_rxLevel;
|
||||||
|
CRingBuffer<q15_t> m_inputRFRB;
|
||||||
CRingBuffer<q15_t> m_outputRFRB;
|
CRingBuffer<q15_t> m_outputRFRB;
|
||||||
CRingBuffer<q15_t> m_inputExtRB;
|
CRingBuffer<q15_t> m_inputExtRB;
|
||||||
|
|
||||||
|
@ -116,6 +117,8 @@ private:
|
||||||
|
|
||||||
void sendCallsign();
|
void sendCallsign();
|
||||||
void beginRelaying();
|
void beginRelaying();
|
||||||
|
|
||||||
|
void insertDelay(uint16_t ms);
|
||||||
void insertSilence(uint16_t ms);
|
void insertSilence(uint16_t ms);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue