New features + waterfall code cleanup

This commit is contained in:
Ryzerth 2021-04-17 22:37:50 +02:00
parent d1e553f05a
commit d91934955b
18 changed files with 263 additions and 84 deletions

View File

@ -83,14 +83,14 @@ namespace dsp {
void updateWindow(dsp::filter_window::generic_window* window) { void updateWindow(dsp::filter_window::generic_window* window) {
std::lock_guard<std::mutex> lck(generic_block<PolyphaseResampler<T>>::ctrlMtx); std::lock_guard<std::mutex> lck(generic_block<PolyphaseResampler<T>>::ctrlMtx);
generic_block<PolyphaseResampler<T>>::tempStop(); //generic_block<PolyphaseResampler<T>>::tempStop();
_window = window; _window = window;
volk_free(taps); volk_free(taps);
tapCount = window->getTapCount(); tapCount = window->getTapCount();
taps = (float*)volk_malloc(tapCount * sizeof(float), volk_get_alignment()); taps = (float*)volk_malloc(tapCount * sizeof(float), volk_get_alignment());
window->createTaps(taps, tapCount, _interp); window->createTaps(taps, tapCount, _interp);
buildTapPhases(); buildTapPhases();
generic_block<PolyphaseResampler<T>>::tempStart(); //generic_block<PolyphaseResampler<T>>::tempStart();
} }
int calcOutSize(int in) { int calcOutSize(int in) {
@ -103,6 +103,8 @@ namespace dsp {
return -1; return -1;
} }
ctrlMtx.lock();
int outCount = calcOutSize(count); int outCount = calcOutSize(count);
memcpy(&buffer[tapsPerPhase], _in->readBuf, count * sizeof(T)); memcpy(&buffer[tapsPerPhase], _in->readBuf, count * sizeof(T));
@ -129,6 +131,8 @@ namespace dsp {
memmove(buffer, &buffer[count], tapsPerPhase * sizeof(T)); memmove(buffer, &buffer[count], tapsPerPhase * sizeof(T));
ctrlMtx.unlock();
return count; return count;
} }

View File

@ -220,6 +220,10 @@ namespace ImGui {
vfo->wfRectMax = ImVec2(vfo->rectMax.x, wfMax.y); vfo->wfRectMax = ImVec2(vfo->rectMax.x, wfMax.y);
vfo->wfLineMin = ImVec2(vfo->lineMin.x, wfMin.y); vfo->wfLineMin = ImVec2(vfo->lineMin.x, wfMin.y);
vfo->wfLineMax = ImVec2(vfo->lineMax.x, wfMax.y); vfo->wfLineMax = ImVec2(vfo->lineMax.x, wfMax.y);
vfo->wfLbwSelMin = ImVec2(vfo->wfRectMin.x - 2, vfo->wfRectMin.y);
vfo->wfLbwSelMax = ImVec2(vfo->wfRectMin.x + 2, vfo->wfRectMax.y);
vfo->wfRbwSelMin = ImVec2(vfo->wfRectMax.x - 2, vfo->wfRectMin.y);
vfo->wfRbwSelMax = ImVec2(vfo->wfRectMax.x + 2, vfo->wfRectMax.y);
} }
vfo->draw(window, name == selectedVFO); vfo->draw(window, name == selectedVFO);
} }
@ -238,64 +242,93 @@ namespace ImGui {
} }
void WaterFall::processInputs() { void WaterFall::processInputs() {
WaterfallVFO* vfo = NULL; // Pre calculate useful values
WaterfallVFO* selVfo = NULL;
if (selectedVFO != "") { if (selectedVFO != "") {
vfo = vfos[selectedVFO]; selVfo = vfos[selectedVFO];
} }
ImVec2 mousePos = ImGui::GetMousePos(); ImVec2 mousePos = ImGui::GetMousePos();
ImVec2 drag = ImGui::GetMouseDragDelta(ImGuiMouseButton_Left); ImVec2 drag = ImGui::GetMouseDragDelta(ImGuiMouseButton_Left);
ImVec2 dragOrigin(mousePos.x - drag.x, mousePos.y - drag.y); ImVec2 dragOrigin(mousePos.x - drag.x, mousePos.y - drag.y);
bool mouseHovered, mouseHeld; bool mouseHovered, mouseHeld;
bool mouseClicked = ImGui::ButtonBehavior(ImRect(fftAreaMin, fftAreaMax), GetID("WaterfallID"), &mouseHovered, &mouseHeld, bool mouseClicked = ImGui::ButtonBehavior(ImRect(fftAreaMin, wfMax), GetID("WaterfallID"), &mouseHovered, &mouseHeld,
ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_PressedOnClick); ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_PressedOnClick);
mouseClicked |= ImGui::ButtonBehavior(ImRect(wfMin, wfMax), GetID("WaterfallID2"), &mouseHovered, &mouseHeld,
ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_PressedOnClick);
bool draging = ImGui::IsMouseDragging(ImGuiMouseButton_Left) && ImGui::IsWindowFocused(); bool draging = ImGui::IsMouseDragging(ImGuiMouseButton_Left) && ImGui::IsWindowFocused();
bool mouseInFreq = IS_IN_AREA(dragOrigin, freqAreaMin, freqAreaMax); bool mouseInFreq = IS_IN_AREA(dragOrigin, freqAreaMin, freqAreaMax);
bool mouseInFFT = IS_IN_AREA(dragOrigin, fftAreaMin, fftAreaMax); bool mouseInFFT = IS_IN_AREA(dragOrigin, fftAreaMin, fftAreaMax);
bool mouseInWaterfall = IS_IN_AREA(dragOrigin, wfMin, wfMax); bool mouseInWaterfall = IS_IN_AREA(dragOrigin, wfMin, wfMax);
// If mouse was clicked on a VFO, select VFO and return // Deselect everything if the mouse is released
// If mouse was clicked but not on a VFO, move selected VFO to position if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
freqScaleSelect = false;
vfoSelect = false;
vfoBorderSelect = false;
lastDrag = 0;
}
// If mouse was clicked, check what was clicked
if (mouseClicked) { if (mouseClicked) {
bool targetFound = false;
mouseDownPos = mousePos;
// First, check if a VFO border was selected
for (auto const& [name, _vfo] : vfos) { for (auto const& [name, _vfo] : vfos) {
if (name == selectedVFO) { if (_vfo->bandwidthLocked) { continue; }
continue; bool resizing = false;
if (_vfo->reference != REF_LOWER) {
if (IS_IN_AREA(mousePos, _vfo->lbwSelMin, _vfo->lbwSelMax)) { resizing = true; }
else if (IS_IN_AREA(mousePos, _vfo->wfLbwSelMin, _vfo->wfLbwSelMax)) { resizing = true; }
} }
if (IS_IN_AREA(mousePos, _vfo->rectMin, _vfo->rectMax) || IS_IN_AREA(mousePos, _vfo->wfRectMin, _vfo->wfRectMax)) { if (_vfo->reference != REF_UPPER) {
selectedVFO = name; if (IS_IN_AREA(mousePos, _vfo->rbwSelMin, _vfo->rbwSelMax)) { resizing = true; }
selectedVFOChanged = true; else if (IS_IN_AREA(mousePos, _vfo->wfRbwSelMin, _vfo->wfRbwSelMax)) { resizing = true; }
return; }
if (!resizing) { continue; }
relatedVfo = _vfo;
vfoBorderSelect = true;
targetFound = true;
break;
}
// Next, check if a VFO was selected
if (!targetFound) {
for (auto const& [name, _vfo] : vfos) {
if (name == selectedVFO) {
continue;
}
// If another VFO is selected, select it and cancel out
if (IS_IN_AREA(mousePos, _vfo->rectMin, _vfo->rectMax) || IS_IN_AREA(mousePos, _vfo->wfRectMin, _vfo->wfRectMax)) {
selectedVFO = name;
selectedVFOChanged = true;
targetFound = true;
return;
}
} }
} }
if (vfo != NULL) {
int refCenter = mousePos.x - (widgetPos.x + 50); // Now, check frequency scale
if (refCenter >= 0 && refCenter < dataWidth) { if (!targetFound && mouseInFreq) {
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset; freqScaleSelect = true;
off += centerFreq;
off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq;
vfo->setOffset(off);
}
} }
} }
// Draging VFO // If a vfo border is selected, resize VFO accordingly
if (draging && (mouseInFFT || mouseInWaterfall)) { if (vfoBorderSelect) {
int refCenter = mousePos.x - (widgetPos.x + 50); double dist = fabsf(mousePos.x - relatedVfo->lineMin.x);
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y) && vfo != NULL) { double hzDist = dist * (viewBandwidth / (double)dataWidth);
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset; if (relatedVfo->reference == REF_CENTER) {
off += centerFreq; hzDist *= 2.0;
off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq;
vfo->setOffset(off);
} }
} hzDist = std::clamp<double>(hzDist, relatedVfo->minBandwidth, relatedVfo->maxBandwidth);
relatedVfo->setBandwidth(hzDist);
return;
}
// Draging frequency scale // If the frequency scale is selected, move it
if (draging && mouseInFreq) { if (freqScaleSelect) {
double deltax = drag.x - lastDrag; double deltax = drag.x - lastDrag;
lastDrag = drag.x; lastDrag = drag.x;
double viewDelta = deltax * (viewBandwidth / (double)dataWidth); double viewDelta = deltax * (viewBandwidth / (double)dataWidth);
@ -322,10 +355,21 @@ namespace ImGui {
updateAllVFOs(); updateAllVFOs();
if (_fullUpdate) { updateWaterfallFb(); }; if (_fullUpdate) { updateWaterfallFb(); };
} }
return;
} }
else {
lastDrag = 0; // Finally, if nothing else was selected, just move the VFO
} if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
if (selVfo != NULL) {
int refCenter = mousePos.x - (widgetPos.x + 50);
if (refCenter >= 0 && refCenter < dataWidth) {
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset;
off += centerFreq;
off = (round(off / selVfo->snapInterval) * selVfo->snapInterval) - centerFreq;
selVfo->setOffset(off);
}
}
}
} }
void WaterFall::setFastFFT(bool fastFFT) { void WaterFall::setFastFFT(bool fastFFT) {
@ -815,6 +859,11 @@ namespace ImGui {
vfo->wfRectMax = ImVec2(vfo->rectMax.x, wfMax.y); vfo->wfRectMax = ImVec2(vfo->rectMax.x, wfMax.y);
vfo->wfLineMin = ImVec2(vfo->lineMin.x, wfMin.y); vfo->wfLineMin = ImVec2(vfo->lineMin.x, wfMin.y);
vfo->wfLineMax = ImVec2(vfo->lineMax.x, wfMax.y); vfo->wfLineMax = ImVec2(vfo->lineMax.x, wfMax.y);
vfo->wfLbwSelMin = ImVec2(vfo->wfRectMin.x - 2, vfo->wfRectMin.y);
vfo->wfLbwSelMax = ImVec2(vfo->wfRectMin.x + 2, vfo->wfRectMax.y);
vfo->wfRbwSelMin = ImVec2(vfo->wfRectMax.x - 2, vfo->wfRectMin.y);
vfo->wfRbwSelMax = ImVec2(vfo->wfRectMax.x + 2, vfo->wfRectMax.y);
} }
} }
@ -897,6 +946,7 @@ namespace ImGui {
lowerOffset = upperOffset - bandwidth; lowerOffset = upperOffset - bandwidth;
centerOffsetChanged = true; centerOffsetChanged = true;
} }
bandwidthChanged = true;
redrawRequired = true; redrawRequired = true;
} }
@ -940,8 +990,10 @@ namespace ImGui {
rectMin = ImVec2(widgetPos.x + 50 + left, widgetPos.y + 10); rectMin = ImVec2(widgetPos.x + 50 + left, widgetPos.y + 10);
rectMax = ImVec2(widgetPos.x + 51 + right, widgetPos.y + fftHeight + 10); rectMax = ImVec2(widgetPos.x + 51 + right, widgetPos.y + fftHeight + 10);
lbwSelMin = ImVec2(rectMin.x - 1, rectMin.y); lbwSelMin = ImVec2(rectMin.x - 2, rectMin.y);
lbwSelMax = ImVec2(rectMin.x + 1, rectMax.y); lbwSelMax = ImVec2(rectMin.x + 2, rectMax.y);
rbwSelMin = ImVec2(rectMax.x - 2, rectMin.y);
rbwSelMax = ImVec2(rectMax.x + 2, rectMax.y);
} }
void WaterfallVFO::draw(ImGuiWindow* window, bool selected) { void WaterfallVFO::draw(ImGuiWindow* window, bool selected) {
@ -949,6 +1001,16 @@ namespace ImGui {
if (lineVisible) { if (lineVisible) {
window->DrawList->AddLine(lineMin, lineMax, selected ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255)); window->DrawList->AddLine(lineMin, lineMax, selected ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255));
} }
ImVec2 mousePos = ImGui::GetMousePos();
if (reference != REF_LOWER && !bandwidthLocked) {
if (IS_IN_AREA(mousePos, lbwSelMin, lbwSelMax)) { ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW); }
else if (IS_IN_AREA(mousePos, wfLbwSelMin, wfLbwSelMax)) { ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW); }
}
if (reference != REF_UPPER && !bandwidthLocked) {
if (IS_IN_AREA(mousePos, rbwSelMin, rbwSelMax)) { ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW); }
else if (IS_IN_AREA(mousePos, wfRbwSelMin, wfRbwSelMax)) { ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW); }
}
}; };
void WaterFall::showWaterfall() { void WaterFall::showWaterfall() {

View File

@ -56,6 +56,11 @@ namespace ImGui {
bool upperOffsetChanged = false; bool upperOffsetChanged = false;
bool redrawRequired = true; bool redrawRequired = true;
bool lineVisible = true; bool lineVisible = true;
bool bandwidthChanged = false;
double minBandwidth;
double maxBandwidth;
bool bandwidthLocked;
}; };
class WaterFall { class WaterFall {
@ -228,5 +233,12 @@ namespace ImGui {
bool _fullUpdate = true; bool _fullUpdate = true;
int bandPlanPos = BANDPLAN_POS_BOTTOM; int bandPlanPos = BANDPLAN_POS_BOTTOM;
// UI Select elements
bool freqScaleSelect = false;
bool vfoSelect = false;
bool vfoBorderSelect = false;
WaterfallVFO* relatedVfo = NULL;
ImVec2 mouseDownPos;
}; };
}; };

