NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
Log | Files | Refs | Submodules | README | LICENSE

commit e22525653fbddf39038937f2de34356a057bf811
parent fd51b4e7ebd71d4da3fa1db966260bafa866f909
Author: Steven Atkinson <steven@atkinson.mn>
Date:   Sun, 16 Apr 2023 23:31:59 -0700

Fix OutNorm on UI init

Diffstat:
MNeuralAmpModeler/NeuralAmpModeler.cpp | 41++++++++++++++++++++---------------------
MNeuralAmpModeler/NeuralAmpModeler.h | 5+++++
2 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -621,6 +621,8 @@ void NeuralAmpModeler::OnUIOpen() this->_SetModelMsg(this->mNAMPath); if (this->mIRPath.GetLength()) this->_SetIRMsg(this->mIRPath); + if (this->mNAM != nullptr) + this->_SetOutputNormalizationDisableState(!this->mNAM->HasLoudness()); } // Private methods ============================================================ @@ -672,27 +674,8 @@ void NeuralAmpModeler::_ApplyDSPStaging() } if (this->mFlagSetDisableNormalization) { - try - { - // Disable Normalization toggle when no loudness data in model metadata - // Sometimes the UI isn't initialized, so we have to try again later. - auto ui = GetUI(); - if (ui != nullptr) - { - auto c = ui->GetControlWithTag(kOutNorm); - if (c != nullptr) - { - c->SetDisabled(this->mSetDisableNormalization); - if (c->IsDisabled() == this->mSetDisableNormalization) - { - this->mFlagSetDisableNormalization = false; - } - } - } - } - catch (std::runtime_error& e) - { - } + if (this->_SetOutputNormalizationDisableState(this->mSetDisableNormalization)) + this->mFlagSetDisableNormalization = false; } } @@ -897,6 +880,22 @@ void NeuralAmpModeler::_SetIRMsg(const WDL_String& irPath) SendControlMsgFromDelegate(kCtrlTagIRName, 0, int(strlen(ss.str().c_str())), ss.str().c_str()); } +bool NeuralAmpModeler::_SetOutputNormalizationDisableState(const bool disable) +{ + bool success = false; + auto ui = this->GetUI(); + if (ui != nullptr) + { + auto c = ui->GetControlWithTag(kOutNorm); + if (c != nullptr) + { + c->SetDisabled(disable); + success = c->IsDisabled() == disable; + } + } + return success; +} + void NeuralAmpModeler::_UnsetModelMsg() { this->_UnsetMsg(kCtrlTagModelName, this->mDefaultNAMString); diff --git a/NeuralAmpModeler/NeuralAmpModeler.h b/NeuralAmpModeler/NeuralAmpModeler.h @@ -105,6 +105,11 @@ private: const size_t nChansOut); // Update the text in the IR area to say what's loaded. void _SetIRMsg(const WDL_String& irPath); + // Disable Normalization toggle when no loudness data in model metadata + // Sometimes the UI isn't initialized, so we have to try again later. + // + // Returns whether it was successful + bool _SetOutputNormalizationDisableState(const bool disable); void _UnsetModelMsg(); void _UnsetIRMsg(); void _UnsetMsg(const int tag, const WDL_String& msg);