File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -517,14 +517,18 @@ void NeuralAmpModeler::_CheckSampleRateWarning()
517517{
518518 if (auto * pGraphics = GetUI ())
519519 {
520+ auto * control = pGraphics->GetControlWithTag (kCtrlTagSampleRateWarning )->As <NAMSampleRateWarningControl>();
520521 bool showWarning = false ;
521522 if (_HaveModel ())
522523 {
523524 const auto pluginSampleRate = GetSampleRate ();
524- const double namSampleRate = 48000.0 ; // TODO from model
525+ const auto namSampleRateFromModel = mModel ->GetExpectedSampleRate ();
526+ // Any model with "-1" is probably 48k
527+ const auto namSampleRate = namSampleRateFromModel == -1.0 ? 48000.0 : namSampleRateFromModel;
528+ control->SetSampleRate (namSampleRate);
525529 showWarning = pluginSampleRate != namSampleRate;
526530 }
527- pGraphics-> GetControlWithTag ( kCtrlTagSampleRateWarning ) ->SetDisabled (!showWarning);
531+ control ->SetDisabled (!showWarning);
528532 mCheckSampleRateWarning = false ;
529533 }
530534}
Original file line number Diff line number Diff line change 11#pragma once
22
3+ #include < cmath> // std::round
4+ #include < sstream> // std::stringstream
35#include " IControls.h"
46
57#define PLUG () static_cast <PLUG_CLASS_NAME*>(GetDelegate())
@@ -436,10 +438,11 @@ class NAMSampleRateWarningControl : public ITextControl
436438{
437439public:
438440 NAMSampleRateWarningControl (const IRECT& bounds)
439- : ITextControl(bounds, " WARNING: Run NAM at sample rate 48kHz! " , _WARNING_TEXT)
441+ : ITextControl(bounds, " " , _WARNING_TEXT)
440442 {
441443 // Default to disabled so that we don't get a flash every time we open the UI.
442444 SetDisabled (true );
445+ SetSampleRate (48000.0 );
443446 }
444447 void SetDisabled (bool disable) override
445448 {
@@ -449,6 +452,14 @@ class NAMSampleRateWarningControl : public ITextControl
449452 SetDirty (false );
450453 }
451454 }
455+ // Adjust what's displayed according to the provided smalpe rate.
456+ // Assumes that the given value is valid.
457+ void SetSampleRate (const double sampleRate)
458+ {
459+ std::stringstream ss;
460+ ss << " WARNING: NAM model expects sample rate " << static_cast <long >(std::round (sampleRate));
461+ SetStr (ss.str ().c_str ());
462+ }
452463
453464protected:
454465 float mDisabledBlend = 0 .0f ; // when this is disabled, it's completely gone.
You can’t perform that action at this time.
0 commit comments