View File

@ -1,13 +1,16 @@
#include <signal_path/vfo_manager.h> #include <signal_path/vfo_manager.h>
#include <signal_path/signal_path.h> #include <signal_path/signal_path.h>
VFOManager::VFO::VFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, int blockSize) { VFOManager::VFO::VFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, double minBandwidth, double maxBandwidth, bool bandwidthLocked) {
this->name = name; this->name = name;
dspVFO = sigpath::signalPath.addVFO(name, sampleRate, bandwidth, offset); dspVFO = sigpath::signalPath.addVFO(name, sampleRate, bandwidth, offset);
wtfVFO = new ImGui::WaterfallVFO; wtfVFO = new ImGui::WaterfallVFO;
wtfVFO->setReference(reference); wtfVFO->setReference(reference);
wtfVFO->setBandwidth(bandwidth); wtfVFO->setBandwidth(bandwidth);
wtfVFO->setOffset(offset); wtfVFO->setOffset(offset);
wtfVFO->minBandwidth = minBandwidth;
wtfVFO->maxBandwidth = maxBandwidth;
wtfVFO->bandwidthLocked = bandwidthLocked;
output = dspVFO->out; output = dspVFO->out;
gui::waterfall.vfos[name] = wtfVFO; gui::waterfall.vfos[name] = wtfVFO;
} }
@ -32,8 +35,8 @@ void VFOManager::VFO::setCenterOffset(double offset) {
dspVFO->setOffset(offset); dspVFO->setOffset(offset);
} }
void VFOManager::VFO::setBandwidth(double bandwidth) { void VFOManager::VFO::setBandwidth(double bandwidth, bool updateWaterfall) {
wtfVFO->setBandwidth(bandwidth); if (updateWaterfall) { wtfVFO->setBandwidth(bandwidth); }
dspVFO->setBandwidth(bandwidth); dspVFO->setBandwidth(bandwidth);
} }
@ -46,25 +49,35 @@ void VFOManager::VFO::setReference(int ref) {
wtfVFO->setReference(ref); wtfVFO->setReference(ref);
} }
int VFOManager::VFO::getOutputBlockSize() {
// NOTE: This shouldn't be needed anymore
return 1; //dspVFO->getOutputBlockSize();
}
void VFOManager::VFO::setSnapInterval(double interval) { void VFOManager::VFO::setSnapInterval(double interval) {
wtfVFO->setSnapInterval(interval); wtfVFO->setSnapInterval(interval);
} }
void VFOManager::VFO::setBandwidthLimits(double minBandwidth, double maxBandwidth, bool bandwidthLocked) {
wtfVFO->minBandwidth = minBandwidth;
wtfVFO->maxBandwidth = maxBandwidth;
wtfVFO->bandwidthLocked = bandwidthLocked;
}
bool VFOManager::VFO::getBandwidthChanged(bool erase) {
bool val = wtfVFO->bandwidthChanged;
if (erase) { wtfVFO->bandwidthChanged = false; }
return val;
}
double VFOManager::VFO::getBandwidth() {
return wtfVFO->bandwidth;
}
VFOManager::VFOManager() { VFOManager::VFOManager() {
} }
VFOManager::VFO* VFOManager::createVFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, int blockSize) { VFOManager::VFO* VFOManager::createVFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, double minBandwidth, double maxBandwidth, bool bandwidthLocked) {
if (vfos.find(name) != vfos.end() || name == "") { if (vfos.find(name) != vfos.end() || name == "") {
return NULL; return NULL;
} }
VFOManager::VFO* vfo = new VFO(name, reference, offset, bandwidth, sampleRate, blockSize); VFOManager::VFO* vfo = new VFO(name, reference, offset, bandwidth, sampleRate, minBandwidth, maxBandwidth, bandwidthLocked);
vfos[name] = vfo; vfos[name] = vfo;
return vfo; return vfo;
} }
@ -98,11 +111,11 @@ void VFOManager::setCenterOffset(std::string name, double offset) {
vfos[name]->setCenterOffset(offset); vfos[name]->setCenterOffset(offset);
} }
void VFOManager::setBandwidth(std::string name, double bandwidth) { void VFOManager::setBandwidth(std::string name, double bandwidth, bool updateWaterfall) {
if (vfos.find(name) == vfos.end()) { if (vfos.find(name) == vfos.end()) {
return; return;
} }
vfos[name]->setBandwidth(bandwidth); vfos[name]->setBandwidth(bandwidth, updateWaterfall);
} }
void VFOManager::setSampleRate(std::string name, double sampleRate, double bandwidth) { void VFOManager::setSampleRate(std::string name, double sampleRate, double bandwidth) {
@ -119,11 +132,25 @@ void VFOManager::setReference(std::string name, int ref) {
vfos[name]->setReference(ref); vfos[name]->setReference(ref);
} }
int VFOManager::getOutputBlockSize(std::string name) { void VFOManager::setBandwidthLimits(std::string name, double minBandwidth, double maxBandwidth, bool bandwidthLocked) {
if (vfos.find(name) == vfos.end()) { if (vfos.find(name) == vfos.end()) {
return -1; return;
} }
return vfos[name]->getOutputBlockSize(); vfos[name]->setBandwidthLimits(minBandwidth, maxBandwidth, bandwidthLocked);
}
bool VFOManager::getBandwidthChanged(std::string name, bool erase) {
if (vfos.find(name) == vfos.end()) {
return false;
}
return vfos[name]->getBandwidthChanged(erase);
}
double VFOManager::getBandwidth(std::string name) {
if (vfos.find(name) == vfos.end()) {
return NAN;
}
return vfos[name]->getBandwidth();
} }
void VFOManager::updateFromWaterfall(ImGui::WaterFall* wtf) { void VFOManager::updateFromWaterfall(ImGui::WaterFall* wtf) {

View File

@ -9,16 +9,18 @@ public:
class VFO { class VFO {
public: public:
VFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, int blockSize); VFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, double minBandwidth, double maxBandwidth, bool bandwidthLocked);
~VFO(); ~VFO();
void setOffset(double offset); void setOffset(double offset);
void setCenterOffset(double offset); void setCenterOffset(double offset);
void setBandwidth(double bandwidth); void setBandwidth(double bandwidth, bool updateWaterfall = true);
void setSampleRate(double sampleRate, double bandwidth); void setSampleRate(double sampleRate, double bandwidth);
void setReference(int ref); void setReference(int ref);
int getOutputBlockSize();
void setSnapInterval(double interval); void setSnapInterval(double interval);
void setBandwidthLimits(double minBandwidth, double maxBandwidth, bool bandwidthLocked);
bool getBandwidthChanged(bool erase = true);
double getBandwidth();
dsp::stream<dsp::complex_t>* output; dsp::stream<dsp::complex_t>* output;
@ -31,15 +33,17 @@ public:
}; };
VFOManager::VFO* createVFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, int blockSize); VFOManager::VFO* createVFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, double minBandwidth, double maxBandwidth, bool bandwidthLocked);
void deleteVFO(VFOManager::VFO* vfo); void deleteVFO(VFOManager::VFO* vfo);
void setOffset(std::string name, double offset); void setOffset(std::string name, double offset);
void setCenterOffset(std::string name, double offset); void setCenterOffset(std::string name, double offset);
void setBandwidth(std::string name, double bandwidth); void setBandwidth(std::string name, double bandwidth, bool updateWaterfall = true);
void setSampleRate(std::string name, double sampleRate, double bandwidth); void setSampleRate(std::string name, double sampleRate, double bandwidth);
void setReference(std::string name, int ref); void setReference(std::string name, int ref);
int getOutputBlockSize(std::string name); void setBandwidthLimits(std::string name, double minBandwidth, double maxBandwidth, bool bandwidthLocked);
bool getBandwidthChanged(std::string name, bool erase = true);
double getBandwidth(std::string name);
void updateFromWaterfall(ImGui::WaterFall* wtf); void updateFromWaterfall(ImGui::WaterFall* wtf);

