From 2997d2151cb8331ba8e2af014e358209d9be0bb0 Mon Sep 17 00:00:00 2001 From: jthedering <51533355+jthedering@users.noreply.github.com> Date: Wed, 19 Jul 2017 19:20:02 +0000 Subject: [PATCH] Fixed: When removing a row with embedded VST plugin, the Configuration Editor crashed. Fixed: Analysis panel was not always working correctly when the loudness correction was active, especially on single-core systems. Fixed: Font of attribution in loudness correction GUI was too small. --- Editor/guis/LoudnessCorrectionFilterGUI.ui | 4 +++- Editor/guis/VSTPluginFilterGUI.cpp | 13 ++++++------ Editor/guis/VSTPluginFilterGUI.h | 1 + .../LoudnessCorrectionFilter.cpp | 20 +++++++++++++++++-- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Editor/guis/LoudnessCorrectionFilterGUI.ui b/Editor/guis/LoudnessCorrectionFilterGUI.ui index 2a83bab..1a1f390 100644 --- a/Editor/guis/LoudnessCorrectionFilterGUI.ui +++ b/Editor/guis/LoudnessCorrectionFilterGUI.ui @@ -98,8 +98,10 @@ - 6 + 7 + 50 true + false diff --git a/Editor/guis/VSTPluginFilterGUI.cpp b/Editor/guis/VSTPluginFilterGUI.cpp index 411c0e6..c66ebb9 100644 --- a/Editor/guis/VSTPluginFilterGUI.cpp +++ b/Editor/guis/VSTPluginFilterGUI.cpp @@ -59,7 +59,7 @@ VSTPluginFilterGUI::~VSTPluginFilterGUI() { if (effect != NULL) { - if (ui->embedAction->isChecked()) + if (embedded) on_embedAction_toggled(false); delete effect; effect = NULL; @@ -295,9 +295,9 @@ void VSTPluginFilterGUI::on_embedAction_toggled(bool checked) if (effect == NULL) enable = false; - bool wasEnabled = ui->frame->isVisible(); - if (enable != wasEnabled) + if (enable != embedded) { + embedded = enable; ui->frame->setVisible(enable); ui->statusLabel->setVisible(!enable); @@ -310,6 +310,7 @@ void VSTPluginFilterGUI::on_embedAction_toggled(bool checked) } else { + embedded = false; ui->frame->setVisible(false); ui->statusLabel->setVisible(true); @@ -339,7 +340,7 @@ void VSTPluginFilterGUI::on_idle() { effect->doIdle(); - if (ui->frame->isVisible() || autoApplyDialog) + if (embedded || autoApplyDialog) { if (!lastReadTimer.isValid() || lastReadTimer.elapsed() > 1000) { @@ -361,7 +362,7 @@ void VSTPluginFilterGUI::on_idle() void VSTPluginFilterGUI::onAutomate() { - if (ui->frame->isVisible() || autoApplyDialog) + if (embedded || autoApplyDialog) { effect->readFromEffect(chunkData, paramMap); updateModel(); @@ -371,7 +372,7 @@ void VSTPluginFilterGUI::onAutomate() void VSTPluginFilterGUI::onSizeWindow(int w, int h) { - if (ui->frame->isVisible()) + if (embedded) ui->frame->setFixedSize(w, h); } diff --git a/Editor/guis/VSTPluginFilterGUI.h b/Editor/guis/VSTPluginFilterGUI.h index 1390911..129ead1 100644 --- a/Editor/guis/VSTPluginFilterGUI.h +++ b/Editor/guis/VSTPluginFilterGUI.h @@ -61,6 +61,7 @@ private: VSTPluginInstance* effect = NULL; std::wstring chunkData; std::unordered_map paramMap; + bool embedded = false; bool autoApplyDialog = false; QElapsedTimer lastReadTimer; }; diff --git a/filters/loudnessCorrection/LoudnessCorrectionFilter.cpp b/filters/loudnessCorrection/LoudnessCorrectionFilter.cpp index 22661fe..1d160bb 100644 --- a/filters/loudnessCorrection/LoudnessCorrectionFilter.cpp +++ b/filters/loudnessCorrection/LoudnessCorrectionFilter.cpp @@ -62,10 +62,26 @@ std::vector LoudnessCorrectionFilter::initialize(float sampleRate, _highShelfBiquads.resize(_channelCount); _sampleRate = sampleRate; _attFactor = 1.0; + _neutral = true; + + double freqLS = 75, qLS = 1, gainLS = 0; + double freqHS = 10000, qHS = 1, gainHS = 0; + VolumeController VolumeController; + float vol; + HRESULT res = VolumeController.getVolume(vol); + if (res == S_OK) + { + double preAmp; + getLShelfParamter(vol, freqLS, qLS, gainLS, preAmp); + _attFactor = exp(preAmp / 6 * log(2)); + getHShelfParamter(vol + (float)preAmp, freqHS, qHS, gainHS); + _neutral = std::max(std::abs(gainLS), std::abs(gainHS)) < 0.2 ? true : false; + } + for (unsigned i = 0; i < _channelCount; i++) { - _lowShelfBiquads[i] = BiQuad(BiQuad::LOW_SHELF, 0, 75, _sampleRate, 1, false); - _highShelfBiquads[i] = BiQuad(BiQuad::HIGH_SHELF, 0, 10000, _sampleRate, 1, false); + _lowShelfBiquads[i] = BiQuad(BiQuad::LOW_SHELF, gainLS, freqLS, _sampleRate, qLS, false); + _highShelfBiquads[i] = BiQuad(BiQuad::HIGH_SHELF, gainHS, freqHS, _sampleRate, qHS, false); } _stopParameterUpdateThreadEvent = CreateEvent(NULL, true, false, NULL); _parameterchangedEvent = CreateEvent(NULL, true, false, NULL);