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

Make NAM disablable - bypass dry signal #494

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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: 42 additions & 5 deletions NeuralAmpModeler/NeuralAmpModeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)

pGraphics->AttachBackground(BACKGROUND_FN);
pGraphics->AttachControl(new IBitmapControl(b, linesBitmap));
pGraphics->AttachControl(new IVLabelControl(titleArea, "NEURAL AMP MODELER", titleStyle));
pGraphics->AttachControl(new NAMTitleToggleControl(titleArea, kNamToggle, titleStyle.valueText));
pGraphics->AttachControl(new ISVGControl(modelIconArea, modelIconSVG));

#ifdef NAM_PICK_DIRECTORY
Expand Down Expand Up @@ -256,7 +256,12 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
pControl->SetMouseOverWhenDisabled(true);
});

pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetMouseEventsWhenDisabled(false);
pGraphics->GetControlWithParamIdx(kOutNorm)->SetMouseEventsWhenDisabled(false);
pGraphics->GetControlWithParamIdx(kNoiseGateActive)->SetMouseEventsWhenDisabled(false);
pGraphics->GetControlWithParamIdx(kEQActive)->SetMouseEventsWhenDisabled(false);
pGraphics->GetControlWithParamIdx(kIRToggle)->SetMouseEventsWhenDisabled(false);

