mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-15 16:41:54 -05:00
Merge pull request #50 from cjcliffe/mryndzionek-master
@mryndzionek - Added LUT for IQ mapping with proper scaling
This commit is contained in:
commit
ec306eea64
@ -3,6 +3,22 @@
|
|||||||
#define CUBICSDR_VERSION "v0.01a"
|
#define CUBICSDR_VERSION "v0.01a"
|
||||||
#define CUBICSDR_TITLE "CubicSDR " CUBICSDR_VERSION " by Charles J. Cliffe (@ccliffe)"
|
#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 =
|
const char filePathSeparator =
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
'\\';
|
'\\';
|
||||||
|
@ -7,6 +7,20 @@
|
|||||||
|
|
||||||
SDRPostThread::SDRPostThread() :
|
SDRPostThread::SDRPostThread() :
|
||||||
iqDataOutQueue(NULL), iqDataInQueue(NULL), iqVisualQueue(NULL), terminated(false), dcFilter(NULL), num_vis_samples(16384) {
|
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() {
|
SDRPostThread::~SDRPostThread() {
|
||||||
@ -82,8 +96,7 @@ void SDRPostThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, iMax = dataSize; i < iMax; i++) {
|
for (int i = 0, iMax = dataSize; i < iMax; i++) {
|
||||||
fpData[i].real = (float) data_in->data[i * 2] / 127.0;
|
fpData[i] = _lut[*((uint16_t*)&data_in->data[2*i])];
|
||||||
fpData[i].imag = (float) data_in->data[i * 2 + 1] / 127.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iirfilt_crcf_execute_block(dcFilter, &fpData[0], dataSize, &dataOut[0]);
|
iirfilt_crcf_execute_block(dcFilter, &fpData[0], dataSize, &dataOut[0]);
|
||||||
|
@ -32,4 +32,7 @@ protected:
|
|||||||
std::atomic<bool> terminated;
|
std::atomic<bool> terminated;
|
||||||
iirfilt_crcf dcFilter;
|
iirfilt_crcf dcFilter;
|
||||||
int num_vis_samples;
|
int num_vis_samples;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<liquid_float_complex> _lut;
|
||||||
};
|
};
|
||||||
|
@ -255,9 +255,7 @@ void SDRThread::threadMain() {
|
|||||||
dataOut->data.resize(n_read);
|
dataOut->data.resize(n_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < n_read; i++) {
|
memcpy(&dataOut->data[0], buf, n_read);
|
||||||
dataOut->data[i] = buf[i] - 127;
|
|
||||||
}
|
|
||||||
|
|
||||||
double time_slice = (double) n_read / (double) sampleRate;
|
double time_slice = (double) n_read / (double) sampleRate;
|
||||||
seconds += time_slice;
|
seconds += time_slice;
|
||||||
|
@ -99,7 +99,7 @@ class SDRThreadIQData: public ReferenceCounter {
|
|||||||
public:
|
public:
|
||||||
long long frequency;
|
long long frequency;
|
||||||
long long sampleRate;
|
long long sampleRate;
|
||||||
std::vector<signed char> data;
|
std::vector<unsigned char> data;
|
||||||
|
|
||||||
SDRThreadIQData() :
|
SDRThreadIQData() :
|
||||||
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE) {
|
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user