From 6a351aaa6a19066f47389853634ad4a7b0c2ece0 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Fri, 8 Nov 2024 22:09:21 -0800 Subject: [PATCH 01/10] Rearrange about info --- NeuralAmpModeler/NeuralAmpModelerControls.h | 108 ++++++++++---------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index a1fd7d80..5449fce3 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -600,47 +600,27 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren void OnAttached() override { - AddNamedChildControl(new IBitmapControl(IRECT(), mBitmap), mControlNames.bitmap)->SetIgnoreMouse(true); - + const float pad = 20.0f; const IVStyle titleStyle = DEFAULT_STYLE.WithValueText(IText(30, COLOR_WHITE, "Michroma-Regular")) .WithDrawFrame(false) .WithShadowOffset(2.f); - - AddNamedChildControl(new IVLabelControl(IRECT(), "NEURAL AMP MODELER", titleStyle), mControlNames.title); - - WDL_String verStr, buildInfoStr; - PLUG()->GetPluginVersionStr(verStr); - - buildInfoStr.SetFormatted(100, "Version %s %s %s", verStr.Get(), PLUG()->GetArchStr(), PLUG()->GetAPIStr()); - const auto text = IText(DEFAULT_TEXT_SIZE, EAlign::Center, PluginColors::HELP_TEXT); + const auto leftText = text.WithAlign(EAlign::Near); const auto style = mStyle.WithDrawFrame(false).WithValueText(text); + const IVStyle leftStyle = style.WithValueText(leftText); - - AddNamedChildControl(new IVLabelControl(IRECT(), "By Steven Atkinson", style), mControlNames.byAuthor); - AddNamedChildControl(new IVLabelControl(IRECT(), buildInfoStr.Get(), style), mControlNames.buildInfo); - AddNamedChildControl( - new IURLControl(IRECT(), "Plug-in development: Steve Atkinson, Oli Larkin, ... ", - "https://github.com/sdatkinson/NeuralAmpModelerPlugin/graphs/contributors", text, - COLOR_TRANSPARENT, PluginColors::HELP_TEXT_MO, PluginColors::HELP_TEXT_CLICKED), - mControlNames.development); + // This'll get fixed on OnResize; FIXME + AddNamedChildControl(new IBitmapControl(IRECT(), mBitmap), mControlNames.bitmap)->SetIgnoreMouse(true); AddNamedChildControl( - new IURLControl(IRECT(), "www.neuralampmodeler.com", "https://www.neuralampmodeler.com", text, COLOR_TRANSPARENT, - PluginColors::HELP_TEXT_MO, PluginColors::HELP_TEXT_CLICKED), - mControlNames.website); - - // AddChildControl(new IVColorSwatchControl(IRECT() , "Highlight", [&](int idx, IColor color){ - // - // WDL_String colorCodeStr; - // color.ToColorCodeStr(colorCodeStr, false); - // this->GetDelegate()->SendArbitraryMsgFromUI(kMsgTagHighlightColor, kNoTag, colorCodeStr.GetLength(), - // colorCodeStr.Get()); - // - // }, mStyle, IVColorSwatchControl::ECellLayout::kHorizontal, {kFG}, {""})); - - AddNamedChildControl(new ModelInfoControl(GetRECT().GetPadded(-20.0f).GetFromBottom(75.0f).GetFromTop(30.0f), - style.WithValueText(style.valueText.WithAlign(EAlign::Near))), - mControlNames.modelInfo); + new IVLabelControl(GetRECT().GetPadded(-(pad + 10.0f)).GetFromTop(50.0f), "SETTINGS", titleStyle), + mControlNames.title); + + const float halfWidth = PLUG_WIDTH / 2.0f - pad; + const auto bottomArea = GetRECT().GetPadded(-pad).GetFromBottom(78.0f); + const auto modelInfoArea = bottomArea.GetFromLeft(halfWidth).GetFromTop(30.0f); + const auto aboutArea = bottomArea.GetFromRight(halfWidth); + AddNamedChildControl(new ModelInfoControl(modelInfoArea, leftStyle), mControlNames.modelInfo); + AddNamedChildControl(new AboutControl(aboutArea, leftStyle, leftText), mControlNames.about); auto closeAction = [&](IControl* pCaller) { static_cast(pCaller->GetParent())->HideAnimated(true); @@ -655,19 +635,8 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren { if (NChildren()) { - const IRECT mainArea = mRECT.GetPadded(-20); - const auto content = mainArea.GetPadded(-10); - const auto titleLabel = content.GetFromTop(50); GetNamedChild(mControlNames.bitmap)->SetTargetAndDrawRECTs(mRECT); - GetNamedChild(mControlNames.title)->SetTargetAndDrawRECTs(titleLabel); - GetNamedChild(mControlNames.byAuthor)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H())); - GetNamedChild(mControlNames.buildInfo) - ->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 20).GetMidVPadded(5)); - GetNamedChild(mControlNames.development) - ->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 40).GetMidVPadded(7)); - GetNamedChild(mControlNames.website) - ->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 60).GetMidVPadded(7)); - // GetChild(6)->SetTargetAndDrawRECTs(content.GetFromBRHC(100, 50)); + // Rework this later, but resizing on the main page needs to happen too. } } @@ -689,13 +658,44 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren // Make sure that these are all unique and that you use them with AddNamedChildControl struct ControlNames { - const std::string bitmap = "bitmap"; - const std::string byAuthor = "by author"; - const std::string buildInfo = "build info"; - const std::string close = "close"; - const std::string development = "development"; - const std::string modelInfo = "model info"; - const std::string title = "title"; - const std::string website = "website"; + const std::string about = "About"; + const std::string bitmap = "Bitmap"; + const std::string calibrateInput = "CalibrateInput"; + const std::string close = "Close"; + const std::string inputCalibrationLevel = "InputCalibrationLevel"; + const std::string modelInfo = "ModelInfo"; + const std::string title = "Title"; } mControlNames; + + class AboutControl : public IContainerBase + { + public: + AboutControl(const IRECT& bounds, const IVStyle& style, const IText& text) + : IContainerBase(bounds) + , mStyle(style) + , mText(text) {}; + + void OnAttached() override + { + WDL_String verStr, buildInfoStr; + PLUG()->GetPluginVersionStr(verStr); + + buildInfoStr.SetFormatted(100, "Version %s %s %s", verStr.Get(), PLUG()->GetArchStr(), PLUG()->GetAPIStr()); + + AddChildControl(new IVLabelControl(GetRECT().GetGridCell(0, 0, 5, 1), "NEURAL AMP MODELER", mStyle)); + AddChildControl(new IVLabelControl(GetRECT().GetGridCell(1, 0, 5, 1), "By Steven Atkinson", mStyle)); + AddChildControl(new IVLabelControl(GetRECT().GetGridCell(2, 0, 5, 1), buildInfoStr.Get(), mStyle)); + AddChildControl(new IURLControl(GetRECT().GetGridCell(3, 0, 5, 1), + "Plug-in development: Steve Atkinson, Oli Larkin, ... ", + "https://github.com/sdatkinson/NeuralAmpModelerPlugin/graphs/contributors", mText, + COLOR_TRANSPARENT, PluginColors::HELP_TEXT_MO, PluginColors::HELP_TEXT_CLICKED)); + AddChildControl(new IURLControl(GetRECT().GetGridCell(4, 0, 5, 1), "www.neuralampmodeler.com", + "https://www.neuralampmodeler.com", mText, COLOR_TRANSPARENT, + PluginColors::HELP_TEXT_MO, PluginColors::HELP_TEXT_CLICKED)); + }; + + private: + IVStyle mStyle; + IText mText; + }; }; From 7bb60f5a7f27883504a848885fa3c9d3b909f223 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Nov 2024 11:00:36 -0800 Subject: [PATCH 02/10] Define parameters for input calibration --- NeuralAmpModeler/NeuralAmpModeler.cpp | 2 ++ NeuralAmpModeler/NeuralAmpModeler.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp index 738717dc..6d4a5861 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.cpp +++ b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -81,6 +81,8 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) GetParam(kEQActive)->InitBool("ToneStack", true); GetParam(kOutNorm)->InitBool("OutNorm", true); GetParam(kIRToggle)->InitBool("IRToggle", true); + GetParam(kCalibrateInput)->InitBool("CalibrateInput", false); + GetParam(kInputCalibrationLevel)->InitGain("InputCalibrationLevel", 12.0, -30.0, 30.0, 0.1); mNoiseGateTrigger.AddListener(&mNoiseGateGain); diff --git a/NeuralAmpModeler/NeuralAmpModeler.h b/NeuralAmpModeler/NeuralAmpModeler.h index a391e275..b396e00f 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.h +++ b/NeuralAmpModeler/NeuralAmpModeler.h @@ -41,6 +41,9 @@ enum EParams kEQActive, kOutNorm, kIRToggle, + // Input calibration + kCalibrateInput, + kInputCalibrationLevel, kNumParams }; From 7dc35651cd7ba94f94abb648ebaeeddc5a828cd0 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Nov 2024 11:01:47 -0800 Subject: [PATCH 03/10] No click through ModelInfoControl--just use the 'close' button in the corner --- NeuralAmpModeler/NeuralAmpModelerControls.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index 5449fce3..aaa8e1c0 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -503,9 +503,6 @@ class ModelInfoControl : public IContainerBaseWithNamedChildren AddNamedChildControl(new IVLabelControl(GetRECT().GetGridCell(1, 0, 2, 1), "", mStyle), mControlNames.sampleRate); }; - // Click through me - void OnMouseDown(float x, float y, const IMouseMod& mod) override { GetParent()->OnMouseDown(x, y, mod); } - void SetModelInfo(const ModelInfo& modelInfo) { std::stringstream ss; From 523d6a2365cc6a7da9555277b13ac3647c66bc94 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Nov 2024 11:05:19 -0800 Subject: [PATCH 04/10] Settings control: Clean up OnAttached() and set rect for background immediately --- NeuralAmpModeler/NeuralAmpModelerControls.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index aaa8e1c0..cb7a23e0 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -607,7 +607,7 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren const IVStyle leftStyle = style.WithValueText(leftText); // This'll get fixed on OnResize; FIXME - AddNamedChildControl(new IBitmapControl(IRECT(), mBitmap), mControlNames.bitmap)->SetIgnoreMouse(true); + AddNamedChildControl(new IBitmapControl(GetRECT(), mBitmap), mControlNames.bitmap)->SetIgnoreMouse(true); AddNamedChildControl( new IVLabelControl(GetRECT().GetPadded(-(pad + 10.0f)).GetFromTop(50.0f), "SETTINGS", titleStyle), mControlNames.title); @@ -628,15 +628,6 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren OnResize(); } - void OnResize() override - { - if (NChildren()) - { - GetNamedChild(mControlNames.bitmap)->SetTargetAndDrawRECTs(mRECT); - // Rework this later, but resizing on the main page needs to happen too. - } - } - void SetModelInfo(const ModelInfo& modelInfo) { auto* modelInfoControl = static_cast(GetNamedChild(mControlNames.modelInfo)); From 628ec609d8584c5d66ac69c770aa722368b93f43 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Sat, 9 Nov 2024 11:35:19 -0800 Subject: [PATCH 05/10] Input calibration controls --- NeuralAmpModeler/NeuralAmpModeler.cpp | 8 ++-- NeuralAmpModeler/NeuralAmpModelerControls.h | 47 ++++++++++++++++----- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp index 6d4a5861..81e6ab87 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.cpp +++ b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -132,9 +132,8 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) // Areas for knobs const auto knobsPad = 20.0f; const auto knobsExtraSpaceBelowTitle = 25.0f; - const auto knobHeight = 120.f; const auto singleKnobPad = -2.0f; - const auto knobsArea = contentArea.GetFromTop(knobHeight) + const auto knobsArea = contentArea.GetFromTop(NAM_KNOB_HEIGHT) .GetReducedFromLeft(knobsPad) .GetReducedFromRight(knobsPad) .GetVShifted(titleHeight + knobsExtraSpaceBelowTitle); @@ -252,7 +251,10 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) }, gearSVG)); - pGraphics->AttachControl(new NAMSettingsPageControl(b, backgroundBitmap, crossSVG, style), kCtrlTagSettingsBox) + pGraphics + ->AttachControl( + new NAMSettingsPageControl(b, backgroundBitmap, knobBackgroundBitmap, switchHandleBitmap, crossSVG, style), + kCtrlTagSettingsBox) ->Hide(true); pGraphics->ForAllControlsFunc([](IControl* pControl) { diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index cb7a23e0..668f8073 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -6,6 +6,8 @@ #include "IControls.h" #define PLUG() static_cast(GetDelegate()) +#define NAM_KNOB_HEIGHT 120.0f +#define NAM_SWTICH_HEIGHT 50.0f using namespace iplug; using namespace igraphics; @@ -532,10 +534,13 @@ class ModelInfoControl : public IContainerBaseWithNamedChildren class NAMSettingsPageControl : public IContainerBaseWithNamedChildren { public: - NAMSettingsPageControl(const IRECT& bounds, const IBitmap& bitmap, ISVG closeSVG, const IVStyle& style) + NAMSettingsPageControl(const IRECT& bounds, const IBitmap& bitmap, const IBitmap& knobBitmap, + const IBitmap& switchBitmap, ISVG closeSVG, const IVStyle& style) : IContainerBaseWithNamedChildren(bounds) , mAnimationTime(0) , mBitmap(bitmap) + , mKnobBitmap(knobBitmap) + , mSwitchBitmap(switchBitmap) , mStyle(style) , mCloseSVG(closeSVG) { @@ -606,11 +611,31 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren const auto style = mStyle.WithDrawFrame(false).WithValueText(text); const IVStyle leftStyle = style.WithValueText(leftText); - // This'll get fixed on OnResize; FIXME AddNamedChildControl(new IBitmapControl(GetRECT(), mBitmap), mControlNames.bitmap)->SetIgnoreMouse(true); - AddNamedChildControl( - new IVLabelControl(GetRECT().GetPadded(-(pad + 10.0f)).GetFromTop(50.0f), "SETTINGS", titleStyle), - mControlNames.title); + const auto titleArea = GetRECT().GetPadded(-(pad + 10.0f)).GetFromTop(50.0f); + AddNamedChildControl(new IVLabelControl(titleArea, "SETTINGS", titleStyle), mControlNames.title); + + // Attach input/output calibration controls + { + const float height = NAM_KNOB_HEIGHT + NAM_SWTICH_HEIGHT + 10.0f; + const float width = titleArea.W(); + const auto inputOutputArea = titleArea.GetFromBottom(height).GetTranslated(0.0f, height); + const auto inputArea = inputOutputArea.GetFromLeft(0.5f * width); + const auto outputArea = inputOutputArea.GetFromRight(0.5f * width); + + const float knobWidth = 87.0f; // HACK based on looking at the main page knobs. + const auto inputKnobArea = inputArea.GetFromTop(NAM_KNOB_HEIGHT).GetMidHPadded(0.5f * knobWidth); + const auto inputSwitchArea = inputArea.GetFromBottom(NAM_SWTICH_HEIGHT).GetMidHPadded(0.5f * knobWidth); + ; + AddNamedChildControl(new NAMKnobControl(inputKnobArea, kInputCalibrationLevel, "Level", mStyle, mKnobBitmap), + mControlNames.inputCalibrationLevel); + AddNamedChildControl( + new NAMSwitchControl(inputSwitchArea, kCalibrateInput, "Calibrate Input", mStyle, mSwitchBitmap), + mControlNames.calibrateInput); + // TODO Disable knob if calibration is false + + // TODO output--raw, normalized, calibrated + } const float halfWidth = PLUG_WIDTH / 2.0f - pad; const auto bottomArea = GetRECT().GetPadded(-pad).GetFromBottom(78.0f); @@ -637,6 +662,8 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren private: IBitmap mBitmap; + IBitmap mKnobBitmap; + IBitmap mSwitchBitmap; IVStyle mStyle; ISVG mCloseSVG; int mAnimationTime = 200; @@ -670,14 +697,14 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren buildInfoStr.SetFormatted(100, "Version %s %s %s", verStr.Get(), PLUG()->GetArchStr(), PLUG()->GetAPIStr()); - AddChildControl(new IVLabelControl(GetRECT().GetGridCell(0, 0, 5, 1), "NEURAL AMP MODELER", mStyle)); - AddChildControl(new IVLabelControl(GetRECT().GetGridCell(1, 0, 5, 1), "By Steven Atkinson", mStyle)); - AddChildControl(new IVLabelControl(GetRECT().GetGridCell(2, 0, 5, 1), buildInfoStr.Get(), mStyle)); - AddChildControl(new IURLControl(GetRECT().GetGridCell(3, 0, 5, 1), + AddChildControl(new IVLabelControl(GetRECT().SubRectVertical(5, 0), "NEURAL AMP MODELER", mStyle)); + AddChildControl(new IVLabelControl(GetRECT().SubRectVertical(5, 1), "By Steven Atkinson", mStyle)); + AddChildControl(new IVLabelControl(GetRECT().SubRectVertical(5, 2), buildInfoStr.Get(), mStyle)); + AddChildControl(new IURLControl(GetRECT().SubRectVertical(5, 3), "Plug-in development: Steve Atkinson, Oli Larkin, ... ", "https://github.com/sdatkinson/NeuralAmpModelerPlugin/graphs/contributors", mText, COLOR_TRANSPARENT, PluginColors::HELP_TEXT_MO, PluginColors::HELP_TEXT_CLICKED)); - AddChildControl(new IURLControl(GetRECT().GetGridCell(4, 0, 5, 1), "www.neuralampmodeler.com", + AddChildControl(new IURLControl(GetRECT().SubRectVertical(5, 4), "www.neuralampmodeler.com", "https://www.neuralampmodeler.com", mText, COLOR_TRANSPARENT, PluginColors::HELP_TEXT_MO, PluginColors::HELP_TEXT_CLICKED)); }; From 7e13e9876eac59e6d1609df20ea46c89526f5150 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Tue, 12 Nov 2024 08:46:12 -0800 Subject: [PATCH 06/10] Input calibration controls --- NeuralAmpModeler/NeuralAmpModeler.cpp | 35 ++++++++++++++++----- NeuralAmpModeler/NeuralAmpModeler.h | 16 ++++++++++ NeuralAmpModeler/NeuralAmpModelerControls.h | 6 ++-- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp index 81e6ab87..88fb64fe 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.cpp +++ b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -82,7 +82,8 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) GetParam(kOutNorm)->InitBool("OutNorm", true); GetParam(kIRToggle)->InitBool("IRToggle", true); GetParam(kCalibrateInput)->InitBool("CalibrateInput", false); - GetParam(kInputCalibrationLevel)->InitGain("InputCalibrationLevel", 12.0, -30.0, 30.0, 0.1); + // TODO Double, label "dBu" + GetParam(kInputCalibrationLevel)->InitGain("InputCalibrationLevel", 12.5, -30.0, 30.0, 0.1); mNoiseGateTrigger.AddListener(&mNoiseGateGain); @@ -263,6 +264,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) }); pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetMouseEventsWhenDisabled(false); + pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetMouseEventsWhenDisabled(false); }; } @@ -388,6 +390,7 @@ void NeuralAmpModeler::OnIdle() modelInfo.sampleRate = mModel->GetEncapsulatedSampleRate(); modelInfo.knownSampleRate = true; static_cast(pGraphics->GetControlWithTag(kCtrlTagSettingsBox))->SetModelInfo(modelInfo); + pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetDisabled(!mModel->HasInputLevel()); mNewModelLoadedInDSP = false; } } @@ -472,6 +475,11 @@ void NeuralAmpModeler::OnParamChange(int paramIdx) { switch (paramIdx) { + // Changes to the input gain + case kCalibrateInput: + case kInputCalibrationLevel: + case kInputLevel: _SetInputGain(); break; + // Tone stack: case kToneBass: mToneStack->SetParam("bass", GetParam(paramIdx)->Value()); break; case kToneMid: mToneStack->SetParam("middle", GetParam(paramIdx)->Value()); break; case kToneTreble: mToneStack->SetParam("treble", GetParam(paramIdx)->Value()); break; @@ -555,6 +563,7 @@ void NeuralAmpModeler::_ApplyDSPStaging() mShouldRemoveModel = false; mModelCleared = true; _UpdateLatency(); + _SetInputGain(); } if (mShouldRemoveIR) { @@ -570,6 +579,7 @@ void NeuralAmpModeler::_ApplyDSPStaging() mStagedModel = nullptr; mNewModelLoadedInDSP = true; _UpdateLatency(); + _SetInputGain(); } if (mStagedIR != nullptr) { @@ -655,6 +665,18 @@ void NeuralAmpModeler::_ResetModelAndIR(const double sampleRate, const int maxBl } } +void NeuralAmpModeler::_SetInputGain() +{ + iplug::sample inputGainDB = GetParam(kInputLevel)->Value(); + // Input calibration + // TODO: Need to access the encapsulted model in the ResamplingNAM! + if ((mModel != nullptr) && (mModel->HasInputLevel()) && GetParam(kCalibrateInput)->Value()) + { + inputGainDB += GetParam(kInputCalibrationLevel)->Value() - mModel->GetInputLevel(); + } + mInputGain = DBToAmp(inputGainDB); +} + std::string NeuralAmpModeler::_StageModel(const WDL_String& modelPath) { WDL_String previousNAMPath = mNAMPath; @@ -791,13 +813,12 @@ void NeuralAmpModeler::_ProcessInput(iplug::sample** inputs, const size_t nFrame } // On the standalone, we can probably assume that the user has plugged into only one input and they expect it to be - // carried straight through. Don't apply any division over nCahnsIn because we're just "catching anything out there." + // carried straight through. Don't apply any division over nChansIn because we're just "catching anything out there." // However, in a DAW, it's probably something providing stereo, and we want to take the average in order to avoid - // doubling the loudness. -#ifdef APP_API - const double gain = pow(10.0, GetParam(kInputLevel)->Value() / 20.0); -#else - const double gain = pow(10.0, GetParam(kInputLevel)->Value() / 20.0) / (float)nChansIn; + // doubling the loudness. (This would change w/ double mono processing) + double gain = mInputGain; +#ifndef APP_API + gain /= (float)nChansIn; #endif // Assume _PrepareBuffers() was already called for (size_t c = 0; c < nChansIn; c++) diff --git a/NeuralAmpModeler/NeuralAmpModeler.h b/NeuralAmpModeler/NeuralAmpModeler.h index b396e00f..743fc447 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.h +++ b/NeuralAmpModeler/NeuralAmpModeler.h @@ -57,6 +57,7 @@ enum ECtrlTags kCtrlTagOutputMeter, kCtrlTagSettingsBox, kCtrlTagOutNorm, + kCtrlTagCalibrateInput, kNumCtrlTags }; @@ -105,7 +106,17 @@ class ResamplingNAM : public nam::DSP // Get the other information from the encapsulated NAM so that we can tell the outside world about what we're // holding. if (mEncapsulated->HasLoudness()) + { SetLoudness(mEncapsulated->GetLoudness()); + } + if (mEncapsulated->HasInputLevel()) + { + SetInputLevel(mEncapsulated->GetInputLevel()); + } + if (mEncapsulated->HasOutputLevel()) + { + SetOutputLevel(mEncapsulated->GetOutputLevel()); + } // NOTE: prewarm samples doesn't mean anything--we can prewarm the encapsulated model as it likes and be good to // go. @@ -231,6 +242,8 @@ class NeuralAmpModeler final : public iplug::Plugin // Resetting for models and IRs, called by OnReset void _ResetModelAndIR(const double sampleRate, const int maxBlockSize); + void _SetInputGain(); + // Unserialize current-version plug-in data: int _UnserializeStateCurrent(const iplug::IByteChunk& chunk, int startPos); // Unserialize v0.7.9 legacy data: @@ -256,6 +269,9 @@ class NeuralAmpModeler final : public iplug::Plugin iplug::sample** mInputPointers = nullptr; iplug::sample** mOutputPointers = nullptr; + // Input and (soon) output gain + iplug::sample mInputGain = 1.0; + // Noise gates dsp::noise_gate::Trigger mNoiseGateTrigger; dsp::noise_gate::Gain mNoiseGateGain; diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index 668f8073..6054c64a 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -455,12 +455,12 @@ class IContainerBaseWithNamedChildren : public IContainerBase ~IContainerBaseWithNamedChildren() = default; protected: - IControl* AddNamedChildControl(IControl* control, std::string name) + IControl* AddNamedChildControl(IControl* control, std::string name, int ctrlTag = kNoTag, const char* group = "") { // Make sure we haven't already used this name assert(mChildNameIndexMap.find(name) == mChildNameIndexMap.end()); mChildNameIndexMap[name] = NChildren(); - return AddChildControl(control); + return AddChildControl(control, ctrlTag, group); }; IControl* GetNamedChild(std::string name) @@ -631,7 +631,7 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren mControlNames.inputCalibrationLevel); AddNamedChildControl( new NAMSwitchControl(inputSwitchArea, kCalibrateInput, "Calibrate Input", mStyle, mSwitchBitmap), - mControlNames.calibrateInput); + mControlNames.calibrateInput, kCtrlTagCalibrateInput); // TODO Disable knob if calibration is false // TODO output--raw, normalized, calibrated From f2364e9e47d8e578475958195297940371ec292e Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Wed, 13 Nov 2024 23:01:34 -0800 Subject: [PATCH 07/10] Input calibration * Disable both the switch and knob when model doesn't have input calibration metadata * Display I/O calibration levels in model info * Add tooltip to input calibraiton knob. * Don't disable mouse events when input calibraiton controls are disabled. --- NeuralAmpModeler/NeuralAmpModeler.cpp | 26 +++++--- NeuralAmpModeler/NeuralAmpModeler.h | 1 + NeuralAmpModeler/NeuralAmpModelerControls.h | 69 +++++++++++++++------ 3 files changed, 67 insertions(+), 29 deletions(-) diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp index 88fb64fe..4bf13c2e 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.cpp +++ b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -83,7 +83,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) GetParam(kIRToggle)->InitBool("IRToggle", true); GetParam(kCalibrateInput)->InitBool("CalibrateInput", false); // TODO Double, label "dBu" - GetParam(kInputCalibrationLevel)->InitGain("InputCalibrationLevel", 12.5, -30.0, 30.0, 0.1); + GetParam(kInputCalibrationLevel)->InitDouble("InputCalibrationLevel", 12.5, -30.0, 30.0, 0.1, "dBu"); mNoiseGateTrigger.AddListener(&mNoiseGateGain); @@ -263,8 +263,8 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) pControl->SetMouseOverWhenDisabled(true); }); - pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetMouseEventsWhenDisabled(false); - pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetMouseEventsWhenDisabled(false); + // pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetMouseEventsWhenDisabled(false); + // pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetMouseEventsWhenDisabled(false); }; } @@ -387,10 +387,19 @@ void NeuralAmpModeler::OnIdle() { pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!mModel->HasLoudness()); ModelInfo modelInfo; - modelInfo.sampleRate = mModel->GetEncapsulatedSampleRate(); - modelInfo.knownSampleRate = true; + 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(pGraphics->GetControlWithTag(kCtrlTagSettingsBox))->SetModelInfo(modelInfo); - pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetDisabled(!mModel->HasInputLevel()); + + const bool disableInputCalibrationControls = !mModel->HasInputLevel(); + pGraphics->GetControlWithTag(kCtrlTagCalibrateInput)->SetDisabled(disableInputCalibrationControls); + pGraphics->GetControlWithTag(kCtrlTagInputCalibrationLevel)->SetDisabled(disableInputCalibrationControls); + mNewModelLoadedInDSP = false; } } @@ -499,7 +508,7 @@ 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; default: break; } } @@ -669,8 +678,7 @@ void NeuralAmpModeler::_SetInputGain() { iplug::sample inputGainDB = GetParam(kInputLevel)->Value(); // Input calibration - // TODO: Need to access the encapsulted model in the ResamplingNAM! - if ((mModel != nullptr) && (mModel->HasInputLevel()) && GetParam(kCalibrateInput)->Value()) + if ((mModel != nullptr) && (mModel->HasInputLevel()) && GetParam(kCalibrateInput)->Bool()) { inputGainDB += GetParam(kInputCalibrationLevel)->Value() - mModel->GetInputLevel(); } diff --git a/NeuralAmpModeler/NeuralAmpModeler.h b/NeuralAmpModeler/NeuralAmpModeler.h index 743fc447..3179f026 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.h +++ b/NeuralAmpModeler/NeuralAmpModeler.h @@ -58,6 +58,7 @@ enum ECtrlTags kCtrlTagSettingsBox, kCtrlTagOutNorm, kCtrlTagCalibrateInput, + kCtrlTagInputCalibrationLevel, kNumCtrlTags }; diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index 6054c64a..f41e61da 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -474,10 +474,18 @@ class IContainerBaseWithNamedChildren : public IContainerBase std::unordered_map mChildNameIndexMap; }; // class IContainerBaseWithNamedChildren + +struct PossiblyKnownParameter +{ + bool known = false; + double value = 0.0; +}; + struct ModelInfo { - bool knownSampleRate = false; - double sampleRate = 0.0; + PossiblyKnownParameter sampleRate; + PossiblyKnownParameter inputCalibrationLevel; + PossiblyKnownParameter outputCalibrationLevel; }; class ModelInfoControl : public IContainerBaseWithNamedChildren @@ -501,23 +509,37 @@ class ModelInfoControl : public IContainerBaseWithNamedChildren void OnAttached() override { - AddChildControl(new IVLabelControl(GetRECT().GetGridCell(0, 0, 2, 1), "Model information:", mStyle)); - AddNamedChildControl(new IVLabelControl(GetRECT().GetGridCell(1, 0, 2, 1), "", mStyle), mControlNames.sampleRate); + AddChildControl(new IVLabelControl(GetRECT().SubRectVertical(4, 0), "Model information:", mStyle)); + AddNamedChildControl(new IVLabelControl(GetRECT().SubRectVertical(4, 1), "", mStyle), mControlNames.sampleRate); + AddNamedChildControl( + new IVLabelControl(GetRECT().SubRectVertical(4, 2), "", mStyle), mControlNames.inputCalibrationLevel); + AddNamedChildControl( + new IVLabelControl(GetRECT().SubRectVertical(4, 3), "", mStyle), mControlNames.outputCalibrationLevel); }; void SetModelInfo(const ModelInfo& modelInfo) { - std::stringstream ss; - ss << "Sample rate: "; - if (modelInfo.knownSampleRate) - { - ss << (int)modelInfo.sampleRate; - } - else - { - ss << "(Unknown)"; - } - static_cast(GetNamedChild(mControlNames.sampleRate))->SetStr(ss.str().c_str()); + auto SetControlStr = [&](const std::string& name, const PossiblyKnownParameter& p, const std::string& units, + const std::string& childName) { + std::stringstream ss; + ss << name << ": "; + if (p.known) + { + ss << p.value << " " << units; + } + else + { + ss << "(Unknown)"; + } + static_cast(GetNamedChild(childName))->SetStr(ss.str().c_str()); + }; + + SetControlStr("Sample rate", modelInfo.sampleRate, "Hz", mControlNames.sampleRate); + SetControlStr( + "Input calibration level", modelInfo.inputCalibrationLevel, "dBu", mControlNames.inputCalibrationLevel); + SetControlStr( + "Output calibration level", modelInfo.outputCalibrationLevel, "dBu", mControlNames.outputCalibrationLevel); + mHasInfo = true; }; @@ -526,6 +548,8 @@ class ModelInfoControl : public IContainerBaseWithNamedChildren struct { const std::string sampleRate = "sampleRate"; + const std::string inputCalibrationLevel = "inputCalibrationLevel"; + const std::string outputCalibrationLevel = "outputCalibrationLevel"; } mControlNames; // Do I have info? bool mHasInfo = false; @@ -621,14 +645,18 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren const float width = titleArea.W(); const auto inputOutputArea = titleArea.GetFromBottom(height).GetTranslated(0.0f, height); const auto inputArea = inputOutputArea.GetFromLeft(0.5f * width); - const auto outputArea = inputOutputArea.GetFromRight(0.5f * width); + // const auto outputArea = inputOutputArea.GetFromRight(0.5f * width); const float knobWidth = 87.0f; // HACK based on looking at the main page knobs. const auto inputKnobArea = inputArea.GetFromTop(NAM_KNOB_HEIGHT).GetMidHPadded(0.5f * knobWidth); const auto inputSwitchArea = inputArea.GetFromBottom(NAM_SWTICH_HEIGHT).GetMidHPadded(0.5f * knobWidth); ; - AddNamedChildControl(new NAMKnobControl(inputKnobArea, kInputCalibrationLevel, "Level", mStyle, mKnobBitmap), - mControlNames.inputCalibrationLevel); + auto* inputLevelControl = + AddNamedChildControl(new NAMKnobControl(inputKnobArea, kInputCalibrationLevel, "Level", mStyle, mKnobBitmap), + mControlNames.inputCalibrationLevel, kCtrlTagInputCalibrationLevel); + inputLevelControl->SetTooltip( + "The analog level, in dBu RMS, that corresponds to digital level of 0 dBFS peak in the host as its signal " + "enters this plugin."); AddNamedChildControl( new NAMSwitchControl(inputSwitchArea, kCalibrateInput, "Calibrate Input", mStyle, mSwitchBitmap), mControlNames.calibrateInput, kCtrlTagCalibrateInput); @@ -639,8 +667,9 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren const float halfWidth = PLUG_WIDTH / 2.0f - pad; const auto bottomArea = GetRECT().GetPadded(-pad).GetFromBottom(78.0f); - const auto modelInfoArea = bottomArea.GetFromLeft(halfWidth).GetFromTop(30.0f); - const auto aboutArea = bottomArea.GetFromRight(halfWidth); + const float lineHeight = 15.0f; + const auto modelInfoArea = bottomArea.GetFromLeft(halfWidth).GetFromTop(4 * lineHeight); + const auto aboutArea = bottomArea.GetFromRight(halfWidth).GetFromTop(5 * lineHeight); AddNamedChildControl(new ModelInfoControl(modelInfoArea, leftStyle), mControlNames.modelInfo); AddNamedChildControl(new AboutControl(aboutArea, leftStyle, leftText), mControlNames.about); From e9e0a5c15a0516fabbaa6726d4dd85d74f51dd33 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Wed, 13 Nov 2024 23:09:32 -0800 Subject: [PATCH 08/10] Set disable state correctly on UI open for input calibration controls --- NeuralAmpModeler/NeuralAmpModeler.cpp | 9 ++++++++- NeuralAmpModeler/NeuralAmpModelerControls.h | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp index 4bf13c2e..1418ec64 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.cpp +++ b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -477,7 +477,14 @@ void NeuralAmpModeler::OnUIOpen() } if (mModel != nullptr) - GetUI()->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!mModel->HasLoudness()); + { + 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); + } } void NeuralAmpModeler::OnParamChange(int paramIdx) diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index f41e61da..cb1bc795 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -511,10 +511,10 @@ class ModelInfoControl : public IContainerBaseWithNamedChildren { AddChildControl(new IVLabelControl(GetRECT().SubRectVertical(4, 0), "Model information:", mStyle)); AddNamedChildControl(new IVLabelControl(GetRECT().SubRectVertical(4, 1), "", mStyle), mControlNames.sampleRate); - AddNamedChildControl( - new IVLabelControl(GetRECT().SubRectVertical(4, 2), "", mStyle), mControlNames.inputCalibrationLevel); - AddNamedChildControl( - new IVLabelControl(GetRECT().SubRectVertical(4, 3), "", mStyle), mControlNames.outputCalibrationLevel); + // AddNamedChildControl( + // new IVLabelControl(GetRECT().SubRectVertical(4, 2), "", mStyle), mControlNames.inputCalibrationLevel); + // AddNamedChildControl( + // new IVLabelControl(GetRECT().SubRectVertical(4, 3), "", mStyle), mControlNames.outputCalibrationLevel); }; void SetModelInfo(const ModelInfo& modelInfo) @@ -535,10 +535,10 @@ class ModelInfoControl : public IContainerBaseWithNamedChildren }; SetControlStr("Sample rate", modelInfo.sampleRate, "Hz", mControlNames.sampleRate); - SetControlStr( - "Input calibration level", modelInfo.inputCalibrationLevel, "dBu", mControlNames.inputCalibrationLevel); - SetControlStr( - "Output calibration level", modelInfo.outputCalibrationLevel, "dBu", mControlNames.outputCalibrationLevel); + // SetControlStr( + // "Input calibration level", modelInfo.inputCalibrationLevel, "dBu", mControlNames.inputCalibrationLevel); + // SetControlStr( + // "Output calibration level", modelInfo.outputCalibrationLevel, "dBu", mControlNames.outputCalibrationLevel); mHasInfo = true; }; @@ -548,8 +548,8 @@ class ModelInfoControl : public IContainerBaseWithNamedChildren struct { const std::string sampleRate = "sampleRate"; - const std::string inputCalibrationLevel = "inputCalibrationLevel"; - const std::string outputCalibrationLevel = "outputCalibrationLevel"; + // const std::string inputCalibrationLevel = "inputCalibrationLevel"; + // const std::string outputCalibrationLevel = "outputCalibrationLevel"; } mControlNames; // Do I have info? bool mHasInfo = false; From f357a15e029e59df53a1e3c1d9ae827a71d42dfc Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Thu, 14 Nov 2024 22:05:16 -0800 Subject: [PATCH 09/10] Input level as text control, still needs cleaning up --- NeuralAmpModeler/NeuralAmpModelerControls.h | 40 +++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index cb1bc795..b0977891 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -648,11 +648,11 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren // const auto outputArea = inputOutputArea.GetFromRight(0.5f * width); const float knobWidth = 87.0f; // HACK based on looking at the main page knobs. - const auto inputKnobArea = inputArea.GetFromTop(NAM_KNOB_HEIGHT).GetMidHPadded(0.5f * knobWidth); + const auto inputLevelArea = inputArea.GetFromTop(NAM_KNOB_HEIGHT).GetMidHPadded(0.5f * knobWidth); const auto inputSwitchArea = inputArea.GetFromBottom(NAM_SWTICH_HEIGHT).GetMidHPadded(0.5f * knobWidth); ; auto* inputLevelControl = - AddNamedChildControl(new NAMKnobControl(inputKnobArea, kInputCalibrationLevel, "Level", mStyle, mKnobBitmap), + AddNamedChildControl(new InputLevelControl(inputLevelArea, kInputCalibrationLevel, "Set level", text), mControlNames.inputCalibrationLevel, kCtrlTagInputCalibrationLevel); inputLevelControl->SetTooltip( "The analog level, in dBu RMS, that corresponds to digital level of 0 dBFS peak in the host as its signal " @@ -711,6 +711,42 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren const std::string title = "Title"; } mControlNames; + class InputLevelControl : public IEditableTextControl + { + public: + InputLevelControl(const IRECT& bounds, int paramIdx, const char* str, const IText& text = DEFAULT_TEXT, + const IColor& BGColor = DEFAULT_BGCOLOR) + : IEditableTextControl(bounds, str, text, BGColor) + { + SetParamIdx(paramIdx); + }; + + void SetValueFromUserInput(double normalizedValue, int valIdx) override + { + IControl::SetValueFromUserInput(normalizedValue, valIdx); + const std::string s = ConvertToString(normalizedValue); + OnTextEntryCompletion(s.c_str(), valIdx); + }; + + void SetValueFromDelegate(double normalizedValue, int valIdx) override + { + IControl::SetValueFromDelegate(normalizedValue, valIdx); + const std::string s = ConvertToString(normalizedValue); + OnTextEntryCompletion(s.c_str(), valIdx); + }; + + private: + std::string ConvertToString(const double normalizedValue) + { + const double naturalValue = GetParam()->FromNormalized(normalizedValue); + // And make the value to display + std::stringstream ss; + ss << naturalValue << " dBu"; + std::string s = ss.str(); + return s; + }; + }; + class AboutControl : public IContainerBase { public: From d80342c05520d0a5d9eed708e96b67832b6b1546 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Thu, 14 Nov 2024 23:05:46 -0800 Subject: [PATCH 10/10] Improve input level graphics, still iffy layout --- NeuralAmpModeler/NeuralAmpModeler.cpp | 7 ++-- NeuralAmpModeler/NeuralAmpModelerControls.h | 31 +++++++++++------- NeuralAmpModeler/config.h | 3 ++ .../resources/img/InputLevelBackground.png | Bin 0 -> 710 bytes .../resources/img/InputLevelBackground@2x.png | Bin 0 -> 1629 bytes .../resources/img/InputLevelBackground@3x.png | Bin 0 -> 2851 bytes NeuralAmpModeler/resources/main.rc | 6 ++++ 7 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 NeuralAmpModeler/resources/img/InputLevelBackground.png create mode 100644 NeuralAmpModeler/resources/img/InputLevelBackground@2x.png create mode 100644 NeuralAmpModeler/resources/img/InputLevelBackground@3x.png diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp index 1418ec64..b2922ad9 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.cpp +++ b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -119,6 +119,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) const auto backgroundBitmap = pGraphics->LoadBitmap(BACKGROUND_FN); const auto fileBackgroundBitmap = pGraphics->LoadBitmap(FILEBACKGROUND_FN); + const auto inputLevelBackgroundBitmap = pGraphics->LoadBitmap(INPUTLEVELBACKGROUND_FN); const auto linesBitmap = pGraphics->LoadBitmap(LINES_FN); const auto knobBackgroundBitmap = pGraphics->LoadBitmap(KNOBBACKGROUND_FN); const auto switchHandleBitmap = pGraphics->LoadBitmap(SLIDESWITCHHANDLE_FN); @@ -253,9 +254,9 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) gearSVG)); pGraphics - ->AttachControl( - new NAMSettingsPageControl(b, backgroundBitmap, knobBackgroundBitmap, switchHandleBitmap, crossSVG, style), - kCtrlTagSettingsBox) + ->AttachControl(new NAMSettingsPageControl( + b, backgroundBitmap, inputLevelBackgroundBitmap, switchHandleBitmap, crossSVG, style), + kCtrlTagSettingsBox) ->Hide(true); pGraphics->ForAllControlsFunc([](IControl* pControl) { diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h index b0977891..77724268 100644 --- a/NeuralAmpModeler/NeuralAmpModelerControls.h +++ b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -558,12 +558,12 @@ class ModelInfoControl : public IContainerBaseWithNamedChildren class NAMSettingsPageControl : public IContainerBaseWithNamedChildren { public: - NAMSettingsPageControl(const IRECT& bounds, const IBitmap& bitmap, const IBitmap& knobBitmap, + NAMSettingsPageControl(const IRECT& bounds, const IBitmap& bitmap, const IBitmap& inputLevelBackgroundBitmap, const IBitmap& switchBitmap, ISVG closeSVG, const IVStyle& style) : IContainerBaseWithNamedChildren(bounds) , mAnimationTime(0) , mBitmap(bitmap) - , mKnobBitmap(knobBitmap) + , mInputLevelBackgroundBitmap(inputLevelBackgroundBitmap) , mSwitchBitmap(switchBitmap) , mStyle(style) , mCloseSVG(closeSVG) @@ -648,19 +648,19 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren // const auto outputArea = inputOutputArea.GetFromRight(0.5f * width); const float knobWidth = 87.0f; // HACK based on looking at the main page knobs. - const auto inputLevelArea = inputArea.GetFromTop(NAM_KNOB_HEIGHT).GetMidHPadded(0.5f * knobWidth); + const auto inputLevelArea = + inputArea.GetFromTop(NAM_KNOB_HEIGHT).GetFromBottom(25.0f).GetMidHPadded(0.5f * knobWidth); const auto inputSwitchArea = inputArea.GetFromBottom(NAM_SWTICH_HEIGHT).GetMidHPadded(0.5f * knobWidth); - ; - auto* inputLevelControl = - AddNamedChildControl(new InputLevelControl(inputLevelArea, kInputCalibrationLevel, "Set level", text), - mControlNames.inputCalibrationLevel, kCtrlTagInputCalibrationLevel); + + auto* inputLevelControl = AddNamedChildControl( + new InputLevelControl(inputLevelArea, kInputCalibrationLevel, mInputLevelBackgroundBitmap, text), + mControlNames.inputCalibrationLevel, kCtrlTagInputCalibrationLevel); inputLevelControl->SetTooltip( "The analog level, in dBu RMS, that corresponds to digital level of 0 dBFS peak in the host as its signal " "enters this plugin."); AddNamedChildControl( new NAMSwitchControl(inputSwitchArea, kCalibrateInput, "Calibrate Input", mStyle, mSwitchBitmap), mControlNames.calibrateInput, kCtrlTagCalibrateInput); - // TODO Disable knob if calibration is false // TODO output--raw, normalized, calibrated } @@ -691,7 +691,7 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren private: IBitmap mBitmap; - IBitmap mKnobBitmap; + IBitmap mInputLevelBackgroundBitmap; IBitmap mSwitchBitmap; IVStyle mStyle; ISVG mCloseSVG; @@ -714,13 +714,20 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren class InputLevelControl : public IEditableTextControl { public: - InputLevelControl(const IRECT& bounds, int paramIdx, const char* str, const IText& text = DEFAULT_TEXT, + InputLevelControl(const IRECT& bounds, int paramIdx, const IBitmap& bitmap, const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR) - : IEditableTextControl(bounds, str, text, BGColor) + : IEditableTextControl(bounds, "", text, BGColor) + , mBitmap(bitmap) { SetParamIdx(paramIdx); }; + void Draw(IGraphics& g) override + { + g.DrawFittedBitmap(mBitmap, mRECT); + ITextControl::Draw(g); + }; + void SetValueFromUserInput(double normalizedValue, int valIdx) override { IControl::SetValueFromUserInput(normalizedValue, valIdx); @@ -745,6 +752,8 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren std::string s = ss.str(); return s; }; + + IBitmap mBitmap; }; class AboutControl : public IContainerBase diff --git a/NeuralAmpModeler/config.h b/NeuralAmpModeler/config.h index 790a142f..55ce7cc3 100644 --- a/NeuralAmpModeler/config.h +++ b/NeuralAmpModeler/config.h @@ -77,6 +77,9 @@ #define FILEBACKGROUND_FN "FileBackground.png" #define FILEBACKGROUND2X_FN "FileBackground@2x.png" #define FILEBACKGROUND3X_FN "FileBackground@3x.png" +#define INPUTLEVELBACKGROUND_FN "InputLevelBackground.png" +#define INPUTLEVELBACKGROUND2X_FN "InputLevelBackground@2x.png" +#define INPUTLEVELBACKGROUND3X_FN "InputLevelBackground@3x.png" #define LINES_FN "Lines.png" #define LINES2X_FN "Lines@2x.png" #define LINES3X_FN "Lines@3x.png" diff --git a/NeuralAmpModeler/resources/img/InputLevelBackground.png b/NeuralAmpModeler/resources/img/InputLevelBackground.png new file mode 100644 index 0000000000000000000000000000000000000000..c4e10e37e13db7ee8149be89633128b713d04b9c GIT binary patch literal 710 zcmV;%0y+JOP)$3bv-z0OlQarINL2tcpv-EP{$3CTM5fEqXPasd?6TUIbYUuiYoJP>*T5BB zs62QgQ)Q_!vmtnd|wMgZmQlLa$2Fk;yH6hZv#A2zgcl5Q^*{ zdG|ugJdu806Eo8SR&d(6*rFzc$T_ye?6e-J{K{`L;J`%2s3B&j&6j-ntrQ~C-;Sd| z<;%Wys8NZGl;_5d1LY+m{T;GX{Ow2)=}&xn?Ml^K3|4iIsHE$2W9a ziit>nzlf7kQ_}4(1~FxRUy`1Q66xoen3uf=%1B`{v$iOT?`HO9zyXSkLI~lpZQJJ% zLIH%r%rLXoq7t}WtyZ6h9;nC|q^#VUS!pRuMfx%~v!$8cnc00^*AG=yJ#qSIhe|d1 zs;cU#uImRgyHA-}n%O*?Q<5|I$r7}*32RszU&NKl4kuqYHomIzGF{DS%N&O7hi`m^pF} z5&+Bz#{+@@48;1}-_%$iH@~Gi0T_Qt2=EI|zx{UF^Ss?LRPP@bnsLU|gf6RJvCk2~ zYkSTs?_Fd!k0O);3cBrLaxOT9&zbfkk~yfx2S?txCZ`20SgdRQ#`Q9~j(W0fiE&Bm zaiopr`Ru>F(=(7`<%QIQv39RcK33=00)$=?Rkgh2zgKM@VhQ9jMg?hU{T$pKz%wBCPsgJ9gF+aauWrtVJ=JB=5q6y%-Zi7%A<2Obns@HKFq08DE`W z-Q@@~QEF10CZ+XVo6UTn5hMluewh4Zlx12^@t3&-&rh%N zM3;~sBv)$>xxh?g(laiKSri%_+4F!TeAk;VlH-f6On8vAso1+&$2*ZA&i}2z%Ww!C zkX=|y&_?bv*7&d5G5>S23_kki8t zvtsD2sn~fFg1UGWU@6R(kaK(^LK&{y96!uYb)V0UI{%~Y4nOeX|)+2C(a(%6f?RM>u7rp{A-2*#LV_(eqV{Hdv=f zg|xf=WY1zdfKKD{DEtAUOs#4WwOax^qCuBSz*c0kNAVa3IY8bFPMqYa?zX(P{%1pA zs*~7tMOS#SX=_VSpUmK*X==5`rTbIuQM*`HhG=1yU;rM8r%|lo*HsxO*al!xS?bq= zB-2ImPb`3sf}7usA{FYSVt@sbcWx5`Q;C3d=LT~5$QFS7RPQ7g*i`{~;y=;?PC5PMS;2N+o4Dk{fhtir90Ib*wqVuQ#ImzN0@QyPp+B%$nE@Ef39^%zu@KV zzK(v?2npGiLjl;=v3!so8!Svt;T?TujMk4Gm!g;*2`2~Itg?E%ck$3LBX0d8zDs!P z_oE-CIrw(deIU2LH1IxQBGD!+_+Nj&sz+F9W`|;jldX@PYY1$$?d>H8fLt~x8Thpp zDNM27IO3q!I`5jZ#}`o(E&+Co-E);Or;1m08-VTwX`|LYZGjpZ9P^oi7LIR^Es?3_ zhIfERIiYpTipjFS>FjzYYh{mdzb~NxGkegYyy@Kbr1pj(P-s(4IZrWs&seXsg9F0bMT=a!rSvS}E`uc3%rTg}|<(R6d!e?OiKTqKD8l8u* z^^%fu?Qa#^m(tQ!XBpe(ASYb@xG>=^l}f*5Etr?;%*(teeHUNZH11^#j!#Y`ecW1J zUXC!W+zn9t)zudf42Fz97`y0gONoBpf>IWCiYsG$?o?Fd@%enqv9U3cyPMl#O7-yf z_E%c~(%Dv>nZ9?jTbrBL(zCKQH#8be*ZTV9nzDgqr^3-&5#lj*X|G)ADcL_aKRzNm zE8X^mnd56V6*u3zkiNG5N=Q?8Kq)%=0%6 z#ImM;7DU(4r!Y*JvLPlsPBk1a=`OYO_$5Q%Lx}(PS)7>u^91tT`qvV`rJ%89KMrzf z)V)mWCkW`{EzkM!$}Gi7qe3Ny_QtL8Rg59|uFeXmi-F{0j|~Uz-{h1{Qv_aZFD#k} zbexVD%?OSJ_K8fJ&`G5b|1kRW6~rTCUT{Uzf7(n)TEWa;y7gwA5E$j!ov1BAZJS&p Xi)vPPj{m5C8$kGu5>S7X`O|*^8*B8i literal 0 HcmV?d00001 diff --git a/NeuralAmpModeler/resources/img/InputLevelBackground@3x.png b/NeuralAmpModeler/resources/img/InputLevelBackground@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..5eba996217e5e2334028148d430e96d881ac73a9 GIT binary patch literal 2851 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 kg)C1z+F;XjjrvWFP