View File

@ -43,7 +43,7 @@ public:
Falcon9DecoderModule(std::string name) { Falcon9DecoderModule(std::string name) {
this->name = name; this->name = name;
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 4000000, INPUT_SAMPLE_RATE, 1); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 4000000, INPUT_SAMPLE_RATE, 4000000, 4000000, true);
// dsp::Splitter<float> split; // dsp::Splitter<float> split;
// dsp::Reshaper<float> reshape; // dsp::Reshaper<float> reshape;
@ -89,7 +89,7 @@ public:
} }
void enable() { void enable() {
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 4000000, INPUT_SAMPLE_RATE, 1); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 4000000, INPUT_SAMPLE_RATE, 4000000, 4000000, true);
demod.setInput(vfo->output); demod.setInput(vfo->output);

View File

@ -48,7 +48,7 @@ public:
writeBuffer = new int8_t[STREAM_BUFFER_SIZE]; writeBuffer = new int8_t[STREAM_BUFFER_SIZE];
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 150000, INPUT_SAMPLE_RATE, 1); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 150000, INPUT_SAMPLE_RATE, 150000, 150000, true);
demod.init(vfo->output, INPUT_SAMPLE_RATE, 72000.0f, 32, 0.6f, 0.1f, 0.005f); demod.init(vfo->output, INPUT_SAMPLE_RATE, 72000.0f, 32, 0.6f, 0.1f, 0.005f);
split.init(demod.out); split.init(demod.out);
split.bindStream(&symSinkStream); split.bindStream(&symSinkStream);
@ -71,7 +71,7 @@ public:
} }
void enable() { void enable() {
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 150000, INPUT_SAMPLE_RATE, 1); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 150000, INPUT_SAMPLE_RATE, 150000, 150000, true);
demod.setInput(vfo->output); demod.setInput(vfo->output);