pGraphics->GetControlWithParamIdx(kNamToggle)->SetValueFromUserInput(1); // enabled by default
marmal95 marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand All @@ -273,6 +278,13 @@ void NeuralAmpModeler::ProcessBlock(iplug::sample** inputs, iplug::sample** outp
const size_t numFrames = (size_t)nFrames;
const double sampleRate = GetSampleRate();

if (const bool namActive = GetParam(kNamToggle)->Value(); !namActive)
{
_ProcessOutput(inputs, outputs, numFrames, numChannelsInternal, numChannelsExternalOut);
_UpdateMeters(inputs, outputs, numFrames, numChannelsInternal, numChannelsExternalOut);
return;
sdatkinson marked this conversation as resolved.
Show resolved Hide resolved
}

// Disable floating point denormals
std::fenv_t fe_state;
std::feholdexcept(&fe_state);
Expand Down Expand Up @@ -376,7 +388,10 @@ void NeuralAmpModeler::OnIdle()
if (mNewModelLoadedInDSP)
{
if (auto* pGraphics = GetUI())
pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!mModel->HasLoudness());
{
pGraphics->GetControlWithTag(kCtrlTagOutNorm)
->SetDisabled(!mModel->HasLoudness() || !GetParam(kNamToggle)->Value());
}

mNewModelLoadedInDSP = false;
}
Expand Down Expand Up @@ -471,7 +486,8 @@ void NeuralAmpModeler::OnParamChangeUI(int paramIdx, EParamSource source)
case kEQActive:
pGraphics->ForControlInGroup("EQ_KNOBS", [active](IControl* pControl) { pControl->SetDisabled(!active); });
break;
case kIRToggle: pGraphics->GetControlWithTag(kCtrlTagIRFileBrowser)->SetDisabled(!active);
case kIRToggle: pGraphics->GetControlWithTag(kCtrlTagIRFileBrowser)->SetDisabled(!active); break;
case kNamToggle: _SetDisabledForAllControl(!active); break;
default: break;
}
}
Expand Down Expand Up @@ -790,7 +806,8 @@ void NeuralAmpModeler::_ProcessInput(iplug::sample** inputs, const size_t nFrame
void NeuralAmpModeler::_ProcessOutput(iplug::sample** inputs, iplug::sample** outputs, const size_t nFrames,
const size_t nChansIn, const size_t nChansOut)
{
const double gain = pow(10.0, GetParam(kOutputLevel)->Value() / 20.0);
const bool namActive = GetParam(kNamToggle)->Value();
marmal95 marked this conversation as resolved.
Show resolved Hide resolved
const double gain = namActive ? pow(10.0, GetParam(kOutputLevel)->Value() / 20.0) : 1;
// Assume _PrepareBuffers() was already called
if (nChansIn != 1)
throw std::runtime_error("Plugin is supposed to process in mono.");
Expand Down Expand Up @@ -900,3 +917,23 @@ void NeuralAmpModeler::_UpdateMeters(sample** inputPointer, sample** outputPoint
mInputSender.ProcessBlock(inputPointer, (int)nFrames, kCtrlTagInputMeter, nChansHack);
mOutputSender.ProcessBlock(outputPointer, (int)nFrames, kCtrlTagOutputMeter, nChansHack);
}

void NeuralAmpModeler::_SetDisabledForAllControl(const bool disabled)
sdatkinson marked this conversation as resolved.
Show resolved Hide resolved
{
if (const auto ui = GetUI(); ui != nullptr)
sdatkinson marked this conversation as resolved.
Show resolved Hide resolved
{
ui->GetControlWithParamIdx(kEQActive)->SetDisabled(disabled);
ui->GetControlWithParamIdx(kOutNorm)->SetDisabled(disabled);

ui->GetControlWithTag(kCtrlTagModelFileBrowser)->SetDisabled(disabled);
ui->GetControlWithTag(kCtrlTagIRFileBrowser)->SetDisabled(disabled);

ui->GetControlWithParamIdx(kNoiseGateActive)->SetDisabled(disabled);
ui->GetControlWithParamIdx(kNoiseGateThreshold)->SetDisabled(disabled);
ui->GetControlWithParamIdx(kInputLevel)->SetDisabled(disabled);
ui->GetControlWithParamIdx(kOutputLevel)->SetDisabled(disabled);
ui->GetControlWithParamIdx(kIRToggle)->SetDisabled(disabled);

ui->ForControlInGroup("EQ_KNOBS", [disabled](auto* ctrl) { ctrl->SetDisabled(disabled); });
marmal95 marked this conversation as resolved.
Show resolved Hide resolved
}
}
4 changes: 4 additions & 0 deletions NeuralAmpModeler/NeuralAmpModeler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum EParams
kToneTreble,
kOutputLevel,
// The rest is fine though.
kNamToggle,
marmal95 marked this conversation as resolved.
Show resolved Hide resolved
kNoiseGateActive,
kEQActive,
kOutNorm,
Expand Down Expand Up @@ -243,6 +244,9 @@ class NeuralAmpModeler final : public iplug::Plugin
void _UpdateMeters(iplug::sample** inputPointer, iplug::sample** outputPointer, const size_t nFrames,
const size_t nChansIn, const size_t nChansOut);

// Toggles Disabled flag for all controls
void _SetDisabledForAllControl(const bool disabled);

// Member data

// Input arrays to NAM
Expand Down
27 changes: 26 additions & 1 deletion NeuralAmpModeler/NeuralAmpModelerControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
auto clearFileFunc = [&](IControl* pCaller) {
pCaller->GetDelegate()->SendArbitraryMsgFromUI(mClearMsgTag);
mFileNameControl->SetLabelAndTooltip(mDefaultLabelStr.Get());
pCaller->GetUI()->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(false);

const bool namActive = pCaller->GetUI()->GetControlWithParamIdx(kNamToggle)->GetValue();
sdatkinson marked this conversation as resolved.
Show resolved Hide resolved
pCaller->GetUI()->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!namActive);
};

auto chooseFileFunc = [&, loadFileFunc](IControl* pCaller) {
Expand Down Expand Up @@ -558,3 +560,26 @@ class NAMAboutBoxControl : public IContainerBase
int mAnimationTime = 200;
bool mWillHide = false;
};

class NAMTitleToggleControl : public ITextToggleControl
sdatkinson marked this conversation as resolved.
Show resolved Hide resolved
{
public:
NAMTitleToggleControl(const IRECT& bounds, int paramIdx, const IText& text)
: ITextToggleControl(bounds, paramIdx, "NEURAL AMP MODELER", "NEURAL AMP MODELER", text)
{
}

void Draw(IGraphics& g) override
{
if (GetValue())
{
SetText(mText.WithFGColor(COLOR_WHITE));
}
else
{
SetText(mText.WithFGColor(COLOR_BLACK));
}

ITextToggleControl::Draw(g);
}
};
Loading