mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-02-21 04:58:39 -05:00
Added LUT for IQ mapping with proper scaling
This commit is contained in:
parent
b4e4f3017f
commit
a2c6e0bf91
@ -2,11 +2,27 @@
|
|||||||
#include "CubicSDRDefs.h"
|
#include "CubicSDRDefs.h"
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
|
|
||||||
|
#include <complex.h>
|
||||||
|
#include <endian.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
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 +98,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;
|
||||||
};
|
};
|
||||||
|
@ -256,7 +256,7 @@ void SDRThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < n_read; i++) {
|
for (int i = 0; i < n_read; i++) {
|
||||||
dataOut->data[i] = buf[i] - 127;
|
dataOut->data[i] = buf[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
double time_slice = (double) n_read / (double) sampleRate;
|
double time_slice = (double) n_read / (double) sampleRate;
|
||||||
|
@ -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