@@ -148,6 +148,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
148148
149149 // Misc Areas
150150 const auto helpButtonArea = mainArea.GetFromTRHC (50 , 50 ).GetCentredInside (20 , 20 );
151+ const auto sampleRateWarningArea = inputMeterArea.GetFromBottom (16 .f ).GetTranslated (12 .f , 16 .f ).GetFromLeft (300 .f );
151152
152153 // Model loader button
153154 auto loadModelCompletionHandler = [&](const WDL_String& fileName, const WDL_String& path) {
@@ -224,6 +225,9 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
224225 pGraphics->AttachControl (new NAMMeterControl (inputMeterArea, meterBackgroundBitmap, style), kCtrlTagInputMeter );
225226 pGraphics->AttachControl (new NAMMeterControl (outputMeterArea, meterBackgroundBitmap, style), kCtrlTagOutputMeter );
226227
228+ // A warning when NAM isn't being run in the right sample rate:
229+ pGraphics->AttachControl (new NAMSampleRateWarningControl (sampleRateWarningArea), kCtrlTagSampleRateWarning );
230+
227231 // Help/about box
228232 pGraphics->AttachControl (new NAMCircleButtonControl (
229233 helpButtonArea,
@@ -355,6 +359,7 @@ void NeuralAmpModeler::OnReset()
355359 const auto sampleRate = GetSampleRate ();
356360 mInputSender .Reset (sampleRate);
357361 mOutputSender .Reset (sampleRate);
362+ mCheckSampleRateWarning = true ;
358363}
359364
360365void NeuralAmpModeler::OnIdle ()
@@ -369,6 +374,10 @@ void NeuralAmpModeler::OnIdle()
369374
370375 mNewModelLoadedInDSP = false ;
371376 }
377+ if (mCheckSampleRateWarning )
378+ {
379+ _CheckSampleRateWarning ();
380+ }
372381}
373382
374383bool NeuralAmpModeler::SerializeState (IByteChunk& chunk) const
@@ -403,6 +412,7 @@ void NeuralAmpModeler::OnUIOpen()
403412 SendControlMsgFromDelegate (kCtrlTagIRFileBrowser , kMsgTagLoadedIR , mIRPath .GetLength (), mIRPath .Get ());
404413 if (mModel != nullptr )
405414 GetUI ()->GetControlWithTag (kCtrlTagOutNorm )->SetDisabled (!mModel ->HasLoudness ());
415+ mCheckSampleRateWarning = true ;
406416}
407417
408418void NeuralAmpModeler::OnParamChangeUI (int paramIdx, EParamSource source)
@@ -480,6 +490,7 @@ void NeuralAmpModeler::_ApplyDSPStaging()
480490 mModel = std::move (mStagedModel );
481491 mStagedModel = nullptr ;
482492 mNewModelLoadedInDSP = true ;
493+ mCheckSampleRateWarning = true ;
483494 }
484495 if (mStagedIR != nullptr )
485496 {
@@ -492,6 +503,7 @@ void NeuralAmpModeler::_ApplyDSPStaging()
492503 mModel = nullptr ;
493504 mNAMPath .Set (" " );
494505 mShouldRemoveModel = false ;
506+ mCheckSampleRateWarning = true ;
495507 }
496508 if (mShouldRemoveIR )
497509 {
@@ -501,6 +513,22 @@ void NeuralAmpModeler::_ApplyDSPStaging()
501513 }
502514}
503515
516+ void NeuralAmpModeler::_CheckSampleRateWarning ()
517+ {
518+ if (auto * pGraphics = GetUI ())
519+ {
520+ bool showWarning = false ;
521+ if (_HaveModel ())
522+ {
523+ const auto pluginSampleRate = GetSampleRate ();
524+ const double namSampleRate = 48000.0 ; // TODO from model
525+ showWarning = pluginSampleRate != namSampleRate;
526+ }
527+ pGraphics->GetControlWithTag (kCtrlTagSampleRateWarning )->SetDisabled (!showWarning);
528+ mCheckSampleRateWarning = false ;
529+ }
530+ }
531+
504532void NeuralAmpModeler::_DeallocateIOPointers ()
505533{
506534 if (mInputPointers != nullptr )
0 commit comments