View File

@ -80,6 +80,7 @@ public:
_vfo->setSampleRate(bbSampRate, bw); _vfo->setSampleRate(bbSampRate, bw);
_vfo->setSnapInterval(snapInterval); _vfo->setSnapInterval(snapInterval);
_vfo->setReference(ImGui::WaterfallVFO::REF_CENTER); _vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
_vfo->setBandwidthLimits(bwMin, bwMax, false);
} }
void setVFO(VFOManager::VFO* vfo) { void setVFO(VFOManager::VFO* vfo) {
@ -126,6 +127,15 @@ public:
_config->conf[uiPrefix]["AM"]["bandwidth"] = bw; _config->conf[uiPrefix]["AM"]["bandwidth"] = bw;
_config->release(true); _config->release(true);
} }
if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->aquire();
_config->conf[uiPrefix]["AM"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval"); ImGui::Text("Snap Interval");
ImGui::SameLine(); ImGui::SameLine();
@ -150,9 +160,9 @@ public:
} }
private: private:
void setBandwidth(float bandWidth) { void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bw = bandWidth; bw = bandWidth;
_vfo->setBandwidth(bw); _vfo->setBandwidth(bw, updateWaterfall);
float audioBW = std::min<float>(audioSampRate / 2.0f, bw / 2.0f); float audioBW = std::min<float>(audioSampRate / 2.0f, bw / 2.0f);
win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setSampleRate(bbSampRate * resamp.getInterpolation());
win.setCutoff(audioBW); win.setCutoff(audioBW);

View File

@ -87,6 +87,7 @@ public:
_vfo->setSampleRate(bbSampRate, bw); _vfo->setSampleRate(bbSampRate, bw);
_vfo->setSnapInterval(snapInterval); _vfo->setSnapInterval(snapInterval);
_vfo->setReference(ImGui::WaterfallVFO::REF_CENTER); _vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
_vfo->setBandwidthLimits(bwMin, bwMax, false);
} }
void setVFO(VFOManager::VFO* vfo) { void setVFO(VFOManager::VFO* vfo) {
@ -133,6 +134,14 @@ public:
_config->aquire(); _config->aquire();
_config->conf[uiPrefix]["CW"]["bandwidth"] = bw; _config->conf[uiPrefix]["CW"]["bandwidth"] = bw;
_config->release(true); _config->release(true);
}if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->aquire();
_config->conf[uiPrefix]["CW"]["bandwidth"] = bw;
_config->release(true);
}
} }
ImGui::Text("Snap Interval"); ImGui::Text("Snap Interval");
@ -158,9 +167,9 @@ public:
} }
private: private:
void setBandwidth(float bandWidth) { void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bw = bandWidth; bw = bandWidth;
_vfo->setBandwidth(bw); _vfo->setBandwidth(bw, updateWaterfall);
} }
void setSnapInterval(float snapInt) { void setSnapInterval(float snapInt) {

View File

@ -80,6 +80,7 @@ public:
_vfo->setSampleRate(bbSampRate, bw); _vfo->setSampleRate(bbSampRate, bw);
_vfo->setSnapInterval(snapInterval); _vfo->setSnapInterval(snapInterval);
_vfo->setReference(ImGui::WaterfallVFO::REF_CENTER); _vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
_vfo->setBandwidthLimits(bwMin, bwMax, false);
} }
void setVFO(VFOManager::VFO* vfo) { void setVFO(VFOManager::VFO* vfo) {
@ -126,6 +127,15 @@ public:
_config->conf[uiPrefix]["DSB"]["bandwidth"] = bw; _config->conf[uiPrefix]["DSB"]["bandwidth"] = bw;
_config->release(true); _config->release(true);
} }
if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->aquire();
_config->conf[uiPrefix]["DSB"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval"); ImGui::Text("Snap Interval");
ImGui::SameLine(); ImGui::SameLine();
@ -150,9 +160,9 @@ public:
} }
private: private:
void setBandwidth(float bandWidth) { void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bw = bandWidth; bw = bandWidth;
_vfo->setBandwidth(bw); _vfo->setBandwidth(bw, updateWaterfall);
} }
void setSnapInterval(float snapInt) { void setSnapInterval(float snapInt) {

View File

@ -72,6 +72,7 @@ public:
_vfo->setSampleRate(bbSampRate, bw); _vfo->setSampleRate(bbSampRate, bw);
_vfo->setSnapInterval(snapInterval); _vfo->setSnapInterval(snapInterval);
_vfo->setReference(ImGui::WaterfallVFO::REF_CENTER); _vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
_vfo->setBandwidthLimits(bwMin, bwMax, false);
} }
void setVFO(VFOManager::VFO* vfo) { void setVFO(VFOManager::VFO* vfo) {
@ -118,6 +119,15 @@ public:
_config->conf[uiPrefix]["FM"]["bandwidth"] = bw; _config->conf[uiPrefix]["FM"]["bandwidth"] = bw;
_config->release(true); _config->release(true);
} }
if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->aquire();
_config->conf[uiPrefix]["FM"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval"); ImGui::Text("Snap Interval");
ImGui::SameLine(); ImGui::SameLine();
@ -142,9 +152,9 @@ public:
} }
private: private:
void setBandwidth(float bandWidth) { void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bw = bandWidth; bw = bandWidth;
_vfo->setBandwidth(bw); _vfo->setBandwidth(bw, updateWaterfall);
demod.setDeviation(bw / 2.0f); demod.setDeviation(bw / 2.0f);
setAudioSampleRate(audioSampRate); setAudioSampleRate(audioSampRate);
} }

