NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
Log | Files | Refs | Submodules | README | LICENSE

commit 8ad4f2f8232e1ccd785fca2263e1bf0805620bc2
parent 5791e782cffb882c605aedfad76971738dfa0d86
Author: Oli Larkin <[email protected]>
Date:   Sun, 25 Jun 2023 17:39:55 +0200

Introduce NAMMeterControl

Diffstat:
MNeuralAmpModeler/NeuralAmpModeler.cpp | 37+++++++------------------------------
MNeuralAmpModeler/NeuralAmpModeler.h | 13++++++++++---
MNeuralAmpModeler/NeuralAmpModelerControls.h | 44++++++++++++++++++++++++++++++++++++++++++++
MNeuralAmpModeler/config.h | 4++++
ANeuralAmpModeler/resources/img/MeterBackground.png | 0
ANeuralAmpModeler/resources/img/[email protected] | 0
ANeuralAmpModeler/resources/img/[email protected] | 0
MNeuralAmpModeler/resources/main.rc | 8+++++++-
8 files changed, 72 insertions(+), 34 deletions(-)

diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -5,7 +5,6 @@ #include <utility> #include "Colors.h" -#include "IControls.h" #include "NeuralAmpModelerCore/NAM/activations.h" // clang-format off // These includes need to happen in this order or else the latter won't know @@ -106,6 +105,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) auto linesBitmap = pGraphics->LoadBitmap(LINES_FN); auto knobBackgroundBitmap = pGraphics->LoadBitmap(KNOBBACKGROUND_FN); auto switchHandleBitmap = pGraphics->LoadBitmap(SLIDESWITCHHANDLE_FN); + auto meterBackgroundBitmap = pGraphics->LoadBitmap(METERBACKGROUND_FN); const IRECT b = pGraphics->GetBounds(); const IRECT mainArea = b.GetPadded(-20); @@ -147,15 +147,9 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) const IRECT irArea = modelArea.GetTranslated(0.0f, irYOffset); // Areas for meters - const float meterHalfHeight = 0.5f * 385.0f; - const IRECT inputMeterArea = inputKnobArea.GetFromLeft(allKnobsHalfPad) - .GetMidHPadded(allKnobsHalfPad) - .GetMidVPadded(meterHalfHeight) - .GetTranslated(-allKnobsPad - 18.f, 0.0f); - const IRECT outputMeterArea = outputKnobArea.GetFromRight(allKnobsHalfPad) - .GetMidHPadded(allKnobsHalfPad) - .GetMidVPadded(meterHalfHeight) - .GetTranslated(allKnobsPad + 18.f, 0.0f); + const IRECT inputMeterArea = content.GetFromLeft(30).GetHShifted(-20).GetMidVPadded(100).GetVShifted(-25); + const IRECT outputMeterArea = content.GetFromRight(30).GetHShifted(20).GetMidVPadded(100).GetVShifted(-25); + // Model loader button auto loadModelCompletionHandler = [&](const WDL_String& fileName, const WDL_String& path) { @@ -231,26 +225,9 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) pGraphics->AttachControl(new NAMKnobControl(outputKnobArea, kOutputLevel, "", style, knobBackgroundBitmap)); // The meters - const float meterMin = -90.0f; - const float meterMax = -0.01f; - pGraphics - ->AttachControl( - new IVPeakAvgMeterControl(inputMeterArea, "", - style.WithWidgetFrac(0.5).WithShowValue(false).WithDrawFrame(false).WithColor( - kFG, PluginColors::NAM_THEMECOLOR.WithOpacity(0.4f)), - EDirection::Vertical, {}, 0, meterMin, meterMax, {}), - kCtrlTagInputMeter) - ->As<IVPeakAvgMeterControl<>>() - ->SetPeakSize(2.0f); - pGraphics - ->AttachControl( - new IVPeakAvgMeterControl(outputMeterArea, "", - style.WithWidgetFrac(0.5).WithShowValue(false).WithDrawFrame(false).WithColor( - kFG, PluginColors::NAM_THEMECOLOR.WithOpacity(0.4f)), - EDirection::Vertical, {}, 0, meterMin, meterMax, {}), - kCtrlTagOutputMeter) - ->As<IVPeakAvgMeterControl<>>() - ->SetPeakSize(2.0f); + pGraphics->AttachControl(new NAMMeterControl(inputMeterArea, meterBackgroundBitmap, style), kCtrlTagInputMeter); + pGraphics->AttachControl(new NAMMeterControl(outputMeterArea, meterBackgroundBitmap, style), kCtrlTagOutputMeter); + // Help/about box pGraphics->AttachControl(new NAMCircleButtonControl( diff --git a/NeuralAmpModeler/NeuralAmpModeler.h b/NeuralAmpModeler/NeuralAmpModeler.h @@ -14,6 +14,14 @@ const int kNumPresets = 1; // The plugin is mono inside constexpr size_t kNumChannelsInternal = 1; +class NAMSender : public iplug::IPeakAvgSender<> +{ +public: + NAMSender() + : iplug::IPeakAvgSender<>(-90.0, true, 5.0f, 1.0f, 300.0f, 500.0f) + { + } +}; enum EParams { @@ -157,10 +165,9 @@ private: // Path to IR (.wav file) WDL_String mIRPath; - WDL_String mHighLightColor; + WDL_String mHighLightColor {PluginColors::NAM_THEMECOLOR.ToColorCode()}; std::unordered_map<std::string, double> mNAMParams = {{"Input", 0.0}, {"Output", 0.0}}; - iplug::IPeakAvgSender<> mInputSender; - iplug::IPeakAvgSender<> mOutputSender; + NAMSender mInputSender, mOutputSender; }; diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -393,6 +393,50 @@ private: int mClearMsgTag; }; +class NAMMeterControl : public IVPeakAvgMeterControl<>, public IBitmapBase +{ + static constexpr float KMeterMin = -70.0f; + static constexpr float KMeterMax = -0.01f; + +public: + NAMMeterControl(const IRECT& bounds, const IBitmap& bitmap, const IVStyle& style) + : IVPeakAvgMeterControl<>(bounds, "", + style.WithShowValue(false).WithDrawFrame(false).WithWidgetFrac(0.8), + EDirection::Vertical, {}, 0, KMeterMin, KMeterMax, {}) + , IBitmapBase(bitmap) + { + SetPeakSize(1.0f); + } + + void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); } + + virtual void OnResize() override + { + SetTargetRECT(MakeRects(mRECT)); + mWidgetBounds = mWidgetBounds.GetMidHPadded(5).GetVPadded(10); + MakeTrackRects(mWidgetBounds); + MakeStepRects(mWidgetBounds, mNSteps); + SetDirty(false); + } + + void DrawBackground(IGraphics& g, const IRECT& r) override + { + g.DrawFittedBitmap(mBitmap, r); + } + + void DrawTrackHandle(IGraphics& g, const IRECT& r, int chIdx, bool aboveBaseValue) override + { + if (r.H() > 2) + g.FillRect(GetColor(kX1), r, &mBlend); + } + + void DrawPeak(IGraphics& g, const IRECT& r, int chIdx, bool aboveBaseValue) override + { + g.DrawGrid(COLOR_BLACK, mTrackBounds.Get()[chIdx], 10, 2); + g.FillRect(GetColor(kX3), r, &mBlend); + } +}; + class NAMAboutBoxControl : public IContainerBase { public: diff --git a/NeuralAmpModeler/config.h b/NeuralAmpModeler/config.h @@ -84,6 +84,10 @@ #define SLIDESWITCHHANDLE2X_FN "[email protected]" #define SLIDESWITCHHANDLE3X_FN "[email protected]" +#define METERBACKGROUND_FN "MeterBackground.png" +#define METERBACKGROUND2X_FN "[email protected]" +#define METERBACKGROUND3X_FN "[email protected]" + // Issue 291 // On the macOS standalone, we might not have permissions to traverse the file directory, so we have the app ask the // user to pick a directory instead of the file in the directory. diff --git a/NeuralAmpModeler/resources/img/MeterBackground.png b/NeuralAmpModeler/resources/img/MeterBackground.png Binary files differ. diff --git a/NeuralAmpModeler/resources/img/[email protected] b/NeuralAmpModeler/resources/img/[email protected] Binary files differ. diff --git a/NeuralAmpModeler/resources/img/[email protected] b/NeuralAmpModeler/resources/img/[email protected] Binary files differ. diff --git a/NeuralAmpModeler/resources/main.rc b/NeuralAmpModeler/resources/main.rc @@ -173,7 +173,10 @@ BEGIN "LINES3X_FN PNG LINES3X_FN\r\n" "SLIDESWITCHHANDLE_FN PNG SLIDESWITCHHANDLE_FN\r\n" "SLIDESWITCHHANDLE2X_FN PNG SLIDESWITCHHANDLE2X_FN\r\n" - "SLIDESWITCHHANDLE3X_FN PNG SLIDESWITCHHANDLE3X_FN\0" + "SLIDESWITCHHANDLE3X_FN PNG SLIDESWITCHHANDLE3X_FN\r\n" + "METERBACKGROUND_FN PNG METERBACKGROUND_FN\r\n" + "METERBACKGROUND2X_FN PNG METERBACKGROUND2X_FN\r\n" + "METERBACKGROUND3X_FN PNG METERBACKGROUND3X_FN\0" END #endif // APSTUDIO_INVOKED @@ -278,6 +281,9 @@ LINES3X_FN PNG LINES3X_FN SLIDESWITCHHANDLE_FN PNG SLIDESWITCHHANDLE_FN SLIDESWITCHHANDLE2X_FN PNG SLIDESWITCHHANDLE2X_FN SLIDESWITCHHANDLE3X_FN PNG SLIDESWITCHHANDLE3X_FN +METERBACKGROUND_FN PNG METERBACKGROUND_FN +METERBACKGROUND2X_FN PNG METERBACKGROUND2X_FN +METERBACKGROUND3X_FN PNG METERBACKGROUND3X_FN ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED