diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp index 0528a30d..24099959 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.cpp +++ b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -517,14 +517,18 @@ void NeuralAmpModeler::_CheckSampleRateWarning() { if (auto* pGraphics = GetUI()) { + auto* control = pGraphics->GetControlWithTag(kCtrlTagSampleRateWarning)->As(); bool showWarning = false; if (_HaveModel()) { const auto pluginSampleRate = GetSampleRate(); - const double namSampleRate = 48000.0; // TODO from model + const auto namSampleRateFromModel = mModel->GetExpectedSampleRate(); + // Any model with "-1" is probably 48k + const auto namSampleRate = namSampleRateFromModel == -1.0 ? 48000.0 : namSampleRateFromModel; + control->SetSampleRate(namSampleRate); showWarning = pluginSampleRate != namSampleRate; } - pGraphics->GetControlWithTag(kCtrlTagSampleRateWarning)->SetDisabled(!showWarning); + control->SetDisabled(!showWarning); mCheckSampleRateWarning = false; } } diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index 34f8c00f..670c1144 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -1,5 +1,7 @@ #pragma once +#include // std::round +#include // std::stringstream #include "IControls.h" #define PLUG() static_cast(GetDelegate()) @@ -436,10 +438,11 @@ class NAMSampleRateWarningControl : public ITextControl { public: NAMSampleRateWarningControl(const IRECT& bounds) - : ITextControl(bounds, "WARNING: Run NAM at sample rate 48kHz!", _WARNING_TEXT) + : ITextControl(bounds, "", _WARNING_TEXT) { // Default to disabled so that we don't get a flash every time we open the UI. SetDisabled(true); + SetSampleRate(48000.0); } void SetDisabled(bool disable) override { @@ -449,6 +452,14 @@ class NAMSampleRateWarningControl : public ITextControl SetDirty(false); } } + // Adjust what's displayed according to the provided smalpe rate. + // Assumes that the given value is valid. + void SetSampleRate(const double sampleRate) + { + std::stringstream ss; + ss << "WARNING: NAM model expects sample rate " << static_cast(std::round(sampleRate)); + SetStr(ss.str().c_str()); + } protected: float mDisabledBlend = 0.0f; // when this is disabled, it's completely gone.