commit 96b250055e295b2859381d0a27ecb4fa011d29db
parent 21df0da7e677e337d0208e022ce700b0e87b1a6d
Author: Steven Atkinson <steven@atkinson.mn>
Date: Sat, 12 Aug 2023 16:58:02 -0400
Controls note failures to load model/IR on unserialization (#359)
* Indicate failures to load model and/or IR on unserialization
* Remove new entitlements file
Diffstat:
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp
@@ -421,9 +421,21 @@ void NeuralAmpModeler::OnUIOpen()
Plugin::OnUIOpen();
if (mNAMPath.GetLength())
+ {
SendControlMsgFromDelegate(kCtrlTagModelFileBrowser, kMsgTagLoadedModel, mNAMPath.GetLength(), mNAMPath.Get());
+ // If it's not loaded yet, then mark as failed.
+ // If it's yet to be loaded, then the completion handler will set us straight once it runs.
+ if (mModel == nullptr && mStagedModel == nullptr)
+ SendControlMsgFromDelegate(kCtrlTagModelFileBrowser, kMsgTagLoadFailed);
+ }
+
if (mIRPath.GetLength())
+ {
SendControlMsgFromDelegate(kCtrlTagIRFileBrowser, kMsgTagLoadedIR, mIRPath.GetLength(), mIRPath.Get());
+ if (mIR == nullptr && mStagedIR == nullptr)
+ SendControlMsgFromDelegate(kCtrlTagIRFileBrowser, kMsgTagLoadFailed);
+ }
+
if (mModel != nullptr)
GetUI()->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!mModel->HasLoudness());
mCheckSampleRateWarning = true;
@@ -578,18 +590,22 @@ void NeuralAmpModeler::_ResampleModelAndIR()
const auto sampleRate = GetSampleRate();
// Model
// TODO
-
+
// IR
- if (mStagedIR != nullptr) {
+ if (mStagedIR != nullptr)
+ {
const double irSampleRate = mStagedIR->GetSampleRate();
- if (irSampleRate != sampleRate) {
+ if (irSampleRate != sampleRate)
+ {
const auto irData = mStagedIR->GetData();
mStagedIR = std::make_unique<dsp::ImpulseResponse>(irData, sampleRate);
}
}
- else if (mIR != nullptr) {
+ else if (mIR != nullptr)
+ {
const double irSampleRate = mIR->GetSampleRate();
- if (irSampleRate != sampleRate) {
+ if (irSampleRate != sampleRate)
+ {
const auto irData = mIR->GetData();
mStagedIR = std::make_unique<dsp::ImpulseResponse>(irData, sampleRate);
}
@@ -606,7 +622,7 @@ std::string NeuralAmpModeler::_StageModel(const WDL_String& modelPath)
mNAMPath = modelPath;
SendControlMsgFromDelegate(kCtrlTagModelFileBrowser, kMsgTagLoadedModel, mNAMPath.GetLength(), mNAMPath.Get());
}
- catch (std::exception& e)
+ catch (std::runtime_error& e)
{
SendControlMsgFromDelegate(kCtrlTagModelFileBrowser, kMsgTagLoadFailed);
@@ -635,7 +651,7 @@ dsp::wav::LoadReturnCode NeuralAmpModeler::_StageIR(const WDL_String& irPath)
mStagedIR = std::make_unique<dsp::ImpulseResponse>(irPathU8.string().c_str(), sampleRate);
wavState = mStagedIR->GetWavState();
}
- catch (std::exception& e)
+ catch (std::runtime_error& e)
{
wavState = dsp::wav::LoadReturnCode::ERROR_OTHER;
std::cerr << "Caught unhandled exception while attempting to load IR:" << std::endl;
diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h
@@ -356,15 +356,14 @@ public:
case kMsgTagLoadedModel:
case kMsgTagLoadedIR:
{
- WDL_String fileName;
+ WDL_String fileName, directory;
fileName.Set(reinterpret_cast<const char*>(pData));
+ directory.Set(reinterpret_cast<const char*>(pData));
+ directory.remove_filepart(true);
+
ClearPathList();
- fileName.remove_filepart(true);
- AddPath(fileName.Get(), "");
+ AddPath(directory.Get(), "");
SetupMenu();
-
- // reset
- fileName.Set(reinterpret_cast<const char*>(pData));
SetSelectedFile(fileName.Get());
mFileNameControl->SetLabelAndTooltipEllipsizing(fileName);
break;