Merge branch 'M17_AX25_FM' into I2C
This commit is contained in:
commit
8575b0188d
2 changed files with 27 additions and 27 deletions
|
@ -26,9 +26,9 @@
|
|||
|
||||
#define SWAP_BYTES_16(a) (((a >> 8) & 0x00FFU) | ((a << 8) & 0xFF00U))
|
||||
|
||||
const float DEEMPHASIS_GAIN_DB = 0.0F;
|
||||
const float PREEMPHASIS_GAIN_DB = 13.0F;
|
||||
const float FILTER_GAIN_DB = 0.0F;
|
||||
const float DEEMPHASIS_GAIN_DB = 8.0F; // Audio gain adjustment
|
||||
const float PREEMPHASIS_GAIN_DB = 0.0F; // Audio gain adjustment
|
||||
const float FILTER_GAIN_DB = 2.0F; // Audio gain adjustment
|
||||
const unsigned int FM_MASK = 0x00000FFFU;
|
||||
|
||||
CFMControl::CFMControl(CFMNetwork* network) :
|
||||
|
@ -79,17 +79,17 @@ 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 > 252U)//168 samples 12-bit
|
||||
bufferLength = 252U;
|
||||
if (bufferLength > 240U) //160 samples 12-bit
|
||||
bufferLength = 240U; //160 samples 12-bit
|
||||
|
||||
if (bufferLength >= 3U) {
|
||||
bufferLength = bufferLength - bufferLength % 3U; //round down to nearest multiple of 3
|
||||
unsigned char bufferData[252U];
|
||||
unsigned char bufferData[240U]; //160 samples 12-bit
|
||||
m_incomingRFAudio.getData(bufferData, bufferLength);
|
||||
|
||||
unsigned int pack = 0U;
|
||||
unsigned char* packPointer = (unsigned char*)&pack;
|
||||
float out[168U];
|
||||
float out[160U]; //160 samples 12-bit
|
||||
unsigned int nOut = 0U;
|
||||
short unpackedSamples[2U];
|
||||
|
||||
|
@ -99,7 +99,7 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
|
|||
packPointer[1U] = bufferData[i + 1U];
|
||||
packPointer[2U] = bufferData[i + 2U];
|
||||
unpackedSamples[1U] = short(int(pack & FM_MASK) - 2048);
|
||||
unpackedSamples[0U] = short(int(pack >> 12) - 2048);
|
||||
unpackedSamples[0U] = short(int(pack >> 12 & FM_MASK) - 2048); //
|
||||
|
||||
//process unpacked sample pair
|
||||
for (unsigned char j = 0U; j < 2U; j++) {
|
||||
|
@ -133,11 +133,11 @@ unsigned int CFMControl::readModem(unsigned char* data, unsigned int space)
|
|||
if (m_network == NULL)
|
||||
return 0U;
|
||||
|
||||
if (space > 252U)
|
||||
space = 252U;
|
||||
if (space > 240U) //160 samples 12-bit
|
||||
space = 240U; //160 samples 12-bit
|
||||
|
||||
float netData[168U]; // Modem can handle up to 168 samples at a time
|
||||
unsigned int length = m_network->read(netData, 168U);
|
||||
float netData[160U]; // Modem can handle up to 160 samples at a time
|
||||
unsigned int length = m_network->read(netData, 160U); //160 samples 12-bit
|
||||
if (length == 0U)
|
||||
return 0U;
|
||||
|
||||
|
|
|
@ -117,14 +117,14 @@ bool CFMNetwork::writeData(float* data, unsigned int nSamples)
|
|||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
for (long i = 0L; i < nSamples; i++) {
|
||||
unsigned short val = (unsigned short)((data[i] + 1.0F) * 32767.0F + 0.5F);
|
||||
short val = ( short)((data[i] ) * 32767.0F); // Changing audio format from U16BE to S16LE
|
||||
#else
|
||||
for (long i = 0L; i < src.output_frames_gen; i++) {
|
||||
unsigned short val = (unsigned short)((src.data_out[i] + 1.0F) * 32767.0F + 0.5F);
|
||||
short val = ( short)((src.data_out[i] ) * 32767.0F ); // Changing audio format from U16BE to S16LE
|
||||
#endif
|
||||
|
||||
buffer[length++] = (val >> 8) & 0xFFU;
|
||||
buffer[length++] = (val >> 0) & 0xFFU;
|
||||
buffer[length++] = (val >> 0) & 0xFFU; // changing from BE to LE
|
||||
buffer[length++] = (val >> 8) & 0xFFU; // changing from BE to LE
|
||||
}
|
||||
|
||||
if (m_debug)
|
||||
|
@ -164,11 +164,11 @@ void CFMNetwork::clock(unsigned int ms)
|
|||
if (length <= 0)
|
||||
return;
|
||||
|
||||
// Check if the data is for us
|
||||
if (!CUDPSocket::match(addr, m_addr)) {
|
||||
LogMessage("FM packet received from an invalid source");
|
||||
return;
|
||||
}
|
||||
// Check if the data is for us // does not accept data from USRP
|
||||
//if (!CUDPSocket::match(addr, m_addr)) {
|
||||
// LogMessage("FM packet received from an invalid source");
|
||||
// return;
|
||||
//}
|
||||
|
||||
// Ignore incoming polls
|
||||
if (::memcmp(buffer, "FMP", 3U) == 0)
|
||||
|
@ -211,9 +211,9 @@ unsigned int CFMNetwork::read(float* data, unsigned int nSamples)
|
|||
float in[750U];
|
||||
|
||||
for (unsigned int i = 0U; i < nSamples; i++) {
|
||||
unsigned short val = ((buffer[i * 2U + 0U] & 0xFFU) << 8) +
|
||||
((buffer[i * 2U + 1U] & 0xFFU) << 0);
|
||||
in[i] = (float(val) - 32768.0F) / 32768.0F;
|
||||
short val = ((buffer[i * 2U + 0U] & 0xFFU) << 0) + // Changing audio format from U16BE to S16LE
|
||||
((buffer[i * 2U + 1U] & 0xFFU) << 8); // Changing audio format from U16BE to S16LE
|
||||
in[i] = (float(val) / 65536.0F); // Changing audio format from U16BE to S16LE
|
||||
}
|
||||
|
||||
src.data_in = in;
|
||||
|
@ -233,9 +233,9 @@ unsigned int CFMNetwork::read(float* data, unsigned int nSamples)
|
|||
} else {
|
||||
#endif
|
||||
for (unsigned int i = 0U; i < nSamples; i++) {
|
||||
unsigned short val = ((buffer[i * 2U + 0U] & 0xFFU) << 8) +
|
||||
((buffer[i * 2U + 1U] & 0xFFU) << 0);
|
||||
data[i] = (float(val) - 32768.0F) / 32768.0F;
|
||||
short val = ((buffer[i * 2U + 0U] & 0xFFU) << 0) + // Changing audio format from U16BE to S16LE
|
||||
((buffer[i * 2U + 1U] & 0xFFU) << 8); // Changing audio format from U16BE to S16LE
|
||||
data[i] = (float(val) / 65536.0F); // Changing audio format from U16BE to S16LE
|
||||
}
|
||||
|
||||
return nSamples;
|
||||
|
|
Loading…
Reference in a new issue