Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Show model info after re-opening UI #527

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions NeuralAmpModeler/NeuralAmpModeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,20 +387,7 @@ void NeuralAmpModeler::OnIdle()
if (auto* pGraphics = GetUI())
{
pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!mModel->HasLoudness());
ModelInfo modelInfo;
modelInfo.sampleRate.known = true;
modelInfo.sampleRate.value = mModel->GetEncapsulatedSampleRate();
modelInfo.inputCalibrationLevel.known = mModel->HasInputLevel();
modelInfo.inputCalibrationLevel.value = mModel->HasInputLevel() ? mModel->GetInputLevel() : 0.0;
modelInfo.outputCalibrationLevel.known = mModel->HasOutputLevel();
modelInfo.outputCalibrationLevel.value = mModel->HasOutputLevel() ? mModel->GetOutputLevel() : 0.0;

static_cast<NAMSettingsPageControl*>(pGraphics->GetControlWithTag(kCtrlTagSettingsBox))->SetModelInfo(modelInfo);

const bool disableInputCalibrationControls = !mModel->HasInputLevel();
pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetDisabled(disableInputCalibrationControls);
pGraphics->GetControlWithTag(kCtrlTagInputCalibrationLevel)->SetDisabled(disableInputCalibrationControls);

_UpdateControlsFromModel();
mNewModelLoadedInDSP = false;
}
}
Expand Down Expand Up @@ -479,12 +466,7 @@ void NeuralAmpModeler::OnUIOpen()

if (mModel != nullptr)
{
auto* pGraphics = GetUI();
assert(pGraphics != nullptr);
pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!mModel->HasLoudness());
const bool disableInputCalibrationControls = !mModel->HasInputLevel();
pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetDisabled(disableInputCalibrationControls);
pGraphics->GetControlWithTag(kCtrlTagInputCalibrationLevel)->SetDisabled(disableInputCalibrationControls);
_UpdateControlsFromModel();
}
}

Expand Down Expand Up @@ -939,6 +921,31 @@ int NeuralAmpModeler::_UnserializeStateLegacy_0_7_9(const IByteChunk& chunk, int
return pos;
}

void NeuralAmpModeler::_UpdateControlsFromModel()
{
if (mModel == nullptr)
{
return;
}
if (auto* pGraphics = GetUI())
{
ModelInfo modelInfo;
modelInfo.sampleRate.known = true;
modelInfo.sampleRate.value = mModel->GetEncapsulatedSampleRate();
modelInfo.inputCalibrationLevel.known = mModel->HasInputLevel();
modelInfo.inputCalibrationLevel.value = mModel->HasInputLevel() ? mModel->GetInputLevel() : 0.0;
modelInfo.outputCalibrationLevel.known = mModel->HasOutputLevel();
modelInfo.outputCalibrationLevel.value = mModel->HasOutputLevel() ? mModel->GetOutputLevel() : 0.0;

static_cast<NAMSettingsPageControl*>(pGraphics->GetControlWithTag(kCtrlTagSettingsBox))->SetModelInfo(modelInfo);

const bool disableInputCalibrationControls = !mModel->HasInputLevel();
pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!mModel->HasLoudness());
pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetDisabled(disableInputCalibrationControls);
pGraphics->GetControlWithTag(kCtrlTagInputCalibrationLevel)->SetDisabled(disableInputCalibrationControls);
}
}

void NeuralAmpModeler::_UpdateLatency()
{
int latency = 0;
Expand Down
3 changes: 3 additions & 0 deletions NeuralAmpModeler/NeuralAmpModeler.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ class NeuralAmpModeler final : public iplug::Plugin
int _UnserializeStateLegacy_0_7_9(const iplug::IByteChunk& chunk, int startPos);
// And other legacy unsrializations if/as needed...

// Update all controls that depend on a model
void _UpdateControlsFromModel();

// Make sure that the latency is reported correctly.
void _UpdateLatency();

Expand Down
Loading