Fix complilation on Linux.

This commit is contained in:
Jonathan Naylor 2020-07-27 10:58:32 +01:00
parent da077c73f8
commit 15c21de416
9 changed files with 24 additions and 30 deletions

View File

@ -136,9 +136,8 @@ unsigned int CFMControl::readModem(unsigned char* data, unsigned int space)
if (space > 252U)
space = 252U;
unsigned short netData[168U]; // Modem can handle up to 168 samples at a time
unsigned int length = m_network->read((unsigned char*)netData, 168U * sizeof(unsigned short));
length /= sizeof(unsigned short);
float netData[168U]; // Modem can handle up to 168 samples at a time
unsigned int length = m_network->read(netData, 168U);
if (length == 0U)
return 0U;
@ -147,13 +146,8 @@ unsigned int CFMControl::readModem(unsigned char* data, unsigned int space)
unsigned int nData = 0U;
for (unsigned int i = 0; i < length; i++) {
unsigned short netSample = SWAP_BYTES_16(netData[i]);
// Convert the unsigned 16-bit data (+65535 - 0) to float (+1.0 - -1.0)
float sampleFloat = (float(netSample) / 32768.0F) - 1.0F;
//preemphasis
sampleFloat = m_preemphasis->filter(sampleFloat);
// Pre-emphasis
float sampleFloat = m_preemphasis->filter(netData[i]);
// Convert float to 12-bit samples (0 to 4095)
unsigned int sample12bit = (unsigned int)((sampleFloat + 1.0F) * 2048.0F + 0.5F);

View File

@ -69,7 +69,7 @@ bool CFMNetwork::open()
return m_socket.open();
}
bool CFMNetwork::writeData(const float* data, unsigned int nSamples)
bool CFMNetwork::writeData(float* data, unsigned int nSamples)
{
assert(m_outgoing != NULL);
assert(data != NULL);
@ -193,9 +193,9 @@ unsigned int CFMNetwork::read(float* data, unsigned int nSamples)
if (m_sampleRate != 8000U) {
float in[750U];
unsigned int j = 0U;
for (unsigned int i = 0U; i < nSamples; i++) {
unsigned short val = ((buffer[j++] & 0xFFU) << 8) + ((buffer[j++] & 0xFFU) << 0);
unsigned short val = ((buffer[i * 2U + 0U] & 0xFFU) << 8) +
((buffer[i * 2U + 1U] & 0xFFU) << 0);
in[i] = (float(val) - 32768.0F) / 32768.0F;
}
@ -214,9 +214,9 @@ unsigned int CFMNetwork::read(float* data, unsigned int nSamples)
return src.output_frames_gen;
} else {
unsigned int j = 0U;
for (unsigned int i = 0U; i < nSamples; i++) {
unsigned short val = ((buffer[j++] & 0xFFU) << 8) + ((buffer[j++] & 0xFFU) << 0);
unsigned short val = ((buffer[i * 2U + 0U] & 0xFFU) << 8) +
((buffer[i * 2U + 1U] & 0xFFU) << 0);
data[i] = (float(val) - 32768.0F) / 32768.0F;
}

View File

@ -37,11 +37,11 @@ public:
void enable(bool enabled);
bool writeData(const float* data, unsigned int nSamples);
bool writeData(float* data, unsigned int nSamples);
bool writeEOT();
bool writeEOT();
unsigned int read(float* data, unsigned int nSamples);
unsigned int read(float* data, unsigned int nSamples);
void reset();

View File

@ -5,11 +5,11 @@ CXX = c++
# Use the following CFLAGS and LIBS if you don't want to use gpsd.
CFLAGS = -g -O3 -Wall -std=c++0x -pthread
LIBS = -lpthread -lutil
LIBS = -lpthread -lutil -lsamplerate
# Use the following CFLAGS and LIBS if you do want to use gpsd.
#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread
#LIBS = -lpthread -lgps -lutil
#LIBS = -lpthread -lgps -lutil -lsamplerate
LDFLAGS = -g

View File

@ -4,11 +4,11 @@ CC = gcc
CXX = g++
# Use the following CFLAGS and LIBS if you don't want to use gpsd.
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate
# Use the following CFLAGS and LIBS if you do want to use gpsd.
#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include
#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps -lutil
#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps -lutil -lsamplerate
LDFLAGS = -g -L/usr/local/lib

View File

@ -5,11 +5,11 @@ CC = gcc
CXX = g++
# Use the following CFLAGS and LIBS if you don't want to use gpsd.
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate
# Use the following CFLAGS and LIBS if you do want to use gpsd.
#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include
#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps -lutil
#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps -lutil -lsamplerate
LDFLAGS = -g -L/usr/local/lib

View File

@ -5,11 +5,11 @@ CXX = g++
# Use the following CFLAGS and LIBS if you don't want to use gpsd.
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -I/usr/local/include
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate
# Use the following CFLAGS and LIBS if you do want to use gpsd.
#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -I/usr/local/include
#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps -lutil
#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps -lutil -lsamplerate
LDFLAGS = -g -L/usr/local/lib

View File

@ -5,11 +5,11 @@ CXX = g++
# Use the following CFLAGS and LIBS if you don't want to use gpsd.
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DOLED -I/usr/local/include
LIBS = -lArduiPi_OLED -lwiringPi -lpthread -lutil
LIBS = -lArduiPi_OLED -lwiringPi -lpthread -lutil -lsamplerate
# Use the following CFLAGS and LIBS if you do want to use gpsd.
#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DOLED -I/usr/local/include
#LIBS = -lArduiPi_OLED -lwiringPi -lpthread -lgps -lutil
#LIBS = -lArduiPi_OLED -lwiringPi -lpthread -lgps -lutil -lsamplerate
LDFLAGS = -g -L/usr/local/lib

View File

@ -6,11 +6,11 @@ CXX = g++
# Use the following CFLAGS and LIBS if you don't want to use gpsd.
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate
# Use the following CFLAGS and LIBS if you do want to use gpsd.
#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include
#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps -lutil
#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps -lutil -lsamplerate
LDFLAGS = -g -L/usr/local/lib