View File

@ -80,6 +80,7 @@ public:
_vfo->setSampleRate(bbSampRate, bw); _vfo->setSampleRate(bbSampRate, bw);
_vfo->setSnapInterval(snapInterval); _vfo->setSnapInterval(snapInterval);
_vfo->setReference(ImGui::WaterfallVFO::REF_UPPER); _vfo->setReference(ImGui::WaterfallVFO::REF_UPPER);
_vfo->setBandwidthLimits(bwMin, bwMax, false);
} }
void setVFO(VFOManager::VFO* vfo) { void setVFO(VFOManager::VFO* vfo) {
@ -125,6 +126,14 @@ public:
_config->aquire(); _config->aquire();
_config->conf[uiPrefix]["LSB"]["bandwidth"] = bw; _config->conf[uiPrefix]["LSB"]["bandwidth"] = bw;
_config->release(true); _config->release(true);
}if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->aquire();
_config->conf[uiPrefix]["LSB"]["bandwidth"] = bw;
_config->release(true);
}
} }
ImGui::Text("Snap Interval"); ImGui::Text("Snap Interval");
@ -150,9 +159,9 @@ public:
} }
private: private:
void setBandwidth(float bandWidth) { void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bw = bandWidth; bw = bandWidth;
_vfo->setBandwidth(bw); _vfo->setBandwidth(bw, updateWaterfall);
demod.setBandWidth(bw); demod.setBandWidth(bw);
float audioBW = std::min<float>(audioSampRate / 2.0f, bw); float audioBW = std::min<float>(audioSampRate / 2.0f, bw);
win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setSampleRate(bbSampRate * resamp.getInterpolation());

View File

@ -33,7 +33,7 @@ public:
RadioModule(std::string name) { RadioModule(std::string name) {
this->name = name; this->name = name;
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 200000, 200000, 1); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 200000, 200000, 50000, 200000, false);
ns.init(vfo->output); ns.init(vfo->output);
@ -70,7 +70,7 @@ public:
} }
void enable() { void enable() {
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 200000, 200000, 1); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 200000, 200000, 50000, 200000, false);
wfmDemod.setVFO(vfo); wfmDemod.setVFO(vfo);
fmDemod.setVFO(vfo); fmDemod.setVFO(vfo);

