diff --git a/FMControl.cpp b/FMControl.cpp index c1d3fd0..bc1e0b0 100644 --- a/FMControl.cpp +++ b/FMControl.cpp @@ -22,6 +22,7 @@ #define EMPHASIS_GAIN_DB 0 //Gain needs to be the same for pre an deeemphasis #define RF_AUDIO_SAMP_RATE 8000 +#define FM_AUDIO_BLOCK_SIZE 240 CFMControl::CFMControl(CFMNetwork* network) : m_network(network), @@ -55,14 +56,16 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length) m_incomingRFAudio.addData(data + 1U, length - 1U); unsigned int bufferLength = m_incomingRFAudio.dataSize(); + if(bufferLength > 255U) + bufferLength = 255U; if (bufferLength >= 3U) { bufferLength = bufferLength - bufferLength % 3U; //round down to nearest multiple of 3 - unsigned char bufferData[bufferLength]; + unsigned char bufferData[255]; m_incomingRFAudio.getData(bufferData, bufferLength); // Unpack the serial data into float values. - for (unsigned int i = 0U; i < length; i += 3U) { + for (unsigned int i = 0U; i < bufferLength; i += 3U) { unsigned short sample1 = 0U; unsigned short sample2 = 0U; unsigned int MASK = 0x00000FFFU;