Fixed SNR not updating when waterfall is hidden

This commit is contained in:
Ryzerth 2021-06-29 03:32:40 +02:00
parent aaa15315ce
commit 8a1df1d712
2 changed files with 5 additions and 7 deletions

View File

@ -431,7 +431,7 @@ namespace ImGui {
ImGui::Text("Bandwidth Locked: %s", _vfo->bandwidthLocked ? "Yes" : "No");
float strength, snr;
if (calculateVFOSignalInfo(_vfo, strength, snr)) {
if (calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, _vfo, strength, snr)) {
ImGui::Text("Strength: %0.1fdBFS", strength);
ImGui::Text("SNR: %0.1fdB", snr);
}
@ -448,8 +448,8 @@ namespace ImGui {
}
}
bool WaterFall::calculateVFOSignalInfo(WaterfallVFO* _vfo, float& strength, float& snr) {
if (rawFFTs == NULL || fftLines <= 0) { return false; }
bool WaterFall::calculateVFOSignalInfo(float* fftLine, WaterfallVFO* _vfo, float& strength, float& snr) {
if (fftLine == NULL || fftLines <= 0) { return false; }
// Calculate FFT index data
double vfoMinSizeFreq = _vfo->centerOffset - _vfo->bandwidth;
@ -461,8 +461,6 @@ namespace ImGui {
int vfoMaxOffset = std::clamp<int>(((vfoMaxFreq / (wholeBandwidth/2.0)) * (double)(rawFFTSize/2)) + (rawFFTSize/2), 0, rawFFTSize);
int vfoMaxSideOffset = std::clamp<int>(((vfoMaxSizeFreq / (wholeBandwidth/2.0)) * (double)(rawFFTSize/2)) + (rawFFTSize/2), 0, rawFFTSize);
float* fftLine = &rawFFTs[currentFFTLine * rawFFTSize];
double avg = 0;
float max = -INFINITY;
int avgCount = 0;
@ -804,7 +802,7 @@ namespace ImGui {
if (selectedVFO != "" && vfos.size() > 0) {
float dummy;
calculateVFOSignalInfo(vfos[selectedVFO], dummy, selectedVFOSNR);
calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, vfos[selectedVFO], dummy, selectedVFOSNR);
}
buf_mtx.unlock();

View File

@ -165,7 +165,7 @@ namespace ImGui {
void updateWaterfallFb();
void updateWaterfallTexture();
void updateAllVFOs(bool checkRedrawRequired = false);
bool calculateVFOSignalInfo(WaterfallVFO* vfo, float& strength, float& snr);
bool calculateVFOSignalInfo(float* fftLine, WaterfallVFO* vfo, float& strength, float& snr);
bool waterfallUpdate = false;