mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-04-05 14:37:02 +00:00
Merge remote-tracking branch 'upstream/FM' into FM_Ext
This commit is contained in:
commit
e0234dfc00
6 changed files with 228 additions and 12 deletions
47
FM.cpp
47
FM.cpp
|
|
@ -51,13 +51,13 @@ m_useCOS(true),
|
|||
m_cosInvert(false),
|
||||
m_rfAudioBoost(1U),
|
||||
m_extAudioBoost(1U),
|
||||
m_downsampler(128U), //Size might need adjustement
|
||||
m_extEnabled(false),
|
||||
m_rxLevel(1)
|
||||
m_downsampler(128U),//Size might need adjustement
|
||||
m_rxLevel(1),
|
||||
m_outputRB(2400U) // 100ms of audio
|
||||
{
|
||||
}
|
||||
|
||||
void CFM::samples(bool cos, q15_t* samples, uint8_t length)
|
||||
void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
|
||||
{
|
||||
if (m_useCOS) {
|
||||
if (m_cosInvert)
|
||||
|
|
@ -135,15 +135,34 @@ void CFM::samples(bool cos, q15_t* samples, uint8_t length)
|
|||
|
||||
currentSample += m_ctcssTX.getAudio();
|
||||
|
||||
samples[i] = currentSample;
|
||||
if (m_modemState == STATE_FM)
|
||||
m_outputRB.put(currentSample);
|
||||
}
|
||||
|
||||
if (m_modemState == STATE_FM)
|
||||
io.write(STATE_FM, samples, i);//only write the actual number of processed samples to IO
|
||||
}
|
||||
|
||||
void CFM::process()
|
||||
{
|
||||
if (m_modemState != STATE_FM)
|
||||
return;
|
||||
|
||||
uint16_t length = m_outputRB.getData();
|
||||
if (length == 0U)
|
||||
return;
|
||||
|
||||
uint16_t space = io.getSpace();
|
||||
if (space < 3U)
|
||||
return;
|
||||
|
||||
space -= 2U;
|
||||
|
||||
if (space < length)
|
||||
length = space;
|
||||
|
||||
for (uint16_t i = 0U; i < length; i++) {
|
||||
q15_t sample;
|
||||
m_outputRB.get(sample);
|
||||
io.write(STATE_FM, &sample, 1U);
|
||||
}
|
||||
}
|
||||
|
||||
void CFM::reset()
|
||||
|
|
@ -162,6 +181,8 @@ void CFM::reset()
|
|||
m_extAck.stop();
|
||||
m_callsign.stop();
|
||||
m_timeoutTone.stop();
|
||||
|
||||
m_outputRB.reset();
|
||||
}
|
||||
|
||||
uint8_t CFM::setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch)
|
||||
|
|
@ -328,6 +349,8 @@ void CFM::listeningState(bool validRFSignal, bool validExtSignal)
|
|||
sendCallsign();
|
||||
}
|
||||
|
||||
insertSilence(50U);
|
||||
|
||||
beginRelaying();
|
||||
|
||||
m_callsignTimer.start();
|
||||
|
|
@ -664,3 +687,11 @@ uint8_t CFM::writeData(const uint8_t* data, uint8_t length)
|
|||
|
||||
return 0U;
|
||||
}
|
||||
|
||||
void CFM::insertSilence(uint16_t ms)
|
||||
{
|
||||
uint32_t nSamples = ms * 24U;
|
||||
|
||||
for (uint32_t i = 0U; i < nSamples; i++)
|
||||
m_outputRB.put(0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue