Merge branch 'master' into issue45-demod-opts

This commit is contained in:
Charles J. Cliffe 2015-02-05 20:08:50 -05:00
commit b78b4e1b96
5 changed files with 36 additions and 6 deletions

View File

@ -3,6 +3,22 @@
#define CUBICSDR_VERSION "v0.01a"
#define CUBICSDR_TITLE "CubicSDR " CUBICSDR_VERSION " by Charles J. Cliffe (@ccliffe)"
#ifndef __BYTE_ORDER
#ifdef _WIN32
#define ATTRIBUTE
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __PDP_ENDIAN 3412
#define __BYTE_ORDER __LITTLE_ENDIAN
#else
#ifdef __APPLE__
#include <machine/endian.h>
#else
#include <endian.h>
#endif
#endif
#endif
const char filePathSeparator =
#ifdef _WIN32
'\\';

View File

@ -7,6 +7,20 @@
SDRPostThread::SDRPostThread() :
iqDataOutQueue(NULL), iqDataInQueue(NULL), iqVisualQueue(NULL), terminated(false), dcFilter(NULL), num_vis_samples(16384) {
// create a lookup table
for (unsigned int i = 0; i <= 0xffff; i++) {
liquid_float_complex tmp;
# if (__BYTE_ORDER == __LITTLE_ENDIAN)
tmp.real = (float(i & 0xff) - 127.4f) * (1.0f/128.0f);
tmp.imag = (float(i >> 8) - 127.4f) * (1.0f/128.0f);
_lut.push_back(tmp);
#else // BIG_ENDIAN
tmp.real = (float(i >> 8) - 127.4f) * (1.0f/128.0f);
tmp.imag = (float(i & 0xff) - 127.4f) * (1.0f/128.0f);
_lut.push_back(tmp);
#endif
}
}
SDRPostThread::~SDRPostThread() {
@ -82,8 +96,7 @@ void SDRPostThread::threadMain() {
}
for (int i = 0, iMax = dataSize; i < iMax; i++) {
fpData[i].real = (float) data_in->data[i * 2] / 127.0;
fpData[i].imag = (float) data_in->data[i * 2 + 1] / 127.0;
fpData[i] = _lut[*((uint16_t*)&data_in->data[2*i])];
}
iirfilt_crcf_execute_block(dcFilter, &fpData[0], dataSize, &dataOut[0]);

View File

@ -32,4 +32,7 @@ protected:
std::atomic<bool> terminated;
iirfilt_crcf dcFilter;
int num_vis_samples;
private:
std::vector<liquid_float_complex> _lut;
};

View File

@ -255,9 +255,7 @@ void SDRThread::threadMain() {
dataOut->data.resize(n_read);
}
for (int i = 0; i < n_read; i++) {
dataOut->data[i] = buf[i] - 127;
}
memcpy(&dataOut->data[0], buf, n_read);
double time_slice = (double) n_read / (double) sampleRate;
seconds += time_slice;

View File

@ -99,7 +99,7 @@ class SDRThreadIQData: public ReferenceCounter {
public:
long long frequency;
long long sampleRate;
std::vector<signed char> data;
std::vector<unsigned char> data;
SDRThreadIQData() :
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE) {