mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2026-04-19 14:52:43 +00:00
added stuff idk
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
namespace cdsp {
|
||||
class FMDemodulator {
|
||||
public:
|
||||
FMDemodulator() {
|
||||
|
||||
}
|
||||
|
||||
FMDemodulator(stream<complex_t>* in, float deviation, long sampleRate, int bufferSize) : output(bufferSize * 2) {
|
||||
_input = in;
|
||||
_bufferSize = bufferSize;
|
||||
@@ -14,6 +18,14 @@ namespace cdsp {
|
||||
_phasorSpeed = (2 * 3.1415926535) / (sampleRate / deviation);
|
||||
}
|
||||
|
||||
void init(stream<complex_t>* in, float deviation, long sampleRate, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
_input = in;
|
||||
_bufferSize = bufferSize;
|
||||
_phase = 0.0f;
|
||||
_phasorSpeed = (2 * 3.1415926535) / (sampleRate / deviation);
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,21 @@ namespace cdsp {
|
||||
|
||||
class RawFileSource {
|
||||
public:
|
||||
RawFileSource() {
|
||||
|
||||
}
|
||||
|
||||
RawFileSource(std::string path, int bufferSize) : output(bufferSize * 2) {
|
||||
_bufferSize = bufferSize;
|
||||
_file = std::ifstream(path.c_str(), std::ios::in | std::ios::binary);
|
||||
}
|
||||
|
||||
void init(std::string path, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
_bufferSize = bufferSize;
|
||||
_file = std::ifstream(path.c_str(), std::ios::in | std::ios::binary);
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
@@ -50,12 +60,22 @@ namespace cdsp {
|
||||
|
||||
class RawFileSink {
|
||||
public:
|
||||
RawFileSink() {
|
||||
|
||||
}
|
||||
|
||||
RawFileSink(std::string path, stream<float>* in, int bufferSize) {
|
||||
_bufferSize = bufferSize;
|
||||
_input = in;
|
||||
_file = std::ofstream(path.c_str(), std::ios::out | std::ios::binary);
|
||||
}
|
||||
|
||||
void init(std::string path, stream<float>* in, int bufferSize) {
|
||||
_bufferSize = bufferSize;
|
||||
_input = in;
|
||||
_file = std::ofstream(path.c_str(), std::ios::out | std::ios::binary);
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
namespace cdsp {
|
||||
class FIRFilter {
|
||||
public:
|
||||
FIRFilter() {
|
||||
|
||||
}
|
||||
|
||||
FIRFilter(stream<complex_t>* input, std::vector<float> taps, int bufferSize) : output(bufferSize * 2) {
|
||||
_in = input;
|
||||
_bufferSize = bufferSize;
|
||||
@@ -15,6 +19,15 @@ namespace cdsp {
|
||||
_taps = taps;
|
||||
}
|
||||
|
||||
void init(stream<complex_t>* input, std::vector<float> taps, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
_in = input;
|
||||
_bufferSize = bufferSize;
|
||||
_tapCount = taps.size();
|
||||
delayBuf = new complex_t[_tapCount];
|
||||
_taps = taps;
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
@@ -66,9 +79,21 @@ namespace cdsp {
|
||||
|
||||
class DCBiasRemover {
|
||||
public:
|
||||
DCBiasRemover() {
|
||||
|
||||
}
|
||||
|
||||
DCBiasRemover(stream<complex_t>* input, int bufferSize) : output(bufferSize * 2) {
|
||||
_in = input;
|
||||
_bufferSize = bufferSize;
|
||||
bypass = false;
|
||||
}
|
||||
|
||||
void init(stream<complex_t>* input, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
_in = input;
|
||||
_bufferSize = bufferSize;
|
||||
bypass = false;
|
||||
}
|
||||
|
||||
void start() {
|
||||
@@ -76,6 +101,7 @@ namespace cdsp {
|
||||
}
|
||||
|
||||
stream<complex_t> output;
|
||||
bool bypass;
|
||||
|
||||
private:
|
||||
static void _worker(DCBiasRemover* _this) {
|
||||
@@ -84,6 +110,10 @@ namespace cdsp {
|
||||
float qbias = 0.0f;
|
||||
while (true) {
|
||||
_this->_in->read(buf, _this->_bufferSize);
|
||||
if (_this->bypass) {
|
||||
_this->output.write(buf, _this->_bufferSize);
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < _this->_bufferSize; i++) {
|
||||
ibias += buf[i].i;
|
||||
qbias += buf[i].q;
|
||||
@@ -102,4 +132,45 @@ namespace cdsp {
|
||||
int _bufferSize;
|
||||
std::thread _workerThread;
|
||||
};
|
||||
|
||||
class HandlerSink {
|
||||
public:
|
||||
HandlerSink() {
|
||||
|
||||
}
|
||||
|
||||
HandlerSink(stream<complex_t>* input, complex_t* buffer, int bufferSize, void handler(complex_t*)) {
|
||||
_in = input;
|
||||
_bufferSize = bufferSize;
|
||||
_buffer = buffer;
|
||||
_handler = handler;
|
||||
}
|
||||
|
||||
void init(stream<complex_t>* input, complex_t* buffer, int bufferSize, void handler(complex_t*)) {
|
||||
_in = input;
|
||||
_bufferSize = bufferSize;
|
||||
_buffer = buffer;
|
||||
_handler = handler;
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
|
||||
bool bypass;
|
||||
|
||||
private:
|
||||
static void _worker(HandlerSink* _this) {
|
||||
while (true) {
|
||||
_this->_in->read(_this->_buffer, _this->_bufferSize);
|
||||
_this->_handler(_this->_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
stream<complex_t>* _in;
|
||||
int _bufferSize;
|
||||
complex_t* _buffer;
|
||||
std::thread _workerThread;
|
||||
void (*_handler)(complex_t*);
|
||||
};
|
||||
};
|
||||
@@ -6,12 +6,23 @@
|
||||
namespace cdsp {
|
||||
class SineSource {
|
||||
public:
|
||||
SineSource() {
|
||||
|
||||
}
|
||||
|
||||
SineSource(float frequency, long sampleRate, int bufferSize) : output(bufferSize * 2) {
|
||||
_bufferSize = bufferSize;
|
||||
_phasorSpeed = (2 * 3.1415926535) / (sampleRate / frequency);
|
||||
_phase = 0;
|
||||
}
|
||||
|
||||
void init(float frequency, long sampleRate, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
_bufferSize = bufferSize;
|
||||
_phasorSpeed = (2 * 3.1415926535) / (sampleRate / frequency);
|
||||
_phase = 0;
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
@@ -39,10 +50,19 @@ namespace cdsp {
|
||||
|
||||
class RandomSource {
|
||||
public:
|
||||
RandomSource() {
|
||||
|
||||
}
|
||||
|
||||
RandomSource(float frequency, long sampleRate, int bufferSize) : output(bufferSize * 2) {
|
||||
_bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
void init(float frequency, long sampleRate, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
_bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
@@ -66,12 +86,23 @@ namespace cdsp {
|
||||
|
||||
class ComplexSineSource {
|
||||
public:
|
||||
ComplexSineSource() {
|
||||
|
||||
}
|
||||
|
||||
ComplexSineSource(float frequency, long sampleRate, int bufferSize) : output(bufferSize * 2) {
|
||||
_bufferSize = bufferSize;
|
||||
_phasorSpeed = (2 * 3.1415926535) / (sampleRate / frequency);
|
||||
_phase = 0;
|
||||
}
|
||||
|
||||
void init(float frequency, long sampleRate, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
_bufferSize = bufferSize;
|
||||
_phasorSpeed = (2 * 3.1415926535) / (sampleRate / frequency);
|
||||
_phase = 0;
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
|
||||
@@ -16,11 +16,21 @@ namespace cdsp {
|
||||
|
||||
class Complex2HackRF {
|
||||
public:
|
||||
Complex2HackRF() {
|
||||
|
||||
}
|
||||
|
||||
Complex2HackRF(stream<complex_t>* in, int bufferSize) : output(bufferSize * 2) {
|
||||
_input = in;
|
||||
_bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
void init(stream<complex_t>* in, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
_input = in;
|
||||
_bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
stream<hackrf_sample_t> output;
|
||||
|
||||
void start() {
|
||||
@@ -48,11 +58,21 @@ namespace cdsp {
|
||||
|
||||
class HackRF2Complex {
|
||||
public:
|
||||
HackRF2Complex() {
|
||||
|
||||
}
|
||||
|
||||
HackRF2Complex(stream<complex_t>* out, int bufferSize) : input(bufferSize * 2) {
|
||||
_output = out;
|
||||
_bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
void init(stream<complex_t>* out, int bufferSize) {
|
||||
input.init(bufferSize * 2);
|
||||
_output = out;
|
||||
_bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
void start() {
|
||||
_workerThread = std::thread(_worker, this);
|
||||
}
|
||||
@@ -81,12 +101,23 @@ namespace cdsp {
|
||||
|
||||
class HackRFSink {
|
||||
public:
|
||||
HackRFSink() {
|
||||
|
||||
}
|
||||
|
||||
HackRFSink(hackrf_device* dev, int bufferSize, stream<complex_t>* input) : gen(input, bufferSize) {
|
||||
_input = input;
|
||||
_dev = dev;
|
||||
gen.start();
|
||||
}
|
||||
|
||||
void init(hackrf_device* dev, int bufferSize, stream<complex_t>* input) {
|
||||
gen.init(input, bufferSize);
|
||||
_input = input;
|
||||
_dev = dev;
|
||||
gen.start();
|
||||
}
|
||||
|
||||
void start() {
|
||||
streaming = true;
|
||||
hackrf_start_tx(_dev, _worker, this);
|
||||
@@ -116,11 +147,22 @@ namespace cdsp {
|
||||
|
||||
class HackRFSource {
|
||||
public:
|
||||
HackRFSource() {
|
||||
|
||||
}
|
||||
|
||||
HackRFSource(hackrf_device* dev, int bufferSize) : output(bufferSize * 2), gen(&output, bufferSize) {
|
||||
_dev = dev;
|
||||
gen.start();
|
||||
}
|
||||
|
||||
void init(hackrf_device* dev, int bufferSize) {
|
||||
output.init(bufferSize * 2);
|
||||
gen.init(&output, bufferSize);
|
||||
_dev = dev;
|
||||
gen.start();
|
||||
}
|
||||
|
||||
void start() {
|
||||
streaming = true;
|
||||
hackrf_start_rx(_dev, _worker, this);
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
namespace cdsp {
|
||||
class Multiplier {
|
||||
public:
|
||||
Multiplier() {
|
||||
|
||||
}
|
||||
|
||||
Multiplier(stream<complex_t>* a, stream<complex_t>* b, int bufferSize) : output(bufferSize * 2) {
|
||||
_a = a;
|
||||
_b = b;
|
||||
|
||||
@@ -7,12 +7,22 @@ namespace cdsp {
|
||||
template <class T>
|
||||
class stream {
|
||||
public:
|
||||
stream() {
|
||||
|
||||
}
|
||||
|
||||
stream(int size) {
|
||||
_buffer = new T[size];
|
||||
this->size = size;
|
||||
writec = 0;
|
||||
readc = size - 1;
|
||||
//printf("Stream init\n");
|
||||
}
|
||||
|
||||
void init(int size) {
|
||||
_buffer = new T[size];
|
||||
this->size = size;
|
||||
writec = 0;
|
||||
readc = size - 1;
|
||||
}
|
||||
|
||||
void read(T* data, int len) {
|
||||
|
||||
Reference in New Issue
Block a user