Merge pull request #267 from F4FXL/FM_Ext

Write Audio to serial
This commit is contained in:
Jonathan Naylor 2020-05-12 19:00:09 +01:00 committed by GitHub
commit 2cc6c1f68f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

14
FM.cpp
View File

@ -21,7 +21,8 @@
#include "FM.h" #include "FM.h"
const uint16_t FM_TX_BLOCK_SIZE = 400U; const uint16_t FM_TX_BLOCK_SIZE = 400U;
const uint16_t FM_SERIAL_BLOCK_SIZE = 126U; const uint16_t FM_SERIAL_BLOCK_SIZE = 42U;//this is actually the number of sample pairs to send over serial. One sample pair is 3bytes.
//three times this vqlue shall never exceed 126 !
CFM::CFM() : CFM::CFM() :
m_callsign(), m_callsign(),
@ -117,6 +118,9 @@ void CFM::samples(bool cos, q15_t* samples, uint8_t length)
// Only let RF audio through when relaying RF audio // Only let RF audio through when relaying RF audio
if (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF || m_state == FS_RELAYING_EXT || m_state == FS_KERCHUNK_EXT) { if (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF || m_state == FS_RELAYING_EXT || m_state == FS_KERCHUNK_EXT) {
currentSample = m_blanking.process(currentSample); currentSample = m_blanking.process(currentSample);
if (m_extEnabled && (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF))
m_downsampler.addSample(currentSample);
currentSample *= currentBoost; currentSample *= currentBoost;
} else { } else {
currentSample = 0; currentSample = 0;
@ -166,15 +170,17 @@ void CFM::process()
m_outputRFRB.get(sample); m_outputRFRB.get(sample);
samples[i] = sample; samples[i] = sample;
if(m_extEnabled && (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF)) { if(m_extEnabled) {
m_downsampler.addSample(sample);
uint16_t downSamplerLength = m_downsampler.getData(); uint16_t downSamplerLength = m_downsampler.getData();
if(downSamplerLength >= FM_SERIAL_BLOCK_SIZE) { if(downSamplerLength >= FM_SERIAL_BLOCK_SIZE) {
TSamplePairPack serialSamples[FM_SERIAL_BLOCK_SIZE]; TSamplePairPack serialSamples[FM_SERIAL_BLOCK_SIZE];
for(uint16_t j = 0U; j < downSamplerLength; j++) { for(uint16_t j = 0U; j < downSamplerLength; j++) {
m_downsampler.getPackedData(serialSamples[j]); m_downsampler.getPackedData(serialSamples[j]);
} }
serial.writeFMData((uint8_t*)serialSamples, txLength * sizeof(TSamplePairPack));
serial.writeFMData((uint8_t*)serialSamples, downSamplerLength * sizeof(TSamplePairPack));
} }
} }
} }