View File

@ -61,6 +61,7 @@ public:
_vfo->setSampleRate(audioSampRate, audioSampRate); _vfo->setSampleRate(audioSampRate, audioSampRate);
_vfo->setSnapInterval(snapInterval); _vfo->setSnapInterval(snapInterval);
_vfo->setReference(ImGui::WaterfallVFO::REF_CENTER); _vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
_vfo->setBandwidthLimits(0, 0, true);
} }
void setVFO(VFOManager::VFO* vfo) { void setVFO(VFOManager::VFO* vfo) {

View File

@ -80,6 +80,7 @@ public:
_vfo->setSampleRate(bbSampRate, bw); _vfo->setSampleRate(bbSampRate, bw);
_vfo->setSnapInterval(snapInterval); _vfo->setSnapInterval(snapInterval);
_vfo->setReference(ImGui::WaterfallVFO::REF_LOWER); _vfo->setReference(ImGui::WaterfallVFO::REF_LOWER);
_vfo->setBandwidthLimits(bwMin, bwMax, false);
} }
void setVFO(VFOManager::VFO* vfo) { void setVFO(VFOManager::VFO* vfo) {
@ -125,6 +126,14 @@ public:
_config->aquire(); _config->aquire();
_config->conf[uiPrefix]["USB"]["bandwidth"] = bw; _config->conf[uiPrefix]["USB"]["bandwidth"] = bw;
_config->release(true); _config->release(true);
}if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->aquire();
_config->conf[uiPrefix]["USB"]["bandwidth"] = bw;
_config->release(true);
}
} }
ImGui::Text("Snap Interval"); ImGui::Text("Snap Interval");
@ -150,9 +159,9 @@ public:
} }
private: private:
void setBandwidth(float bandWidth) { void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bw = bandWidth; bw = bandWidth;
_vfo->setBandwidth(bw); _vfo->setBandwidth(bw, updateWaterfall);
demod.setBandWidth(bw); demod.setBandWidth(bw);
float audioBW = std::min<float>(audioSampRate / 2.0f, bw); float audioBW = std::min<float>(audioSampRate / 2.0f, bw);
win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setSampleRate(bbSampRate * resamp.getInterpolation());

View File

@ -85,6 +85,7 @@ public:
_vfo->setSampleRate(bbSampRate, bw); _vfo->setSampleRate(bbSampRate, bw);
_vfo->setSnapInterval(snapInterval); _vfo->setSnapInterval(snapInterval);
_vfo->setReference(ImGui::WaterfallVFO::REF_CENTER); _vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
_vfo->setBandwidthLimits(bwMin, bwMax, false);
} }
void setVFO(VFOManager::VFO* vfo) { void setVFO(VFOManager::VFO* vfo) {
@ -128,12 +129,22 @@ public:
ImGui::SetNextItemWidth(menuWidth); ImGui::SetNextItemWidth(menuWidth);
if (ImGui::InputFloat(("##_radio_wfm_bw_" + uiPrefix).c_str(), &bw, 1, 100, "%.0f", 0)) { if (ImGui::InputFloat(("##_radio_wfm_bw_" + uiPrefix).c_str(), &bw, 1, 100, "%.0f", 0)) {
spdlog::warn("TEST");
bw = std::clamp<float>(bw, bwMin, bwMax); bw = std::clamp<float>(bw, bwMin, bwMax);
setBandwidth(bw); setBandwidth(bw);
_config->aquire(); _config->aquire();
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->release(true); _config->release(true);
} }
if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->aquire();
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval"); ImGui::Text("Snap Interval");
ImGui::SameLine(); ImGui::SameLine();
@ -169,9 +180,9 @@ public:
} }
private: private:
void setBandwidth(float bandWidth) { void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bw = bandWidth; bw = bandWidth;
_vfo->setBandwidth(bw); _vfo->setBandwidth(bw, updateWaterfall);
demod.setDeviation(bw / 2.0f); demod.setDeviation(bw / 2.0f);
} }

