From e143ee0710c635cbb5ddd496dd3dd19f717057f7 Mon Sep 17 00:00:00 2001 From: Vladimir Sadovnikov Date: Thu, 12 Sep 2024 19:58:56 +0300 Subject: [PATCH] Added +12 dB compensation on measurement of the spectrum to match the amplitude of the pure sine wave on the graph --- CHANGELOG | 3 ++- include/private/meta/spectrum_analyzer.h | 3 ++- src/main/plug/spectrum_analyzer.cpp | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1ab95c2..f199091 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,8 @@ ******************************************************************************* === 1.0.27 === - +* Added +12 dB compensation on measurement of the spectrum to match the amplitude + of the pure sine wave on the graph. === 1.0.26 === * Updated build scripts and dependencies. diff --git a/include/private/meta/spectrum_analyzer.h b/include/private/meta/spectrum_analyzer.h index afc228f..243ac17 100644 --- a/include/private/meta/spectrum_analyzer.h +++ b/include/private/meta/spectrum_analyzer.h @@ -48,7 +48,8 @@ namespace lsp static constexpr float THRESH_HI_DB = 0.0f; static constexpr float THRESH_LO_DB = -48.0f; - static constexpr float SPECTRALIZER_BOOST = 16.0f; + static constexpr float SPECTRALIZER_BOOST = GAIN_AMP_P_24_DB; + static constexpr float ANALYZER_BOOST = GAIN_AMP_P_12_DB; static constexpr size_t MMESH_STEP = 16; static constexpr size_t WND_DFL = dspu::windows::HANN; static constexpr size_t ENV_DFL = dspu::envelope::PINK_NOISE; diff --git a/src/main/plug/spectrum_analyzer.cpp b/src/main/plug/spectrum_analyzer.cpp index 392d1b4..ec7976f 100644 --- a/src/main/plug/spectrum_analyzer.cpp +++ b/src/main/plug/spectrum_analyzer.cpp @@ -736,7 +736,7 @@ namespace lsp // Apply gain float gain = (flags & F_BOOST) ? vChannels[channel].fGain * meta::spectrum_analyzer::SPECTRALIZER_BOOST: - vChannels[channel].fGain ; + vChannels[channel].fGain * meta::spectrum_analyzer::ANALYZER_BOOST; dsp::mul_k2(dst, gain * fPreamp, meta::spectrum_analyzer::MESH_POINTS); // Apply log scale if necessary @@ -926,8 +926,8 @@ namespace lsp { size_t idx = fSelector * ((fft_size - 1) >> 1); pFrequency->set_value(float(idx * fSampleRate) / float(fft_size)); - float lvl = sAnalyzer.get_level(nChannel, idx); - pLevel->set_value(lvl * c->fGain * fPreamp ); + float lvl = sAnalyzer.get_level(nChannel, idx) * meta::spectrum_analyzer::ANALYZER_BOOST; + pLevel->set_value(lvl * c->fGain * fPreamp); } // Mesh is requested?