mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 20:07:51 +02:00
Fixed bugs + new radio
This commit is contained in:
138
core/src/dsp/convertion.h
Normal file
138
core/src/dsp/convertion.h
Normal file
@ -0,0 +1,138 @@
|
||||
#pragma once
|
||||
#include <dsp/block.h>
|
||||
|
||||
namespace dsp {
|
||||
class ComplexToStereo : public generic_block<ComplexToStereo> {
|
||||
public:
|
||||
ComplexToStereo() {}
|
||||
|
||||
ComplexToStereo(stream<complex_t>* in) { init(in); }
|
||||
|
||||
~ComplexToStereo() { generic_block<ComplexToStereo>::stop(); }
|
||||
|
||||
static_assert(sizeof(complex_t) == sizeof(stereo_t));
|
||||
|
||||
void init(stream<complex_t>* in) {
|
||||
_in = in;
|
||||
generic_block<ComplexToStereo>::registerInput(_in);
|
||||
generic_block<ComplexToStereo>::registerOutput(&out);
|
||||
}
|
||||
|
||||
void setInput(stream<complex_t>* in) {
|
||||
std::lock_guard<std::mutex> lck(generic_block<ComplexToStereo>::ctrlMtx);
|
||||
generic_block<ComplexToStereo>::tempStop();
|
||||
generic_block<ComplexToStereo>::unregisterInput(_in);
|
||||
_in = in;
|
||||
generic_block<ComplexToStereo>::registerInput(_in);
|
||||
generic_block<ComplexToStereo>::tempStart();
|
||||
}
|
||||
|
||||
int run() {
|
||||
count = _in->read();
|
||||
if (count < 0) { return -1; }
|
||||
|
||||
if (out.aquire() < 0) { return -1; }
|
||||
memcpy(out.data, _in->data, count * sizeof(complex_t));
|
||||
|
||||
_in->flush();
|
||||
out.write(count);
|
||||
return count;
|
||||
}
|
||||
|
||||
stream<stereo_t> out;
|
||||
|
||||
private:
|
||||
float avg;
|
||||
int count;
|
||||
stream<complex_t>* _in;
|
||||
|
||||
};
|
||||
|
||||
class ComplexToReal : public generic_block<ComplexToReal> {
|
||||
public:
|
||||
ComplexToReal() {}
|
||||
|
||||
ComplexToReal(stream<complex_t>* in) { init(in); }
|
||||
|
||||
~ComplexToReal() { generic_block<ComplexToReal>::stop(); }
|
||||
|
||||
void init(stream<complex_t>* in) {
|
||||
_in = in;
|
||||
generic_block<ComplexToReal>::registerInput(_in);
|
||||
generic_block<ComplexToReal>::registerOutput(&out);
|
||||
}
|
||||
|
||||
void setInput(stream<complex_t>* in) {
|
||||
std::lock_guard<std::mutex> lck(generic_block<ComplexToReal>::ctrlMtx);
|
||||
generic_block<ComplexToReal>::tempStop();
|
||||
generic_block<ComplexToReal>::unregisterInput(_in);
|
||||
_in = in;
|
||||
generic_block<ComplexToReal>::registerInput(_in);
|
||||
generic_block<ComplexToReal>::tempStart();
|
||||
}
|
||||
|
||||
int run() {
|
||||
count = _in->read();
|
||||
if (count < 0) { return -1; }
|
||||
|
||||
if (out.aquire() < 0) { return -1; }
|
||||
volk_32fc_deinterleave_real_32f(out.data, (lv_32fc_t*)_in->data, count);
|
||||
|
||||
_in->flush();
|
||||
out.write(count);
|
||||
return count;
|
||||
}
|
||||
|
||||
stream<float> out;
|
||||
|
||||
private:
|
||||
float avg;
|
||||
int count;
|
||||
stream<complex_t>* _in;
|
||||
|
||||
};
|
||||
|
||||
class ComplexToImag : public generic_block<ComplexToImag> {
|
||||
public:
|
||||
ComplexToImag() {}
|
||||
|
||||
ComplexToImag(stream<complex_t>* in) { init(in); }
|
||||
|
||||
~ComplexToImag() { generic_block<ComplexToImag>::stop(); }
|
||||
|
||||
void init(stream<complex_t>* in) {
|
||||
_in = in;
|
||||
generic_block<ComplexToImag>::registerInput(_in);
|
||||
generic_block<ComplexToImag>::registerOutput(&out);
|
||||
}
|
||||
|
||||
void setInput(stream<complex_t>* in) {
|
||||
std::lock_guard<std::mutex> lck(generic_block<ComplexToImag>::ctrlMtx);
|
||||
generic_block<ComplexToImag>::tempStop();
|
||||
generic_block<ComplexToImag>::unregisterInput(_in);
|
||||
_in = in;
|
||||
generic_block<ComplexToImag>::registerInput(_in);
|
||||
generic_block<ComplexToImag>::tempStart();
|
||||
}
|
||||
|
||||
int run() {
|
||||
count = _in->read();
|
||||
if (count < 0) { return -1; }
|
||||
|
||||
if (out.aquire() < 0) { return -1; }
|
||||
volk_32fc_deinterleave_imag_32f(out.data, (lv_32fc_t*)_in->data, count);
|
||||
|
||||
_in->flush();
|
||||
out.write(count);
|
||||
return count;
|
||||
}
|
||||
|
||||
stream<float> out;
|
||||
|
||||
private:
|
||||
float avg;
|
||||
int count;
|
||||
stream<complex_t>* _in;
|
||||
|
||||
};
|
||||
}
|
@ -5,13 +5,16 @@
|
||||
#include <string.h>
|
||||
|
||||
namespace dsp {
|
||||
class FrequencyXlator : public generic_block<FrequencyXlator> {
|
||||
template <class T>
|
||||
class FrequencyXlator : public generic_block<FrequencyXlator<T>> {
|
||||
public:
|
||||
FrequencyXlator() {}
|
||||
|
||||
FrequencyXlator(stream<complex_t>* in, float sampleRate, float freq) { init(in, sampleRate, freq); }
|
||||
|
||||
~FrequencyXlator() { generic_block<FrequencyXlator>::stop(); }
|
||||
~FrequencyXlator() {
|
||||
generic_block<FrequencyXlator<T>>::stop();
|
||||
}
|
||||
|
||||
void init(stream<complex_t>* in, float sampleRate, float freq) {
|
||||
_in = in;
|
||||
@ -19,17 +22,17 @@ namespace dsp {
|
||||
_freq = freq;
|
||||
phase = lv_cmake(1.0f, 0.0f);
|
||||
phaseDelta = lv_cmake(std::cos((_freq / _sampleRate) * 2.0f * FL_M_PI), std::sin((_freq / _sampleRate) * 2.0f * FL_M_PI));
|
||||
generic_block<FrequencyXlator>::registerInput(_in);
|
||||
generic_block<FrequencyXlator>::registerOutput(&out);
|
||||
generic_block<FrequencyXlator<T>>::registerInput(_in);
|
||||
generic_block<FrequencyXlator<T>>::registerOutput(&out);
|
||||
}
|
||||
|
||||
void setInputSize(stream<complex_t>* in) {
|
||||
std::lock_guard<std::mutex> lck(generic_block<FrequencyXlator>::ctrlMtx);
|
||||
generic_block<FrequencyXlator>::tempStop();
|
||||
generic_block<FrequencyXlator>::unregisterInput(_in);
|
||||
std::lock_guard<std::mutex> lck(generic_block<FrequencyXlator<T>>::ctrlMtx);
|
||||
generic_block<FrequencyXlator<T>>::tempStop();
|
||||
generic_block<FrequencyXlator<T>>::unregisterInput(_in);
|
||||
_in = in;
|
||||
generic_block<FrequencyXlator>::registerInput(_in);
|
||||
generic_block<FrequencyXlator>::tempStart();
|
||||
generic_block<FrequencyXlator<T>>::registerInput(_in);
|
||||
generic_block<FrequencyXlator<T>>::tempStart();
|
||||
}
|
||||
|
||||
void setSampleRate(float sampleRate) {
|
||||
@ -58,7 +61,13 @@ namespace dsp {
|
||||
|
||||
if (out.aquire() < 0) { return -1; }
|
||||
|
||||
volk_32fc_s32fc_x2_rotator_32fc((lv_32fc_t*)out.data, (lv_32fc_t*)_in->data, phaseDelta, &phase, count);
|
||||
// TODO: Do float xlation
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
spdlog::error("XLATOR NOT IMPLEMENTED FOR FLOAT");
|
||||
}
|
||||
if constexpr (std::is_same_v<T, complex_t>) {
|
||||
volk_32fc_s32fc_x2_rotator_32fc((lv_32fc_t*)out.data, (lv_32fc_t*)_in->data, phaseDelta, &phase, count);
|
||||
}
|
||||
|
||||
_in->flush();
|
||||
out.write(count);
|
||||
|
@ -105,7 +105,7 @@ namespace dsp {
|
||||
float _offset, _inSampleRate, _outSampleRate, _bandWidth;
|
||||
filter_window::BlackmanWindow win;
|
||||
stream<complex_t>* _in;
|
||||
FrequencyXlator xlator;
|
||||
FrequencyXlator<complex_t> xlator;
|
||||
PolyphaseResampler<complex_t> resamp;
|
||||
|
||||
};
|
||||
|
@ -62,7 +62,9 @@
|
||||
#if !defined(DUK_CONFIG_H_INCLUDED)
|
||||
#define DUK_CONFIG_H_INCLUDED
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DUK_USE_DATE_NOW_WINDOWS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Intermediate helper defines
|
||||
|
@ -125,13 +125,14 @@ void windowInit() {
|
||||
// Add "select folder" option for the file source
|
||||
// Fix SSB demod
|
||||
// FIX AUDIO ISSUE ON BOTH LINUX AND SOMETIMES WINDOWS (probly the ring buffer, though double buffering could help)
|
||||
// Rewrite radio module with CW and RAW modes
|
||||
// Add CW mode to radio module
|
||||
// Add default main config to avoid having to ship one
|
||||
// Have a good directory system on both linux and windows
|
||||
// Switch to double buffering
|
||||
|
||||
// TODO for 0.2.6
|
||||
// And a module add/remove/change order menu
|
||||
// Add a module add/remove/change order menu
|
||||
// Change the way fft samples are stored to make it less CPU intensive
|
||||
|
||||
// Update UI settings
|
||||
LoadingScreen::show("Loading configuration");
|
||||
|
Reference in New Issue
Block a user