View File

@ -45,7 +45,7 @@ public:
WeatherSatDecoderModule(std::string name) { WeatherSatDecoderModule(std::string name) {
this->name = name; this->name = name;
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 1000000, 1000000, 1); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 1000000, 1000000, 1000000, 1000000, true);
decoders["NOAA HRPT"] = new NOAAHRPTDecoder(vfo, name); decoders["NOAA HRPT"] = new NOAAHRPTDecoder(vfo, name);
@ -68,7 +68,7 @@ public:
} }
void enable() { void enable() {
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 1000000, 1000000, 1); vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 1000000, 1000000, 1000000, 1000000, true);
for (auto const& [name, dec] : decoders) { dec->setVFO(vfo); } for (auto const& [name, dec] : decoders) { dec->setVFO(vfo); }
decoder->select(); decoder->select();
decoder->start(); decoder->start();

View File

@ -72,6 +72,7 @@ public:
void select() { void select() {
_vfo->setSampleRate(NOAA_HRPT_VFO_SR, NOAA_HRPT_VFO_BW); _vfo->setSampleRate(NOAA_HRPT_VFO_SR, NOAA_HRPT_VFO_BW);
_vfo->setReference(ImGui::WaterfallVFO::REF_CENTER); _vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
_vfo->setBandwidthLimits(NOAA_HRPT_VFO_BW, NOAA_HRPT_VFO_BW, true);
}; };
void start() { void start() {