mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 12:07:49 +02:00
Fixed issues with new module system
This commit is contained in:
@ -3,53 +3,14 @@ project(radio)
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "-O2 /std:c++17")
|
||||
link_directories(radio "C:/Program Files/PothosSDR/lib/")
|
||||
include_directories(radio "C:/Program Files/PothosSDR/include/volk/")
|
||||
include_directories(radio "C:/Program Files/PothosSDR/include/")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fsanitize=address -g")
|
||||
include_directories(radio "/usr/include/volk")
|
||||
link_libraries(pthread)
|
||||
link_libraries(GL)
|
||||
link_libraries(GLEW)
|
||||
link_libraries(glfw)
|
||||
link_libraries(fftw3)
|
||||
link_libraries(fftw3f)
|
||||
link_libraries(portaudio)
|
||||
link_libraries(X11)
|
||||
link_libraries(Xxf86vm)
|
||||
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fpermissive -fsanitize=address -g")
|
||||
# set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fpermissive")
|
||||
endif (MSVC)
|
||||
|
||||
link_libraries(volk)
|
||||
link_libraries(SoapySDR)
|
||||
|
||||
# Main code
|
||||
include_directories(radio "src/")
|
||||
include_directories(radio "../core/src/")
|
||||
include_directories(radio "../core/src/imgui")
|
||||
file(GLOB SRC "src/*.cpp")
|
||||
file(GLOB IMGUI "../core/src/imgui/*.cpp")
|
||||
add_library(radio SHARED ${SRC} ${IMGUI})
|
||||
set_target_properties(radio PROPERTIES PREFIX "")
|
||||
|
||||
if (MSVC)
|
||||
# Glew
|
||||
find_package(GLEW REQUIRED)
|
||||
target_link_libraries(radio PRIVATE GLEW::GLEW)
|
||||
include_directories("src/")
|
||||
|
||||
# GLFW3
|
||||
find_package(glfw3 CONFIG REQUIRED)
|
||||
target_link_libraries(radio PRIVATE glfw)
|
||||
|
||||
# FFTW3
|
||||
find_package(FFTW3 CONFIG REQUIRED)
|
||||
target_link_libraries(radio PRIVATE FFTW3::fftw3)
|
||||
find_package(FFTW3f CONFIG REQUIRED)
|
||||
target_link_libraries(radio PRIVATE FFTW3::fftw3f)
|
||||
|
||||
# PortAudio
|
||||
find_package(portaudio CONFIG REQUIRED)
|
||||
target_link_libraries(radio PRIVATE portaudio portaudio_static)
|
||||
endif (MSVC)
|
||||
|
||||
# cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Alex/vcpkg/scripts/buildsystems/vcpkg.cmake" -G "Visual Studio 15 2017 Win64"
|
||||
add_library(radio SHARED ${SRC})
|
||||
target_link_libraries(radio PRIVATE sdrpp_core)
|
@ -25,7 +25,7 @@ MOD_EXPORT void* _INIT_(mod::API_t* _API, ImGuiContext* imctx, std::string _name
|
||||
ctx->bandWidth = 200000;
|
||||
ctx->bandWidthMin = 100000;
|
||||
ctx->bandWidthMax = 200000;
|
||||
ctx->sigPath.init(_name, 200000, 1000, API->registerVFO(_name, mod::API_t::REF_CENTER, 0, 200000, 200000, 1000));
|
||||
ctx->sigPath.init(_name, 200000, 1000);
|
||||
ctx->sigPath.start();
|
||||
ImGui::SetCurrentContext(imctx);
|
||||
return ctx;
|
||||
@ -49,7 +49,6 @@ MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
||||
ctx->bandWidthMin = 8000;
|
||||
ctx->bandWidthMax = 16000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_NFM, ctx->bandWidth);
|
||||
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("WFM##_", ctx->name), ctx->demod == 1) && ctx->demod != 1) {
|
||||
ctx->demod = 1;
|
||||
@ -57,7 +56,6 @@ MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
||||
ctx->bandWidthMin = 100000;
|
||||
ctx->bandWidthMax = 200000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_FM, ctx->bandWidth);
|
||||
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::RadioButton(CONCAT("AM##_", ctx->name), ctx->demod == 2) && ctx->demod != 2) {
|
||||
@ -66,7 +64,6 @@ MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
||||
ctx->bandWidthMin = 6250;
|
||||
ctx->bandWidthMax = 12500;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_AM, ctx->bandWidth);
|
||||
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("DSB##_", ctx->name), ctx->demod == 3) && ctx->demod != 3) {
|
||||
ctx->demod = 3;
|
||||
@ -74,7 +71,6 @@ MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
||||
ctx->bandWidthMin = 3000;
|
||||
ctx->bandWidthMax = 6000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_DSB, ctx->bandWidth);
|
||||
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::RadioButton(CONCAT("USB##_", ctx->name), ctx->demod == 4) && ctx->demod != 4) {
|
||||
@ -83,7 +79,6 @@ MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
||||
ctx->bandWidthMin = 1500;
|
||||
ctx->bandWidthMax = 3000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_USB, ctx->bandWidth);
|
||||
API->setVFOReference(ctx->name, mod::API_t::REF_LOWER);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("CW##_", ctx->name), ctx->demod == 5) && ctx->demod != 5) { ctx->demod = 5; };
|
||||
ImGui::NextColumn();
|
||||
@ -93,7 +88,6 @@ MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
||||
ctx->bandWidthMin = 1500;
|
||||
ctx->bandWidthMax = 3000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_LSB, ctx->bandWidth);
|
||||
API->setVFOReference(ctx->name, mod::API_t::REF_UPPER);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("RAW##_", ctx->name), ctx->demod == 7) && ctx->demod != 7) {
|
||||
ctx->demod = 7;
|
||||
@ -101,7 +95,6 @@ MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
||||
ctx->bandWidthMin = 3000;
|
||||
ctx->bandWidthMax = 10000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_RAW, ctx->bandWidth);
|
||||
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
||||
};
|
||||
ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", ctx->name), false);
|
||||
|
||||
|
@ -18,11 +18,13 @@ int SigPath::sampleRateChangeHandler(void* ctx, float sampleRate) {
|
||||
return _this->audioResamp.getOutputBlockSize();
|
||||
}
|
||||
|
||||
void SigPath::init(std::string vfoName, uint64_t sampleRate, int blockSize, dsp::stream<dsp::complex_t>* input) {
|
||||
void SigPath::init(std::string vfoName, uint64_t sampleRate, int blockSize) {
|
||||
this->sampleRate = sampleRate;
|
||||
this->blockSize = blockSize;
|
||||
this->vfoName = vfoName;
|
||||
|
||||
vfo = sigpath::vfoManager.createVFO(vfoName, mod::API_t::REF_CENTER, 0, 200000, 200000, 1000);
|
||||
|
||||
_demod = DEMOD_FM;
|
||||
_deemp = DEEMP_50US;
|
||||
bandwidth = 200000;
|
||||
@ -31,10 +33,10 @@ void SigPath::init(std::string vfoName, uint64_t sampleRate, int blockSize, dsp:
|
||||
// TODO: ajust deemphasis for different output sample rates
|
||||
// TODO: Add a mono to stereo for different modes
|
||||
|
||||
demod.init(input, 100000, 200000, 800);
|
||||
amDemod.init(input, 50);
|
||||
ssbDemod.init(input, 6000, 3000, 22);
|
||||
cpx2stereo.init(input, 22);
|
||||
demod.init(vfo->output, 100000, 200000, 800);
|
||||
amDemod.init(vfo->output, 50);
|
||||
ssbDemod.init(vfo->output, 6000, 3000, 22);
|
||||
cpx2stereo.init(vfo->output, 22);
|
||||
|
||||
audioResamp.init(&demod.output, 200000, 48000, 800);
|
||||
deemp.init(&audioResamp.output, 800, 50e-6, 48000);
|
||||
@ -91,72 +93,79 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
|
||||
// Set input of the audio resampler
|
||||
// TODO: Set bandwidth from argument
|
||||
if (demId == DEMOD_FM) {
|
||||
API->setVFOSampleRate(vfoName, 200000, bandwidth);
|
||||
demod.setBlockSize(API->getVFOOutputBlockSize(vfoName));
|
||||
vfo->setSampleRate(200000, bandwidth);
|
||||
demod.setBlockSize(vfo->getOutputBlockSize());
|
||||
demod.setSampleRate(200000);
|
||||
demod.setDeviation(bandwidth / 2.0f);
|
||||
audioResamp.setInput(&demod.output);
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(200000, API->getVFOOutputBlockSize(vfoName), audioBw, audioBw);
|
||||
audioResamp.setInputSampleRate(200000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = (_deemp == DEEMP_NONE);
|
||||
vfo->setReference(mod::API_t::REF_CENTER);
|
||||
demod.start();
|
||||
}
|
||||
else if (demId == DEMOD_NFM) {
|
||||
API->setVFOSampleRate(vfoName, 16000, bandwidth);
|
||||
demod.setBlockSize(API->getVFOOutputBlockSize(vfoName));
|
||||
vfo->setSampleRate(16000, bandwidth);
|
||||
demod.setBlockSize(vfo->getOutputBlockSize());
|
||||
demod.setSampleRate(16000);
|
||||
demod.setDeviation(bandwidth / 2.0f);
|
||||
audioResamp.setInput(&demod.output);
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(16000, API->getVFOOutputBlockSize(vfoName), audioBw, audioBw);
|
||||
audioResamp.setInputSampleRate(16000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_CENTER);
|
||||
demod.start();
|
||||
}
|
||||
else if (demId == DEMOD_AM) {
|
||||
API->setVFOSampleRate(vfoName, 12500, bandwidth);
|
||||
amDemod.setBlockSize(API->getVFOOutputBlockSize(vfoName));
|
||||
vfo->setSampleRate(12500, bandwidth);
|
||||
amDemod.setBlockSize(vfo->getOutputBlockSize());
|
||||
audioResamp.setInput(&amDemod.output);
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(12500, API->getVFOOutputBlockSize(vfoName), audioBw, audioBw);
|
||||
audioResamp.setInputSampleRate(12500, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_CENTER);
|
||||
amDemod.start();
|
||||
}
|
||||
else if (demId == DEMOD_USB) {
|
||||
API->setVFOSampleRate(vfoName, 6000, bandwidth);
|
||||
ssbDemod.setBlockSize(API->getVFOOutputBlockSize(vfoName));
|
||||
vfo->setSampleRate(6000, bandwidth);
|
||||
ssbDemod.setBlockSize(vfo->getOutputBlockSize());
|
||||
ssbDemod.setMode(dsp::SSBDemod::MODE_USB);
|
||||
audioResamp.setInput(&ssbDemod.output);
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(6000, API->getVFOOutputBlockSize(vfoName), audioBw, audioBw);
|
||||
audioResamp.setInputSampleRate(6000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_LOWER);
|
||||
ssbDemod.start();
|
||||
}
|
||||
else if (demId == DEMOD_LSB) {
|
||||
API->setVFOSampleRate(vfoName, 6000, bandwidth);
|
||||
ssbDemod.setBlockSize(API->getVFOOutputBlockSize(vfoName));
|
||||
vfo->setSampleRate(6000, bandwidth);
|
||||
ssbDemod.setBlockSize(vfo->getOutputBlockSize());
|
||||
ssbDemod.setMode(dsp::SSBDemod::MODE_LSB);
|
||||
audioResamp.setInput(&ssbDemod.output);
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(6000, API->getVFOOutputBlockSize(vfoName), audioBw, audioBw);
|
||||
audioResamp.setInputSampleRate(6000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_UPPER);
|
||||
ssbDemod.start();
|
||||
}
|
||||
else if (demId == DEMOD_DSB) {
|
||||
API->setVFOSampleRate(vfoName, 6000, bandwidth);
|
||||
ssbDemod.setBlockSize(API->getVFOOutputBlockSize(vfoName));
|
||||
vfo->setSampleRate(6000, bandwidth);
|
||||
ssbDemod.setBlockSize(vfo->getOutputBlockSize());
|
||||
ssbDemod.setMode(dsp::SSBDemod::MODE_DSB);
|
||||
audioResamp.setInput(&ssbDemod.output);
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(6000, API->getVFOOutputBlockSize(vfoName), audioBw, audioBw);
|
||||
audioResamp.setInputSampleRate(6000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_CENTER);
|
||||
ssbDemod.start();
|
||||
}
|
||||
else if (demId == DEMOD_RAW) {
|
||||
API->setVFOSampleRate(vfoName, 10000, bandwidth);
|
||||
cpx2stereo.setBlockSize(API->getVFOOutputBlockSize(vfoName));
|
||||
vfo->setSampleRate(10000, bandwidth);
|
||||
cpx2stereo.setBlockSize(vfo->getOutputBlockSize());
|
||||
//audioResamp.setInput(&cpx2stereo.output);
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(10000, API->getVFOOutputBlockSize(vfoName), audioBw, audioBw);
|
||||
audioResamp.setInputSampleRate(10000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
vfo->setReference(mod::API_t::REF_LOWER);
|
||||
cpx2stereo.start();
|
||||
}
|
||||
else {
|
||||
@ -192,7 +201,7 @@ void SigPath::setDeemphasis(int deemph) {
|
||||
|
||||
void SigPath::setBandwidth(float bandWidth) {
|
||||
bandwidth = bandWidth;
|
||||
API->setVFOBandwidth(vfoName, bandwidth);
|
||||
vfo->setBandwidth(bandwidth);
|
||||
if (_demod == DEMOD_FM) {
|
||||
demod.stop();
|
||||
demod.setDeviation(bandwidth / 2.0f);
|
||||
@ -231,7 +240,7 @@ void SigPath::setBandwidth(float bandWidth) {
|
||||
if (audioBw != _audioBw) {
|
||||
audioBw = _audioBw;
|
||||
audioResamp.stop();
|
||||
audioResamp.setInputSampleRate(6000, API->getVFOOutputBlockSize(vfoName), audioBw, audioBw);
|
||||
audioResamp.setInputSampleRate(6000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
audioResamp.start();
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,12 @@
|
||||
#include <dsp/vfo.h>
|
||||
#include <io/audio.h>
|
||||
#include <module.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
|
||||
class SigPath {
|
||||
public:
|
||||
SigPath();
|
||||
void init(std::string vfoName, uint64_t sampleRate, int blockSize, dsp::stream<dsp::complex_t>* input);
|
||||
void init(std::string vfoName, uint64_t sampleRate, int blockSize);
|
||||
void start();
|
||||
void setSampleRate(float sampleRate);
|
||||
void setVFOFrequency(uint64_t frequency);
|
||||
@ -46,6 +47,8 @@ public:
|
||||
|
||||
private:
|
||||
static int sampleRateChangeHandler(void* ctx, float sampleRate);
|
||||
|
||||
VFOManager::VFO* vfo;
|
||||
|
||||
dsp::stream<dsp::complex_t> input;
|
||||
|
||||
|
Reference in New Issue
Block a user