mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-06 02:37:32 +01:00
added SNR meter smoothing
This commit is contained in:
parent
8d05c1e181
commit
168e28cc44
@ -119,6 +119,8 @@ int sdrpp_main(int argc, char* argv[]) {
|
||||
defConfig["fftHoldSpeed"] = 60;
|
||||
defConfig["fftSmoothing"] = false;
|
||||
defConfig["fftSmoothingSpeed"] = 100;
|
||||
defConfig["snrSmoothing"] = false;
|
||||
defConfig["snrSmoothingSpeed"] = 20;
|
||||
defConfig["fastFFT"] = false;
|
||||
defConfig["fftHeight"] = 300;
|
||||
defConfig["fftRate"] = 20;
|
||||
|
@ -25,6 +25,8 @@ namespace displaymenu {
|
||||
int fftHoldSpeed = 60;
|
||||
bool fftSmoothing = false;
|
||||
int fftSmoothingSpeed = 100;
|
||||
bool snrSmoothing = false;
|
||||
int snrSmoothingSpeed = 20;
|
||||
|
||||
OptionList<float, float> uiScales;
|
||||
|
||||
@ -63,6 +65,7 @@ namespace displaymenu {
|
||||
void updateFFTSpeeds() {
|
||||
gui::waterfall.setFFTHoldSpeed((float)fftHoldSpeed / ((float)fftRate * 10.0f));
|
||||
gui::waterfall.setFFTSmoothingSpeed(std::min<float>((float)fftSmoothingSpeed / (float)(fftRate * 10.0f), 1.0f));
|
||||
gui::waterfall.setSNRSmoothingSpeed(std::min<float>((float)snrSmoothingSpeed / (float)(fftRate * 10.0f), 1.0f));
|
||||
}
|
||||
|
||||
void init() {
|
||||
@ -111,6 +114,9 @@ namespace displaymenu {
|
||||
fftSmoothing = core::configManager.conf["fftSmoothing"];
|
||||
fftSmoothingSpeed = core::configManager.conf["fftSmoothingSpeed"];
|
||||
gui::waterfall.setFFTSmoothing(fftSmoothing);
|
||||
snrSmoothing = core::configManager.conf["snrSmoothing"];
|
||||
snrSmoothingSpeed = core::configManager.conf["snrSmoothingSpeed"];
|
||||
gui::waterfall.setSNRSmoothing(snrSmoothing);
|
||||
updateFFTSpeeds();
|
||||
|
||||
// Define and load UI scales
|
||||
@ -151,15 +157,7 @@ namespace displaymenu {
|
||||
core::configManager.conf["fftHold"] = fftHold;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("FFT Smoothing##_sdrpp", &fftSmoothing)) {
|
||||
gui::waterfall.setFFTSmoothing(fftSmoothing);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftSmoothing"] = fftSmoothing;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
ImGui::LeftLabel("FFT Hold Speed");
|
||||
ImGui::SameLine();
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::InputInt("##sdrpp_fft_hold_speed", &fftHoldSpeed)) {
|
||||
updateFFTSpeeds();
|
||||
@ -168,7 +166,13 @@ namespace displaymenu {
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
ImGui::LeftLabel("FFT Smoothing Speed");
|
||||
if (ImGui::Checkbox("FFT Smoothing##_sdrpp", &fftSmoothing)) {
|
||||
gui::waterfall.setFFTSmoothing(fftSmoothing);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftSmoothing"] = fftSmoothing;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::InputInt("##sdrpp_fft_smoothing_speed", &fftSmoothingSpeed)) {
|
||||
fftSmoothingSpeed = std::max<int>(fftSmoothingSpeed, 1);
|
||||
@ -178,6 +182,22 @@ namespace displaymenu {
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("SNR Smoothing##_sdrpp", &snrSmoothing)) {
|
||||
gui::waterfall.setSNRSmoothing(snrSmoothing);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["snrSmoothing"] = snrSmoothing;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::InputInt("##sdrpp_snr_smoothing_speed", &snrSmoothingSpeed)) {
|
||||
snrSmoothingSpeed = std::max<int>(snrSmoothingSpeed, 1);
|
||||
updateFFTSpeeds();
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["snrSmoothingSpeed"] = snrSmoothingSpeed;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
ImGui::LeftLabel("High-DPI Scaling");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo("##sdrpp_ui_scale", &uiScaleId, uiScales.txt)) {
|
||||
|
@ -886,15 +886,22 @@ namespace ImGui {
|
||||
// Apply smoothing if enabled
|
||||
if (fftSmoothing && latestFFT != NULL && smoothingBuf != NULL && fftLines != 0) {
|
||||
std::lock_guard<std::mutex> lck2(smoothingBufMtx);
|
||||
volk_32f_s32f_multiply_32f(latestFFT, latestFFT, smoothingAlpha, dataWidth);
|
||||
volk_32f_s32f_multiply_32f(smoothingBuf, smoothingBuf, smoothingBeta, dataWidth);
|
||||
volk_32f_s32f_multiply_32f(latestFFT, latestFFT, fftSmoothingAlpha, dataWidth);
|
||||
volk_32f_s32f_multiply_32f(smoothingBuf, smoothingBuf, fftSmoothingBeta, dataWidth);
|
||||
volk_32f_x2_add_32f(smoothingBuf, latestFFT, smoothingBuf, dataWidth);
|
||||
memcpy(latestFFT, smoothingBuf, dataWidth * sizeof(float));
|
||||
}
|
||||
|
||||
if (selectedVFO != "" && vfos.size() > 0) {
|
||||
float dummy;
|
||||
calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, vfos[selectedVFO], dummy, selectedVFOSNR);
|
||||
if (snrSmoothing) {
|
||||
float newSNR = 0.0f;
|
||||
calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, vfos[selectedVFO], dummy, newSNR);
|
||||
selectedVFOSNR = (snrSmoothingBeta*selectedVFOSNR) + (snrSmoothingAlpha*newSNR);
|
||||
}
|
||||
else {
|
||||
calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, vfos[selectedVFO], dummy, selectedVFOSNR);
|
||||
}
|
||||
}
|
||||
|
||||
// If FFT hold is enabled, update it
|
||||
@ -1155,8 +1162,17 @@ namespace ImGui {
|
||||
|
||||
void WaterFall::setFFTSmoothingSpeed(float speed) {
|
||||
std::lock_guard<std::mutex> lck(smoothingBufMtx);
|
||||
smoothingAlpha = speed;
|
||||
smoothingBeta = 1.0f - speed;
|
||||
fftSmoothingAlpha = speed;
|
||||
fftSmoothingBeta = 1.0f - speed;
|
||||
}
|
||||
|
||||
void WaterFall::setSNRSmoothing(bool enabled) {
|
||||
snrSmoothing = enabled;
|
||||
}
|
||||
|
||||
void WaterFall::setSNRSmoothingSpeed(float speed) {
|
||||
snrSmoothingAlpha = speed;
|
||||
snrSmoothingBeta = 1.0f - speed;
|
||||
}
|
||||
|
||||
float* WaterFall::acquireLatestFFT(int& width) {
|
||||
|
@ -172,6 +172,9 @@ namespace ImGui {
|
||||
void setFFTSmoothing(bool enabled);
|
||||
void setFFTSmoothingSpeed(float speed);
|
||||
|
||||
void setSNRSmoothing(bool enabled);
|
||||
void setSNRSmoothingSpeed(float speed);
|
||||
|
||||
float* acquireLatestFFT(int& width);
|
||||
void releaseLatestFFT();
|
||||
|
||||
@ -185,7 +188,7 @@ namespace ImGui {
|
||||
bool mouseInFFT = false;
|
||||
bool mouseInWaterfall = false;
|
||||
|
||||
float selectedVFOSNR = NAN;
|
||||
float selectedVFOSNR = 0.0f;
|
||||
|
||||
bool centerFrequencyLocked = false;
|
||||
|
||||
@ -331,8 +334,12 @@ namespace ImGui {
|
||||
float fftHoldSpeed = 0.3f;
|
||||
|
||||
bool fftSmoothing = false;
|
||||
float smoothingAlpha = 0.5;
|
||||
float smoothingBeta = 0.5;
|
||||
float fftSmoothingAlpha = 0.5;
|
||||
float fftSmoothingBeta = 0.5;
|
||||
|
||||
bool snrSmoothing = false;
|
||||
float snrSmoothingAlpha = 0.5;
|
||||
float snrSmoothingBeta = 0.5;
|
||||
|
||||
// UI Select elements
|
||||
bool fftResizeSelect = false;
|
||||
|
Loading…
Reference in New Issue
Block a user