commit f2d1a75b080cf81d3a73cc3568e742139b835a52
parent 4e2d9f5a1e5b4972a77cb386d7ef166b5940920c
Author: Steven Atkinson <[email protected]>
Date: Sun, 9 Apr 2023 12:02:14 -0700
Update code style (#180)
* Formatting style
* Apply formatting
Diffstat:
13 files changed, 595 insertions(+), 572 deletions(-)
diff --git a/.clang-format b/.clang-format
@@ -0,0 +1,79 @@
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Right
+AlignOperands: true
+AlignTrailingComments: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: true
+AllowShortCaseLabelsOnASingleLine: true
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterCaseLabel: true
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeComma
+BreakStringLiterals: true
+ColumnLimit: 120
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 0
+ContinuationIndentWidth: 2
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+FixNamespaceComments: true
+IndentCaseLabels: true
+IndentPPDirectives: BeforeHash
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: true
+MaxEmptyLinesToKeep: 2
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 2
+ObjCBreakBeforeNestedBlockParam: true
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 0
+PenaltyReturnTypeOnItsOwnLine: 1000
+PointerAlignment: Left
+ReflowComments: true
+SortIncludes: false
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp11
+UseTab: Never
diff --git a/NeuralAmpModeler/Colors.h b/NeuralAmpModeler/Colors.h
@@ -11,10 +11,10 @@
#include "IGraphicsStructs.h"
-namespace PluginColors {
+namespace PluginColors
+{
// COLORS!
-const iplug::igraphics::IColor
- OFF_WHITE(255, 243, 246, 249); // Material UI because Heidi said so
+const iplug::igraphics::IColor OFF_WHITE(255, 243, 246, 249); // Material UI because Heidi said so
// From group photo
// const iplug::igraphics::IColor NAM_5(255, 206, 194, 224); // Languid
@@ -52,8 +52,8 @@ const iplug::igraphics::IColor
// Lavender Blue
// Blue mode
-const iplug::igraphics::IColor NAM_1(255, 29, 26, 31); // Raisin Black
-const iplug::igraphics::IColor NAM_2(255, 80, 133, 232); // Azure
+const iplug::igraphics::IColor NAM_1(255, 29, 26, 31); // Raisin Black
+const iplug::igraphics::IColor NAM_2(255, 80, 133, 232); // Azure
const iplug::igraphics::IColor NAM_3(255, 162, 178, 191); // Cadet Blue Crayola
// Alts
// const iplug::igraphics::IColor NAM_1(255, 18, 17, 19); // Smoky Black
diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp
@@ -18,13 +18,16 @@
using namespace iplug;
using namespace igraphics;
-class IRolloverSVGButtonControl : public ISVGButtonControl {
+class IRolloverSVGButtonControl : public ISVGButtonControl
+{
public:
- IRolloverSVGButtonControl(const IRECT &bounds, IActionFunction af,
- const ISVG &svg)
- : ISVGButtonControl(bounds, af, svg, svg) {}
+ IRolloverSVGButtonControl(const IRECT& bounds, IActionFunction af, const ISVG& svg)
+ : ISVGButtonControl(bounds, af, svg, svg)
+ {
+ }
- void Draw(IGraphics &g) override {
+ void Draw(IGraphics& g) override
+ {
if (mMouseIsOver)
g.FillRect(PluginColors::MOUSEOVER, mRECT);
@@ -32,13 +35,16 @@ public:
}
};
-class IRolloverCircleSVGButtonControl : public ISVGButtonControl {
+class IRolloverCircleSVGButtonControl : public ISVGButtonControl
+{
public:
- IRolloverCircleSVGButtonControl(const IRECT &bounds, IActionFunction af,
- const ISVG &svg)
- : ISVGButtonControl(bounds, af, svg, svg) {}
+ IRolloverCircleSVGButtonControl(const IRECT& bounds, IActionFunction af, const ISVG& svg)
+ : ISVGButtonControl(bounds, af, svg, svg)
+ {
+ }
- void Draw(IGraphics &g) override {
+ void Draw(IGraphics& g) override
+ {
if (mMouseIsOver)
g.FillEllipse(PluginColors::MOUSEOVER, mRECT);
@@ -46,47 +52,45 @@ public:
}
};
-class IVUpdateableLabelControl : public IVLabelControl {
+class IVUpdateableLabelControl : public IVLabelControl
+{
public:
- IVUpdateableLabelControl(const IRECT &bounds, const char *str,
- const IVStyle &style)
- : IVLabelControl(bounds, str, style) {}
-
- void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) {
- SetStr(reinterpret_cast<const char *>(pData));
+ IVUpdateableLabelControl(const IRECT& bounds, const char* str, const IVStyle& style)
+ : IVLabelControl(bounds, str, style)
+ {
}
+
+ void OnMsgFromDelegate(int msgTag, int dataSize, const void* pData) { SetStr(reinterpret_cast<const char*>(pData)); }
};
// Styles
const IVColorSpec activeColorSpec{
- DEFAULT_BGCOLOR, // Background
- PluginColors::NAM_1, // Foreground
- PluginColors::NAM_2.WithOpacity(0.4f), // Pressed
- PluginColors::NAM_3, // Frame
- PluginColors::MOUSEOVER, // Highlight
- DEFAULT_SHCOLOR, // Shadow
- PluginColors::NAM_2, // Extra 1
- COLOR_RED, // Extra 2
- DEFAULT_X3COLOR // Extra 3
+ DEFAULT_BGCOLOR, // Background
+ PluginColors::NAM_1, // Foreground
+ PluginColors::NAM_2.WithOpacity(0.4f), // Pressed
+ PluginColors::NAM_3, // Frame
+ PluginColors::MOUSEOVER, // Highlight
+ DEFAULT_SHCOLOR, // Shadow
+ PluginColors::NAM_2, // Extra 1
+ COLOR_RED, // Extra 2
+ DEFAULT_X3COLOR // Extra 3
};
const IVColorSpec inactiveColorSpec{
- DEFAULT_BGCOLOR, // Background
- PluginColors::NAM_1, //.WithOpacity(0.5f), // Foreground
- PluginColors::NAM_1, // Pressed
- PluginColors::NAM_3.WithOpacity(0.5f), // Frame
- PluginColors::NAM_1, // Highlight
- DEFAULT_SHCOLOR.WithOpacity(0.5f), // Shadow
- PluginColors::NAM_2.WithOpacity(0.5f), // Extra 1
- COLOR_RED.WithOpacity(0.5f), // Extra 2
- DEFAULT_X3COLOR.WithOpacity(0.5f) // Extra 3
+ DEFAULT_BGCOLOR, // Background
+ PluginColors::NAM_1, //.WithOpacity(0.5f), // Foreground
+ PluginColors::NAM_1, // Pressed
+ PluginColors::NAM_3.WithOpacity(0.5f), // Frame
+ PluginColors::NAM_1, // Highlight
+ DEFAULT_SHCOLOR.WithOpacity(0.5f), // Shadow
+ PluginColors::NAM_2.WithOpacity(0.5f), // Extra 1
+ COLOR_RED.WithOpacity(0.5f), // Extra 2
+ DEFAULT_X3COLOR.WithOpacity(0.5f) // Extra 3
};
const IVStyle style = IVStyle{true, // Show label
true, // Show value
activeColorSpec,
- {DEFAULT_TEXT_SIZE + 5.f, EVAlign::Middle,
- PluginColors::NAM_3}, // Knob label text
- {DEFAULT_TEXT_SIZE + 5.f, EVAlign::Bottom,
- PluginColors::NAM_3}, // Knob value text
+ {DEFAULT_TEXT_SIZE + 5.f, EVAlign::Middle, PluginColors::NAM_3}, // Knob label text
+ {DEFAULT_TEXT_SIZE + 5.f, EVAlign::Bottom, PluginColors::NAM_3}, // Knob value text
DEFAULT_HIDE_CURSOR,
DEFAULT_DRAW_FRAME,
false,
@@ -98,22 +102,34 @@ const IVStyle style = IVStyle{true, // Show label
DEFAULT_WIDGET_ANGLE};
const IVStyle styleInactive = style.WithColors(inactiveColorSpec);
-NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo &info)
- : Plugin(info, MakeConfig(kNumParams, kNumPresets)),
- mInputPointers(nullptr), mOutputPointers(nullptr), mNoiseGateTrigger(),
- mNAM(nullptr), mIR(nullptr), mStagedNAM(nullptr), mStagedIR(nullptr),
- mFlagRemoveNAM(false), mFlagRemoveIR(false),
- mDefaultNAMString("Select model..."), mDefaultIRString("Select IR..."),
- mToneBass(), mToneMid(), mToneTreble(), mNAMPath(), mIRPath(),
- mInputSender(), mOutputSender() {
+NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
+: Plugin(info, MakeConfig(kNumParams, kNumPresets))
+, mInputPointers(nullptr)
+, mOutputPointers(nullptr)
+, mNoiseGateTrigger()
+, mNAM(nullptr)
+, mIR(nullptr)
+, mStagedNAM(nullptr)
+, mStagedIR(nullptr)
+, mFlagRemoveNAM(false)
+, mFlagRemoveIR(false)
+, mDefaultNAMString("Select model...")
+, mDefaultIRString("Select IR...")
+, mToneBass()
+, mToneMid()
+, mToneTreble()
+, mNAMPath()
+, mIRPath()
+, mInputSender()
+, mOutputSender()
+{
activations::Activation::enable_fast_tanh();
this->GetParam(kInputLevel)->InitGain("Input", 0.0, -20.0, 20.0, 0.1);
this->GetParam(kToneBass)->InitDouble("Bass", 5.0, 0.0, 10.0, 0.1);
this->GetParam(kToneMid)->InitDouble("Middle", 5.0, 0.0, 10.0, 0.1);
this->GetParam(kToneTreble)->InitDouble("Treble", 5.0, 0.0, 10.0, 0.1);
this->GetParam(kOutputLevel)->InitGain("Output", 0.0, -40.0, 40.0, 0.1);
- this->GetParam(kNoiseGateThreshold)
- ->InitGain("Gate", -80.0, -100.0, 0.0, 0.1);
+ this->GetParam(kNoiseGateThreshold)->InitGain("Gate", -80.0, -100.0, 0.0, 0.1);
this->GetParam(kNoiseGateActive)->InitBool("NoiseGateActive", true);
this->GetParam(kEQActive)->InitBool("ToneStack", true);
this->GetParam(kOutNorm)->InitBool("OutNorm", false);
@@ -131,7 +147,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo &info)
return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, scaleFactor);
};
- mLayoutFunc = [&](IGraphics *pGraphics) {
+ mLayoutFunc = [&](IGraphics* pGraphics) {
pGraphics->AttachCornerResizer(EUIResizerMode::Scale, false);
pGraphics->AttachPanelBackground(COLOR_BLACK);
pGraphics->EnableMouseOver(true);
@@ -154,276 +170,222 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo &info)
const float knobHalfHeight = 70.0f;
const float knobHeight = 2.0f * knobHalfHeight;
const float singleKnobPad = 10.0f;
- const auto knobs =
- content.GetFromTop(knobHeight)
- .GetReducedFromLeft(allKnobsPad)
- .GetReducedFromRight(allKnobsPad)
- .GetTranslated(0.0f, titleHeight + knobsExtraSpaceBelowTitle);
- const IRECT inputKnobArea = knobs.GetGridCell(0, kInputLevel, 1, numKnobs)
- .GetPadded(-singleKnobPad);
- const IRECT noiseGateArea =
- knobs.GetGridCell(0, kNoiseGateThreshold, 1, numKnobs).GetPadded(-10);
- const IRECT bassKnobArea =
- knobs.GetGridCell(0, kToneBass, 1, numKnobs).GetPadded(-singleKnobPad);
- const IRECT middleKnobArea =
- knobs.GetGridCell(0, kToneMid, 1, numKnobs).GetPadded(-singleKnobPad);
- const IRECT trebleKnobArea = knobs.GetGridCell(0, kToneTreble, 1, numKnobs)
- .GetPadded(-singleKnobPad);
- const IRECT outputKnobArea = knobs.GetGridCell(0, kOutputLevel, 1, numKnobs)
- .GetPadded(-singleKnobPad);
+ const auto knobs = content.GetFromTop(knobHeight)
+ .GetReducedFromLeft(allKnobsPad)
+ .GetReducedFromRight(allKnobsPad)
+ .GetTranslated(0.0f, titleHeight + knobsExtraSpaceBelowTitle);
+ const IRECT inputKnobArea = knobs.GetGridCell(0, kInputLevel, 1, numKnobs).GetPadded(-singleKnobPad);
+ const IRECT noiseGateArea = knobs.GetGridCell(0, kNoiseGateThreshold, 1, numKnobs).GetPadded(-10);
+ const IRECT bassKnobArea = knobs.GetGridCell(0, kToneBass, 1, numKnobs).GetPadded(-singleKnobPad);
+ const IRECT middleKnobArea = knobs.GetGridCell(0, kToneMid, 1, numKnobs).GetPadded(-singleKnobPad);
+ const IRECT trebleKnobArea = knobs.GetGridCell(0, kToneTreble, 1, numKnobs).GetPadded(-singleKnobPad);
+ const IRECT outputKnobArea = knobs.GetGridCell(0, kOutputLevel, 1, numKnobs).GetPadded(-singleKnobPad);
const float toggleHeight = 40.0f;
// Area for noise gate toggle
const float ngAreaHeight = toggleHeight;
const float ngAreaHalfWidth = 0.5f * noiseGateArea.W();
- const IRECT ngToggleArea =
- noiseGateArea.GetFromBottom(ngAreaHeight)
- .GetTranslated(0.0f, ngAreaHeight + singleKnobPad)
- .GetMidHPadded(ngAreaHalfWidth);
+ const IRECT ngToggleArea = noiseGateArea.GetFromBottom(ngAreaHeight)
+ .GetTranslated(0.0f, ngAreaHeight + singleKnobPad)
+ .GetMidHPadded(ngAreaHalfWidth);
// Area for EQ toggle
const float eqAreaHeight = toggleHeight;
const float eqAreaHalfWidth = 0.5f * middleKnobArea.W();
- const IRECT eqToggleArea =
- middleKnobArea.GetFromBottom(eqAreaHeight)
- .GetTranslated(0.0f, eqAreaHeight + singleKnobPad)
- .GetMidHPadded(eqAreaHalfWidth);
+ const IRECT eqToggleArea = middleKnobArea.GetFromBottom(eqAreaHeight)
+ .GetTranslated(0.0f, eqAreaHeight + singleKnobPad)
+ .GetMidHPadded(eqAreaHalfWidth);
// Area for output normalization toggle
const float outNormAreaHeight = toggleHeight;
const float outNormAreaHalfWidth = 0.5f * outputKnobArea.W();
- const IRECT outNormToggleArea =
- outputKnobArea.GetFromBottom(outNormAreaHeight)
- .GetTranslated(0.0f, outNormAreaHeight + singleKnobPad)
- .GetMidHPadded(outNormAreaHalfWidth);
+ const IRECT outNormToggleArea = outputKnobArea.GetFromBottom(outNormAreaHeight)
+ .GetTranslated(0.0f, outNormAreaHeight + singleKnobPad)
+ .GetMidHPadded(outNormAreaHalfWidth);
// Areas for model and IR
const float fileWidth = 250.0f;
const float fileHeight = 30.0f;
const float fileSpace = 10.0f;
- const IRECT modelArea = content.GetFromBottom(2.0f * fileHeight + fileSpace)
- .GetFromTop(fileHeight)
- .GetMidHPadded(fileWidth);
- const IRECT irArea =
- content.GetFromBottom(fileHeight).GetMidHPadded(fileWidth);
+ const IRECT modelArea =
+ content.GetFromBottom(2.0f * fileHeight + fileSpace).GetFromTop(fileHeight).GetMidHPadded(fileWidth);
+ const IRECT irArea = content.GetFromBottom(fileHeight).GetMidHPadded(fileWidth);
// Areas for meters
const float meterHalfHeight = 0.5f * 250.0f;
const IRECT inputMeterArea = inputKnobArea.GetFromLeft(allKnobsHalfPad)
- .GetMidHPadded(allKnobsHalfPad)
- .GetMidVPadded(meterHalfHeight)
- .GetTranslated(-allKnobsPad, 0.0f);
+ .GetMidHPadded(allKnobsHalfPad)
+ .GetMidVPadded(meterHalfHeight)
+ .GetTranslated(-allKnobsPad, 0.0f);
const IRECT outputMeterArea = outputKnobArea.GetFromRight(allKnobsHalfPad)
- .GetMidHPadded(allKnobsHalfPad)
- .GetMidVPadded(meterHalfHeight)
- .GetTranslated(allKnobsPad, 0.0f);
+ .GetMidHPadded(allKnobsHalfPad)
+ .GetMidVPadded(meterHalfHeight)
+ .GetTranslated(allKnobsPad, 0.0f);
// auto tolexPNG = pGraphics->LoadBitmap(TOLEX_FN);
// pGraphics->AttachControl(new IBitmapControl(pGraphics->GetBounds(),
// tolexPNG, kNoParameter))->SetBlend(IBlend(EBlend::Default, 0.5));
// The background inside the outermost border
- pGraphics->AttachControl(new IVPanelControl(
- mainArea, "",
- style.WithColor(kFG, PluginColors::NAM_1))); // .WithContrast(-0.75)
pGraphics->AttachControl(
- new IVLabelControl(titleLabel, "Neural Amp Modeler",
- style.WithDrawFrame(false).WithValueText(
- {30, EAlign::Center, PluginColors::NAM_3})));
+ new IVPanelControl(mainArea, "", style.WithColor(kFG, PluginColors::NAM_1))); // .WithContrast(-0.75)
+ pGraphics->AttachControl(
+ new IVLabelControl(titleLabel, "Neural Amp Modeler",
+ style.WithDrawFrame(false).WithValueText({30, EAlign::Center, PluginColors::NAM_3})));
// Model loader button
- auto loadNAM = [&, pGraphics](IControl *pCaller) {
+ auto loadNAM = [&, pGraphics](IControl* pCaller) {
WDL_String initFileName;
WDL_String initPath(this->mNAMPath.Get());
initPath.remove_filepart();
pGraphics->PromptForFile(
- initFileName, initPath, EFileAction::Open, "nam",
- [&](const WDL_String &fileName, const WDL_String &path) {
- if (fileName.GetLength()) {
- // Sets mNAMPath and mStagedNAM
- const std::string msg = this->_GetNAM(fileName);
- // TODO error messages like the IR loader.
- if (msg.size()) {
- std::stringstream ss;
- ss << "Failed to load NAM model. Message:\n\n"
- << msg << "\n\n"
- << "If the model is an old \"directory-style\" model, it "
- "can be "
- "converted using the utility at "
- "https://github.com/sdatkinson/nam-model-utility";
- pGraphics->ShowMessageBox(ss.str().c_str(),
- "Failed to load model!", kMB_OK);
- }
+ initFileName, initPath, EFileAction::Open, "nam", [&](const WDL_String& fileName, const WDL_String& path) {
+ if (fileName.GetLength())
+ {
+ // Sets mNAMPath and mStagedNAM
+ const std::string msg = this->_GetNAM(fileName);
+ // TODO error messages like the IR loader.
+ if (msg.size())
+ {
+ std::stringstream ss;
+ ss << "Failed to load NAM model. Message:\n\n"
+ << msg << "\n\n"
+ << "If the model is an old \"directory-style\" model, it "
+ "can be "
+ "converted using the utility at "
+ "https://github.com/sdatkinson/nam-model-utility";
+ pGraphics->ShowMessageBox(ss.str().c_str(), "Failed to load model!", kMB_OK);
}
- });
+ }
+ });
};
// IR loader button
- auto loadIR = [&, pGraphics](IControl *pCaller) {
+ auto loadIR = [&, pGraphics](IControl* pCaller) {
WDL_String initFileName;
WDL_String initPath(this->mIRPath.Get());
initPath.remove_filepart();
pGraphics->PromptForFile(
- initFileName, initPath, EFileAction::Open, "wav",
- [&](const WDL_String &fileName, const WDL_String &path) {
- if (fileName.GetLength()) {
- this->mIRPath = fileName;
- const dsp::wav::LoadReturnCode retCode = this->_GetIR(fileName);
- if (retCode != dsp::wav::LoadReturnCode::SUCCESS) {
- std::stringstream message;
- message << "Failed to load IR file " << fileName.Get() << ":\n";
- switch (retCode) {
+ initFileName, initPath, EFileAction::Open, "wav", [&](const WDL_String& fileName, const WDL_String& path) {
+ if (fileName.GetLength())
+ {
+ this->mIRPath = fileName;
+ const dsp::wav::LoadReturnCode retCode = this->_GetIR(fileName);
+ if (retCode != dsp::wav::LoadReturnCode::SUCCESS)
+ {
+ std::stringstream message;
+ message << "Failed to load IR file " << fileName.Get() << ":\n";
+ switch (retCode)
+ {
case (dsp::wav::LoadReturnCode::ERROR_OPENING):
message << "Failed to open file (is it being used by another "
"program?)";
break;
- case (dsp::wav::LoadReturnCode::ERROR_NOT_RIFF):
- message << "File is not a WAV file.";
- break;
- case (dsp::wav::LoadReturnCode::ERROR_NOT_WAVE):
- message << "File is not a WAV file.";
- break;
+ case (dsp::wav::LoadReturnCode::ERROR_NOT_RIFF): message << "File is not a WAV file."; break;
+ case (dsp::wav::LoadReturnCode::ERROR_NOT_WAVE): message << "File is not a WAV file."; break;
case (dsp::wav::LoadReturnCode::ERROR_MISSING_FMT):
message << "File is missing expected format chunk.";
break;
- case (dsp::wav::LoadReturnCode::ERROR_INVALID_FILE):
- message << "WAV file contents are invalid.";
- break;
+ case (dsp::wav::LoadReturnCode::ERROR_INVALID_FILE): message << "WAV file contents are invalid."; break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_ALAW):
message << "Unsupported file format \"A-law\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_MULAW):
message << "Unsupported file format \"mu-law\"";
break;
- case (dsp::wav::LoadReturnCode::
- ERROR_UNSUPPORTED_FORMAT_EXTENSIBLE):
+ case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_EXTENSIBLE):
message << "Unsupported file format \"extensible\"";
break;
- case (dsp::wav::LoadReturnCode::ERROR_NOT_MONO):
- message << "File is not mono.";
- break;
- case (dsp::wav::LoadReturnCode::
- ERROR_UNSUPPORTED_BITS_PER_SAMPLE):
+ case (dsp::wav::LoadReturnCode::ERROR_NOT_MONO): message << "File is not mono."; break;
+ case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_BITS_PER_SAMPLE):
message << "Unsupported bits per sample";
break;
- case (dsp::wav::LoadReturnCode::ERROR_OTHER):
- message << "???";
- break;
- default:
- message << "???";
- break;
- }
- pGraphics->ShowMessageBox(message.str().c_str(),
- "Failed to load IR!", kMB_OK);
+ case (dsp::wav::LoadReturnCode::ERROR_OTHER): message << "???"; break;
+ default: message << "???"; break;
}
+ pGraphics->ShowMessageBox(message.str().c_str(), "Failed to load IR!", kMB_OK);
}
- });
+ }
+ });
};
// Model-clearing function
- auto ClearNAM = [&, pGraphics](IControl *pCaller) {
- this->mFlagRemoveNAM = true;
- };
+ auto ClearNAM = [&, pGraphics](IControl* pCaller) { this->mFlagRemoveNAM = true; };
// IR-clearing function
- auto ClearIR = [&, pGraphics](IControl *pCaller) {
- this->mFlagRemoveIR = true;
- };
+ auto ClearIR = [&, pGraphics](IControl* pCaller) { this->mFlagRemoveIR = true; };
// Graphics objects for what NAM is loaded
const float iconWidth = fileHeight; // Square icon
- pGraphics->AttachControl(new IVPanelControl(
- modelArea, "", style.WithColor(kFG, PluginColors::NAM_1)));
- pGraphics->AttachControl(new IRolloverSVGButtonControl(
- modelArea.GetFromLeft(iconWidth).GetPadded(-2.f), loadNAM, fileSVG));
- pGraphics->AttachControl(new IRolloverSVGButtonControl(
- modelArea.GetFromRight(iconWidth).GetPadded(-2.f), ClearNAM,
- closeButtonSVG));
+ pGraphics->AttachControl(new IVPanelControl(modelArea, "", style.WithColor(kFG, PluginColors::NAM_1)));
+ pGraphics->AttachControl(
+ new IRolloverSVGButtonControl(modelArea.GetFromLeft(iconWidth).GetPadded(-2.f), loadNAM, fileSVG));
+ pGraphics->AttachControl(
+ new IRolloverSVGButtonControl(modelArea.GetFromRight(iconWidth).GetPadded(-2.f), ClearNAM, closeButtonSVG));
pGraphics->AttachControl(
- new IVUpdateableLabelControl(
- modelArea.GetReducedFromLeft(iconWidth).GetReducedFromRight(
- iconWidth),
- this->mDefaultNAMString.Get(),
- style.WithDrawFrame(false).WithValueText(
- style.valueText.WithVAlign(EVAlign::Middle))),
- kCtrlTagModelName);
+ new IVUpdateableLabelControl(
+ modelArea.GetReducedFromLeft(iconWidth).GetReducedFromRight(iconWidth), this->mDefaultNAMString.Get(),
+ style.WithDrawFrame(false).WithValueText(style.valueText.WithVAlign(EVAlign::Middle))),
+ kCtrlTagModelName);
// IR
- pGraphics->AttachControl(new IVPanelControl(
- irArea, "", style.WithColor(kFG, PluginColors::NAM_1)));
- pGraphics->AttachControl(new IRolloverSVGButtonControl(
- irArea.GetFromLeft(iconWidth).GetPadded(-2.f), loadIR, fileSVG));
- pGraphics->AttachControl(new IRolloverSVGButtonControl(
- irArea.GetFromRight(iconWidth).GetPadded(-2.f), ClearIR,
- closeButtonSVG));
+ pGraphics->AttachControl(new IVPanelControl(irArea, "", style.WithColor(kFG, PluginColors::NAM_1)));
pGraphics->AttachControl(
- new IVUpdateableLabelControl(
- irArea.GetReducedFromLeft(iconWidth).GetReducedFromRight(iconWidth),
- this->mDefaultIRString.Get(),
- style.WithDrawFrame(false).WithValueText(
- style.valueText.WithVAlign(EVAlign::Middle))),
- kCtrlTagIRName);
+ new IRolloverSVGButtonControl(irArea.GetFromLeft(iconWidth).GetPadded(-2.f), loadIR, fileSVG));
+ pGraphics->AttachControl(
+ new IRolloverSVGButtonControl(irArea.GetFromRight(iconWidth).GetPadded(-2.f), ClearIR, closeButtonSVG));
+ pGraphics->AttachControl(
+ new IVUpdateableLabelControl(
+ irArea.GetReducedFromLeft(iconWidth).GetReducedFromRight(iconWidth), this->mDefaultIRString.Get(),
+ style.WithDrawFrame(false).WithValueText(style.valueText.WithVAlign(EVAlign::Middle))),
+ kCtrlTagIRName);
// NG toggle
- IVSlideSwitchControl *noiseGateSlider =
- new IVSlideSwitchControl(ngToggleArea, kNoiseGateActive, "Gate", style,
- true, // valueInButton
- EDirection::Horizontal);
+ IVSlideSwitchControl* noiseGateSlider = new IVSlideSwitchControl(ngToggleArea, kNoiseGateActive, "Gate", style,
+ true, // valueInButton
+ EDirection::Horizontal);
pGraphics->AttachControl(noiseGateSlider);
// Tone stack toggle
- IVSlideSwitchControl *toneStackSlider =
- new IVSlideSwitchControl(eqToggleArea, kEQActive, "EQ", style,
- true, // valueInButton
- EDirection::Horizontal);
+ IVSlideSwitchControl* toneStackSlider = new IVSlideSwitchControl(eqToggleArea, kEQActive, "EQ", style,
+ true, // valueInButton
+ EDirection::Horizontal);
pGraphics->AttachControl(toneStackSlider);
// NG toggle
- IVSlideSwitchControl *outputNormSlider = new IVSlideSwitchControl(
- outNormToggleArea, kOutNorm, "Normalize", style,
- true, // valueInButton
- EDirection::Horizontal);
+ IVSlideSwitchControl* outputNormSlider = new IVSlideSwitchControl(outNormToggleArea, kOutNorm, "Normalize", style,
+ true, // valueInButton
+ EDirection::Horizontal);
pGraphics->AttachControl(outputNormSlider);
// The knobs
// Input
- pGraphics->AttachControl(
- new IVKnobControl(inputKnobArea, kInputLevel, "", style));
+ pGraphics->AttachControl(new IVKnobControl(inputKnobArea, kInputLevel, "", style));
// Noise gate
const bool noiseGateIsActive = this->GetParam(kNoiseGateActive)->Value();
- const IVStyle noiseGateInitialStyle =
- noiseGateIsActive ? style : styleInactive;
- IVKnobControl *noiseGateControl = new IVKnobControl(
- noiseGateArea, kNoiseGateThreshold, "", noiseGateInitialStyle);
+ const IVStyle noiseGateInitialStyle = noiseGateIsActive ? style : styleInactive;
+ IVKnobControl* noiseGateControl = new IVKnobControl(noiseGateArea, kNoiseGateThreshold, "", noiseGateInitialStyle);
pGraphics->AttachControl(noiseGateControl);
// Tone stack
const bool toneStackIsActive = this->GetParam(kEQActive)->Value();
- const IVStyle toneStackInitialStyle =
- toneStackIsActive ? style : styleInactive;
- IVKnobControl *bassControl =
- new IVKnobControl(bassKnobArea, kToneBass, "", toneStackInitialStyle);
- IVKnobControl *middleControl =
- new IVKnobControl(middleKnobArea, kToneMid, "", toneStackInitialStyle);
- IVKnobControl *trebleControl = new IVKnobControl(
- trebleKnobArea, kToneTreble, "", toneStackInitialStyle);
+ const IVStyle toneStackInitialStyle = toneStackIsActive ? style : styleInactive;
+ IVKnobControl* bassControl = new IVKnobControl(bassKnobArea, kToneBass, "", toneStackInitialStyle);
+ IVKnobControl* middleControl = new IVKnobControl(middleKnobArea, kToneMid, "", toneStackInitialStyle);
+ IVKnobControl* trebleControl = new IVKnobControl(trebleKnobArea, kToneTreble, "", toneStackInitialStyle);
pGraphics->AttachControl(bassControl);
pGraphics->AttachControl(middleControl);
pGraphics->AttachControl(trebleControl);
// Output
- pGraphics->AttachControl(
- new IVKnobControl(outputKnobArea, kOutputLevel, "", style));
+ pGraphics->AttachControl(new IVKnobControl(outputKnobArea, kOutputLevel, "", style));
// Extend the noise gate action function to set the style of its knob
- auto setNoiseGateKnobStyles = [&, pGraphics,
- noiseGateControl](IControl *pCaller) {
+ auto setNoiseGateKnobStyles = [&, pGraphics, noiseGateControl](IControl* pCaller) {
const bool noiseGateActive = pCaller->GetValue() > 0;
const IVStyle noiseGateStyle = noiseGateActive ? style : styleInactive;
noiseGateControl->SetStyle(noiseGateStyle);
noiseGateControl->SetDirty(false);
};
auto defaultNoiseGateSliderAction = noiseGateSlider->GetActionFunction();
- auto noiseGateAction = [defaultNoiseGateSliderAction,
- setNoiseGateKnobStyles](IControl *pCaller) {
+ auto noiseGateAction = [defaultNoiseGateSliderAction, setNoiseGateKnobStyles](IControl* pCaller) {
defaultNoiseGateSliderAction(pCaller);
setNoiseGateKnobStyles(pCaller);
};
noiseGateSlider->SetActionFunction(noiseGateAction);
// Extend the slider action function to set the style of its knobs
- auto setToneStackKnobStyles = [&, pGraphics, bassControl, middleControl,
- trebleControl](IControl *pCaller) {
+ auto setToneStackKnobStyles = [&, pGraphics, bassControl, middleControl, trebleControl](IControl* pCaller) {
const bool toneStackActive = pCaller->GetValue() > 0;
const IVStyle toneStackStyle = toneStackActive ? style : styleInactive;
bassControl->SetStyle(toneStackStyle);
@@ -435,8 +397,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo &info)
trebleControl->SetDirty(false);
};
auto defaultToneStackSliderAction = toneStackSlider->GetActionFunction();
- auto toneStackAction = [defaultToneStackSliderAction,
- setToneStackKnobStyles](IControl *pCaller) {
+ auto toneStackAction = [defaultToneStackSliderAction, setToneStackKnobStyles](IControl* pCaller) {
defaultToneStackSliderAction(pCaller);
setToneStackKnobStyles(pCaller);
};
@@ -446,103 +407,86 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo &info)
const float meterMin = -90.0f;
const float meterMax = -0.01f;
pGraphics
- ->AttachControl(
- new IVPeakAvgMeterControl(
- inputMeterArea, "",
- style.WithWidgetFrac(0.5).WithShowValue(false).WithColor(
- kFG, PluginColors::NAM_2),
- EDirection::Vertical, {}, 0, meterMin, meterMax, {}),
- kCtrlTagInputMeter)
- ->As<IVPeakAvgMeterControl<>>()
- ->SetPeakSize(2.0f);
+ ->AttachControl(
+ new IVPeakAvgMeterControl(inputMeterArea, "",
+ style.WithWidgetFrac(0.5).WithShowValue(false).WithColor(kFG, PluginColors::NAM_2),
+ EDirection::Vertical, {}, 0, meterMin, meterMax, {}),
+ kCtrlTagInputMeter)
+ ->As<IVPeakAvgMeterControl<>>()
+ ->SetPeakSize(2.0f);
pGraphics
- ->AttachControl(
- new IVPeakAvgMeterControl(
- outputMeterArea, "",
- style.WithWidgetFrac(0.5).WithShowValue(false).WithColor(
- kFG, PluginColors::NAM_2),
- EDirection::Vertical, {}, 0, meterMin, meterMax, {}),
- kCtrlTagOutputMeter)
- ->As<IVPeakAvgMeterControl<>>()
- ->SetPeakSize(2.0f);
+ ->AttachControl(
+ new IVPeakAvgMeterControl(outputMeterArea, "",
+ style.WithWidgetFrac(0.5).WithShowValue(false).WithColor(kFG, PluginColors::NAM_2),
+ EDirection::Vertical, {}, 0, meterMin, meterMax, {}),
+ kCtrlTagOutputMeter)
+ ->As<IVPeakAvgMeterControl<>>()
+ ->SetPeakSize(2.0f);
// Help/about box
pGraphics->AttachControl(new IRolloverCircleSVGButtonControl(
- mainArea.GetFromTRHC(50, 50).GetCentredInside(20, 20),
- [pGraphics](IControl *pCaller) {
- pGraphics->GetControlWithTag(kCtrlTagAboutBox)
- ->As<IAboutBoxControl>()
- ->HideAnimated(false);
- },
- helpSVG));
+ mainArea.GetFromTRHC(50, 50).GetCentredInside(20, 20),
+ [pGraphics](IControl* pCaller) {
+ pGraphics->GetControlWithTag(kCtrlTagAboutBox)->As<IAboutBoxControl>()->HideAnimated(false);
+ },
+ helpSVG));
pGraphics
- ->AttachControl(
- new IAboutBoxControl(
- b, COLOR_GRAY,
- // AttachFunc
- [](IContainerBase *pParent, const IRECT &r) {
- pParent->AddChildControl(new IPanelControl(
- IRECT(), IPattern::CreateLinearGradient(
- r, EDirection::Vertical,
- {{PluginColors::NAM_3, 0.f},
- {PluginColors::NAM_1, 1.f}})));
-
- pParent->AddChildControl(new IVPanelControl(
- IRECT(), "",
- style
- .WithColor(kFR, PluginColors::NAM_3.WithOpacity(0.1f))
- .WithColor(kFG,
- PluginColors::NAM_1.WithOpacity(0.1f))));
-
- pParent->AddChildControl(new IVLabelControl(
- IRECT(), "Neural Amp Modeler",
- style.WithDrawFrame(false).WithValueText(
- {30, EAlign::Center, PluginColors::HELP_TEXT})));
-
- WDL_String versionStr{"Version "};
- versionStr.Append(PLUG_VERSION_STR);
- pParent->AddChildControl(new IVLabelControl(
- IRECT(), versionStr.Get(),
- style.WithDrawFrame(false).WithValueText(
- {DEFAULT_TEXT_SIZE, EAlign::Center,
- PluginColors::HELP_TEXT})));
- pParent->AddChildControl(new IVLabelControl(
- IRECT(), "By Steven Atkinson",
- style.WithDrawFrame(false).WithValueText(
- {DEFAULT_TEXT_SIZE, EAlign::Center,
- PluginColors::HELP_TEXT})));
- pParent->AddChildControl(new IURLControl(
- IRECT(), "Train your own model",
- "https://github.com/sdatkinson/neural-amp-modeler",
- {DEFAULT_TEXT_SIZE, PluginColors::HELP_TEXT}));
- },
- // ResizeFunc
- [](IContainerBase *pParent, const IRECT &r) {
- const IRECT mainArea = r.GetPadded(-20);
- const auto content = mainArea.GetPadded(-10);
- const auto titleLabel = content.GetFromTop(50);
- pParent->GetChild(0)->SetTargetAndDrawRECTs(r);
- pParent->GetChild(1)->SetTargetAndDrawRECTs(mainArea);
- pParent->GetChild(2)->SetTargetAndDrawRECTs(titleLabel);
- pParent->GetChild(3)->SetTargetAndDrawRECTs(
- titleLabel.GetVShifted(titleLabel.H()));
- pParent->GetChild(4)->SetTargetAndDrawRECTs(
- titleLabel.GetVShifted(titleLabel.H() + 20));
- pParent->GetChild(5)->SetTargetAndDrawRECTs(
- titleLabel.GetVShifted(titleLabel.H() + 40));
- },
- // Animation Time
- 0),
- kCtrlTagAboutBox)
- ->Hide(true);
+ ->AttachControl(
+ new IAboutBoxControl(
+ b, COLOR_GRAY,
+ // AttachFunc
+ [](IContainerBase* pParent, const IRECT& r) {
+ pParent->AddChildControl(new IPanelControl(
+ IRECT(), IPattern::CreateLinearGradient(
+ r, EDirection::Vertical, {{PluginColors::NAM_3, 0.f}, {PluginColors::NAM_1, 1.f}})));
+
+ pParent->AddChildControl(new IVPanelControl(IRECT(), "",
+ style.WithColor(kFR, PluginColors::NAM_3.WithOpacity(0.1f))
+ .WithColor(kFG, PluginColors::NAM_1.WithOpacity(0.1f))));
+
+ pParent->AddChildControl(new IVLabelControl(
+ IRECT(), "Neural Amp Modeler",
+ style.WithDrawFrame(false).WithValueText({30, EAlign::Center, PluginColors::HELP_TEXT})));
+
+ WDL_String versionStr{"Version "};
+ versionStr.Append(PLUG_VERSION_STR);
+ pParent->AddChildControl(new IVLabelControl(
+ IRECT(), versionStr.Get(),
+ style.WithDrawFrame(false).WithValueText({DEFAULT_TEXT_SIZE, EAlign::Center, PluginColors::HELP_TEXT})));
+ pParent->AddChildControl(new IVLabelControl(
+ IRECT(), "By Steven Atkinson",
+ style.WithDrawFrame(false).WithValueText({DEFAULT_TEXT_SIZE, EAlign::Center, PluginColors::HELP_TEXT})));
+ pParent->AddChildControl(new IURLControl(IRECT(), "Train your own model",
+ "https://github.com/sdatkinson/neural-amp-modeler",
+ {DEFAULT_TEXT_SIZE, PluginColors::HELP_TEXT}));
+ },
+ // ResizeFunc
+ [](IContainerBase* pParent, const IRECT& r) {
+ const IRECT mainArea = r.GetPadded(-20);
+ const auto content = mainArea.GetPadded(-10);
+ const auto titleLabel = content.GetFromTop(50);
+ pParent->GetChild(0)->SetTargetAndDrawRECTs(r);
+ pParent->GetChild(1)->SetTargetAndDrawRECTs(mainArea);
+ pParent->GetChild(2)->SetTargetAndDrawRECTs(titleLabel);
+ pParent->GetChild(3)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H()));
+ pParent->GetChild(4)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 20));
+ pParent->GetChild(5)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 40));
+ },
+ // Animation Time
+ 0),
+ kCtrlTagAboutBox)
+ ->Hide(true);
};
}
-NeuralAmpModeler::~NeuralAmpModeler() { this->_DeallocateIOPointers(); }
+NeuralAmpModeler::~NeuralAmpModeler()
+{
+ this->_DeallocateIOPointers();
+}
-void NeuralAmpModeler::ProcessBlock(iplug::sample **inputs,
- iplug::sample **outputs, int nFrames) {
+void NeuralAmpModeler::ProcessBlock(iplug::sample** inputs, iplug::sample** outputs, int nFrames)
+{
const size_t numChannelsExternalIn = (size_t)this->NInChansConnected();
const size_t numChannelsExternalOut = (size_t)this->NOutChansConnected();
const size_t numChannelsInternal = this->mNUM_INTERNAL_CHANNELS;
@@ -556,61 +500,55 @@ void NeuralAmpModeler::ProcessBlock(iplug::sample **inputs,
this->_PrepareBuffers(numChannelsInternal, numFrames);
// Input is collapsed to mono in preparation for the NAM.
- this->_ProcessInput(inputs, numFrames, numChannelsExternalIn,
- numChannelsInternal);
+ this->_ProcessInput(inputs, numFrames, numChannelsExternalIn, numChannelsInternal);
this->_ApplyDSPStaging();
const bool noiseGateActive = this->GetParam(kNoiseGateActive)->Value();
const bool toneStackActive = this->GetParam(kEQActive)->Value();
// Noise gate trigger
- sample **triggerOutput = mInputPointers;
- if (noiseGateActive) {
+ sample** triggerOutput = mInputPointers;
+ if (noiseGateActive)
+ {
const double time = 0.01;
- const double threshold =
- this->GetParam(kNoiseGateThreshold)->Value(); // GetParam...
- const double ratio = 0.1; // Quadratic...
+ const double threshold = this->GetParam(kNoiseGateThreshold)->Value(); // GetParam...
+ const double ratio = 0.1; // Quadratic...
const double openTime = 0.005;
const double holdTime = 0.01;
const double closeTime = 0.05;
- const dsp::noise_gate::TriggerParams triggerParams(
- time, threshold, ratio, openTime, holdTime, closeTime);
+ const dsp::noise_gate::TriggerParams triggerParams(time, threshold, ratio, openTime, holdTime, closeTime);
this->mNoiseGateTrigger.SetParams(triggerParams);
this->mNoiseGateTrigger.SetSampleRate(sampleRate);
- triggerOutput = this->mNoiseGateTrigger.Process(
- mInputPointers, numChannelsInternal, numFrames);
+ triggerOutput = this->mNoiseGateTrigger.Process(mInputPointers, numChannelsInternal, numFrames);
}
- if (mNAM != nullptr) {
+ if (mNAM != nullptr)
+ {
mNAM->SetNormalize(this->GetParam(kOutNorm)->Value());
// TODO remove input / output gains from here.
const double inputGain = 1.0;
const double outputGain = 1.0;
const int nChans = (int)numChannelsInternal;
- mNAM->process(triggerOutput, this->mOutputPointers, nChans, nFrames,
- inputGain, outputGain, mNAMParams);
+ mNAM->process(triggerOutput, this->mOutputPointers, nChans, nFrames, inputGain, outputGain, mNAMParams);
mNAM->finalize_(nFrames);
- } else {
- this->_FallbackDSP(triggerOutput, this->mOutputPointers,
- numChannelsInternal, numFrames);
+ }
+ else
+ {
+ this->_FallbackDSP(triggerOutput, this->mOutputPointers, numChannelsInternal, numFrames);
}
// Apply the noise gate
- sample **gateGainOutput =
- noiseGateActive
- ? this->mNoiseGateGain.Process(this->mOutputPointers,
- numChannelsInternal, numFrames)
- : this->mOutputPointers;
-
- sample **toneStackOutPointers = gateGainOutput;
- if (toneStackActive) {
+ sample** gateGainOutput = noiseGateActive
+ ? this->mNoiseGateGain.Process(this->mOutputPointers, numChannelsInternal, numFrames)
+ : this->mOutputPointers;
+
+ sample** toneStackOutPointers = gateGainOutput;
+ if (toneStackActive)
+ {
// Translate params from knob 0-10 to dB.
// Tuned ranges based on my ear. E.g. seems treble doesn't need nearly as
// much swing as bass can use.
- const double bassGainDB =
- 4.0 * (this->GetParam(kToneBass)->Value() - 5.0); // +/- 20
- const double midGainDB =
- 3.0 * (this->GetParam(kToneMid)->Value() - 5.0); // +/- 15
- const double trebleGainDB =
- 2.0 * (this->GetParam(kToneTreble)->Value() - 5.0); // +/- 10
+ const double bassGainDB = 4.0 * (this->GetParam(kToneBass)->Value() - 5.0); // +/- 20
+ const double midGainDB = 3.0 * (this->GetParam(kToneMid)->Value() - 5.0); // +/- 15
+ const double trebleGainDB = 2.0 * (this->GetParam(kToneTreble)->Value() - 5.0); // +/- 10
const double bassFrequency = 150.0;
const double midFrequency = 425.0;
@@ -621,45 +559,37 @@ void NeuralAmpModeler::ProcessBlock(iplug::sample **inputs,
const double trebleQuality = 0.707;
// Define filter parameters
- recursive_linear_filter::BiquadParams bassParams(sampleRate, bassFrequency,
- bassQuality, bassGainDB);
- recursive_linear_filter::BiquadParams midParams(sampleRate, midFrequency,
- midQuality, midGainDB);
- recursive_linear_filter::BiquadParams trebleParams(
- sampleRate, trebleFrequency, trebleQuality, trebleGainDB);
+ recursive_linear_filter::BiquadParams bassParams(sampleRate, bassFrequency, bassQuality, bassGainDB);
+ recursive_linear_filter::BiquadParams midParams(sampleRate, midFrequency, midQuality, midGainDB);
+ recursive_linear_filter::BiquadParams trebleParams(sampleRate, trebleFrequency, trebleQuality, trebleGainDB);
// Apply tone stack
// Set parameters
this->mToneBass.SetParams(bassParams);
this->mToneMid.SetParams(midParams);
this->mToneTreble.SetParams(trebleParams);
- sample **bassPointers =
- this->mToneBass.Process(gateGainOutput, numChannelsInternal, numFrames);
- sample **midPointers =
- this->mToneMid.Process(bassPointers, numChannelsInternal, numFrames);
- sample **treblePointers =
- this->mToneTreble.Process(midPointers, numChannelsInternal, numFrames);
+ sample** bassPointers = this->mToneBass.Process(gateGainOutput, numChannelsInternal, numFrames);
+ sample** midPointers = this->mToneMid.Process(bassPointers, numChannelsInternal, numFrames);
+ sample** treblePointers = this->mToneTreble.Process(midPointers, numChannelsInternal, numFrames);
toneStackOutPointers = treblePointers;
}
- sample **irPointers = toneStackOutPointers;
+ sample** irPointers = toneStackOutPointers;
if (this->mIR != nullptr)
- irPointers = this->mIR->Process(toneStackOutPointers, numChannelsInternal,
- numFrames);
+ irPointers = this->mIR->Process(toneStackOutPointers, numChannelsInternal, numFrames);
// restore previous floating point state
std::feupdateenv(&fe_state);
// Let's get outta here
// This is where we exit mono for whatever the output requires.
- this->_ProcessOutput(irPointers, outputs, numFrames, numChannelsInternal,
- numChannelsExternalOut);
+ this->_ProcessOutput(irPointers, outputs, numFrames, numChannelsInternal, numChannelsExternalOut);
// * Output of input leveling (inputs -> mInputPointers),
// * Output of output leveling (mOutputPointers -> outputs)
- this->_UpdateMeters(this->mInputPointers, outputs, numFrames,
- numChannelsInternal, numChannelsExternalOut);
+ this->_UpdateMeters(this->mInputPointers, outputs, numFrames, numChannelsInternal, numChannelsExternalOut);
}
-bool NeuralAmpModeler::SerializeState(IByteChunk &chunk) const {
+bool NeuralAmpModeler::SerializeState(IByteChunk& chunk) const
+{
// Model directory (don't serialize the model itself; we'll just load it again
// when we unserialize)
chunk.PutStr(this->mNAMPath.Get());
@@ -667,7 +597,8 @@ bool NeuralAmpModeler::SerializeState(IByteChunk &chunk) const {
return SerializeParams(chunk);
}
-int NeuralAmpModeler::UnserializeState(const IByteChunk &chunk, int startPos) {
+int NeuralAmpModeler::UnserializeState(const IByteChunk& chunk, int startPos)
+{
WDL_String dir;
startPos = chunk.GetStr(this->mNAMPath, startPos);
startPos = chunk.GetStr(this->mIRPath, startPos);
@@ -681,7 +612,8 @@ int NeuralAmpModeler::UnserializeState(const IByteChunk &chunk, int startPos) {
return retcode;
}
-void NeuralAmpModeler::OnUIOpen() {
+void NeuralAmpModeler::OnUIOpen()
+{
Plugin::OnUIOpen();
if (this->mNAMPath.GetLength())
this->_SetModelMsg(this->mNAMPath);
@@ -691,40 +623,44 @@ void NeuralAmpModeler::OnUIOpen() {
// Private methods ============================================================
-void NeuralAmpModeler::_AllocateIOPointers(const size_t nChans) {
+void NeuralAmpModeler::_AllocateIOPointers(const size_t nChans)
+{
if (this->mInputPointers != nullptr)
- throw std::runtime_error(
- "Tried to re-allocate mInputPointers without freeing");
- this->mInputPointers = new sample *[nChans];
+ throw std::runtime_error("Tried to re-allocate mInputPointers without freeing");
+ this->mInputPointers = new sample*[nChans];
if (this->mInputPointers == nullptr)
throw std::runtime_error("Failed to allocate pointer to input buffer!\n");
if (this->mOutputPointers != nullptr)
- throw std::runtime_error(
- "Tried to re-allocate mOutputPointers without freeing");
- this->mOutputPointers = new sample *[nChans];
+ throw std::runtime_error("Tried to re-allocate mOutputPointers without freeing");
+ this->mOutputPointers = new sample*[nChans];
if (this->mOutputPointers == nullptr)
throw std::runtime_error("Failed to allocate pointer to output buffer!\n");
}
-void NeuralAmpModeler::_ApplyDSPStaging() {
+void NeuralAmpModeler::_ApplyDSPStaging()
+{
// Move things from staged to live
- if (this->mStagedNAM != nullptr) {
+ if (this->mStagedNAM != nullptr)
+ {
// Move from staged to active DSP
this->mNAM = std::move(this->mStagedNAM);
this->mStagedNAM = nullptr;
}
- if (this->mStagedIR != nullptr) {
+ if (this->mStagedIR != nullptr)
+ {
this->mIR = std::move(this->mStagedIR);
this->mStagedIR = nullptr;
}
// Remove marked modules
- if (this->mFlagRemoveNAM) {
+ if (this->mFlagRemoveNAM)
+ {
this->mNAM = nullptr;
this->mNAMPath.Set("");
this->_UnsetModelMsg();
this->mFlagRemoveNAM = false;
}
- if (this->mFlagRemoveIR) {
+ if (this->mFlagRemoveIR)
+ {
this->mIR = nullptr;
this->mIRPath.Set("");
this->_UnsetIRMsg();
@@ -732,44 +668,49 @@ void NeuralAmpModeler::_ApplyDSPStaging() {
}
}
-void NeuralAmpModeler::_DeallocateIOPointers() {
- if (this->mInputPointers != nullptr) {
+void NeuralAmpModeler::_DeallocateIOPointers()
+{
+ if (this->mInputPointers != nullptr)
+ {
delete[] this->mInputPointers;
this->mInputPointers = nullptr;
}
if (this->mInputPointers != nullptr)
throw std::runtime_error("Failed to deallocate pointer to input buffer!\n");
- if (this->mOutputPointers != nullptr) {
+ if (this->mOutputPointers != nullptr)
+ {
delete[] this->mOutputPointers;
this->mOutputPointers = nullptr;
}
if (this->mOutputPointers != nullptr)
- throw std::runtime_error(
- "Failed to deallocate pointer to output buffer!\n");
+ throw std::runtime_error("Failed to deallocate pointer to output buffer!\n");
}
-void NeuralAmpModeler::_FallbackDSP(iplug::sample **inputs,
- iplug::sample **outputs,
- const size_t numChannels,
- const size_t numFrames) {
+void NeuralAmpModeler::_FallbackDSP(iplug::sample** inputs, iplug::sample** outputs, const size_t numChannels,
+ const size_t numFrames)
+{
for (auto c = 0; c < numChannels; c++)
for (auto s = 0; s < numFrames; s++)
this->mOutputArray[c][s] = this->mInputArray[c][s];
}
-std::string NeuralAmpModeler::_GetNAM(const WDL_String &modelPath) {
+std::string NeuralAmpModeler::_GetNAM(const WDL_String& modelPath)
+{
WDL_String previousNAMPath = this->mNAMPath;
- try {
+ try
+ {
auto dspPath = std::filesystem::path(modelPath.Get());
mStagedNAM = get_dsp(dspPath);
this->_SetModelMsg(modelPath);
this->mNAMPath = modelPath;
- } catch (std::exception &e) {
+ }
+ catch (std::exception& e)
+ {
std::stringstream ss;
ss << "FAILED to load model";
- SendControlMsgFromDelegate(kCtrlTagModelName, 0,
- int(strlen(ss.str().c_str())), ss.str().c_str());
- if (this->mStagedNAM != nullptr) {
+ SendControlMsgFromDelegate(kCtrlTagModelName, 0, int(strlen(ss.str().c_str())), ss.str().c_str());
+ if (this->mStagedNAM != nullptr)
+ {
this->mStagedNAM = nullptr;
}
this->mNAMPath = previousNAMPath;
@@ -780,73 +721,82 @@ std::string NeuralAmpModeler::_GetNAM(const WDL_String &modelPath) {
return "";
}
-dsp::wav::LoadReturnCode NeuralAmpModeler::_GetIR(const WDL_String &irPath) {
+dsp::wav::LoadReturnCode NeuralAmpModeler::_GetIR(const WDL_String& irPath)
+{
// FIXME it'd be better for the path to be "staged" as well. Just in case the
// path and the model got caught on opposite sides of the fence...
WDL_String previousIRPath = this->mIRPath;
const double sampleRate = this->GetSampleRate();
dsp::wav::LoadReturnCode wavState = dsp::wav::LoadReturnCode::ERROR_OTHER;
- try {
- this->mStagedIR =
- std::make_unique<dsp::ImpulseResponse>(irPath.Get(), sampleRate);
+ try
+ {
+ this->mStagedIR = std::make_unique<dsp::ImpulseResponse>(irPath.Get(), sampleRate);
wavState = this->mStagedIR->GetWavState();
- } catch (std::exception &e) {
+ }
+ catch (std::exception& e)
+ {
wavState = dsp::wav::LoadReturnCode::ERROR_OTHER;
- std::cerr << "Caught unhandled exception while attempting to load IR:"
- << std::endl;
+ std::cerr << "Caught unhandled exception while attempting to load IR:" << std::endl;
std::cerr << e.what() << std::endl;
}
- if (wavState == dsp::wav::LoadReturnCode::SUCCESS) {
+ if (wavState == dsp::wav::LoadReturnCode::SUCCESS)
+ {
this->_SetIRMsg(irPath);
this->mIRPath = irPath;
- } else {
- if (this->mStagedIR != nullptr) {
+ }
+ else
+ {
+ if (this->mStagedIR != nullptr)
+ {
this->mStagedIR = nullptr;
}
this->mIRPath = previousIRPath;
std::stringstream ss;
ss << "FAILED to load IR";
- SendControlMsgFromDelegate(kCtrlTagIRName, 0, int(strlen(ss.str().c_str())),
- ss.str().c_str());
+ SendControlMsgFromDelegate(kCtrlTagIRName, 0, int(strlen(ss.str().c_str())), ss.str().c_str());
}
return wavState;
}
-size_t NeuralAmpModeler::_GetBufferNumChannels() const {
+size_t NeuralAmpModeler::_GetBufferNumChannels() const
+{
// Assumes input=output (no mono->stereo effects)
return this->mInputArray.size();
}
-size_t NeuralAmpModeler::_GetBufferNumFrames() const {
+size_t NeuralAmpModeler::_GetBufferNumFrames() const
+{
if (this->_GetBufferNumChannels() == 0)
return 0;
return this->mInputArray[0].size();
}
-void NeuralAmpModeler::_PrepareBuffers(const size_t numChannels,
- const size_t numFrames) {
+void NeuralAmpModeler::_PrepareBuffers(const size_t numChannels, const size_t numFrames)
+{
const bool updateChannels = numChannels != this->_GetBufferNumChannels();
- const bool updateFrames =
- updateChannels || (this->_GetBufferNumFrames() != numFrames);
+ const bool updateFrames = updateChannels || (this->_GetBufferNumFrames() != numFrames);
// if (!updateChannels && !updateFrames) // Could we do this?
// return;
- if (updateChannels) {
+ if (updateChannels)
+ {
this->_PrepareIOPointers(numChannels);
this->mInputArray.resize(numChannels);
this->mOutputArray.resize(numChannels);
}
- if (updateFrames) {
- for (auto c = 0; c < this->mInputArray.size(); c++) {
+ if (updateFrames)
+ {
+ for (auto c = 0; c < this->mInputArray.size(); c++)
+ {
this->mInputArray[c].resize(numFrames);
std::fill(this->mInputArray[c].begin(), this->mInputArray[c].end(), 0.0);
}
- for (auto c = 0; c < this->mOutputArray.size(); c++) {
+ for (auto c = 0; c < this->mOutputArray.size(); c++)
+ {
this->mOutputArray[c].resize(numFrames);
- std::fill(this->mOutputArray[c].begin(), this->mOutputArray[c].end(),
- 0.0);
+ std::fill(this->mOutputArray[c].begin(), this->mOutputArray[c].end(), 0.0);
}
}
// Would these ever get changed by something?
@@ -856,34 +806,32 @@ void NeuralAmpModeler::_PrepareBuffers(const size_t numChannels,
this->mOutputPointers[c] = this->mOutputArray[c].data();
}
-void NeuralAmpModeler::_PrepareIOPointers(const size_t numChannels) {
+void NeuralAmpModeler::_PrepareIOPointers(const size_t numChannels)
+{
this->_DeallocateIOPointers();
this->_AllocateIOPointers(numChannels);
}
-void NeuralAmpModeler::_ProcessInput(iplug::sample **inputs,
- const size_t nFrames,
- const size_t nChansIn,
- const size_t nChansOut) {
+void NeuralAmpModeler::_ProcessInput(iplug::sample** inputs, const size_t nFrames, const size_t nChansIn,
+ const size_t nChansOut)
+{
// Assume _PrepareBuffers() was already called
const double gain = pow(10.0, GetParam(kInputLevel)->Value() / 20.0);
if (nChansOut <= nChansIn) // Many->few: Drop additional channels
for (size_t c = 0; c < nChansOut; c++)
for (size_t s = 0; s < nFrames; s++)
this->mInputArray[c][s] = gain * inputs[c][s];
- else {
+ else
+ {
// Something is wrong--this is a mono plugin. How could there be fewer
// incoming channels?
- throw std::runtime_error(
- "Unexpected input processing--sees fewer than 1 incoming channel?");
+ throw std::runtime_error("Unexpected input processing--sees fewer than 1 incoming channel?");
}
}
-void NeuralAmpModeler::_ProcessOutput(iplug::sample **inputs,
- iplug::sample **outputs,
- const size_t nFrames,
- const size_t nChansIn,
- const size_t nChansOut) {
+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);
// Assume _PrepareBuffers() was already called
if (nChansIn != 1)
@@ -900,7 +848,8 @@ void NeuralAmpModeler::_ProcessOutput(iplug::sample **inputs,
#endif
}
-void NeuralAmpModeler::_SetModelMsg(const WDL_String &modelPath) {
+void NeuralAmpModeler::_SetModelMsg(const WDL_String& modelPath)
+{
auto dspPath = std::filesystem::path(modelPath.Get());
std::stringstream ss;
ss << "Loaded ";
@@ -908,41 +857,38 @@ void NeuralAmpModeler::_SetModelMsg(const WDL_String &modelPath) {
ss << dspPath.filename().stem(); // /path/to/model.nam -> "model"
else
ss << dspPath.parent_path().filename(); // /path/to/model/ -> "model"
- SendControlMsgFromDelegate(kCtrlTagModelName, 0,
- int(strlen(ss.str().c_str())), ss.str().c_str());
+ SendControlMsgFromDelegate(kCtrlTagModelName, 0, int(strlen(ss.str().c_str())), ss.str().c_str());
}
-void NeuralAmpModeler::_SetIRMsg(const WDL_String &irPath) {
- this->mIRPath =
- irPath; // This might already be done elsewhere...need to dedup.
+void NeuralAmpModeler::_SetIRMsg(const WDL_String& irPath)
+{
+ this->mIRPath = irPath; // This might already be done elsewhere...need to dedup.
auto dspPath = std::filesystem::path(irPath.Get());
std::stringstream ss;
ss << "Loaded " << dspPath.filename().stem();
- SendControlMsgFromDelegate(kCtrlTagIRName, 0, int(strlen(ss.str().c_str())),
- ss.str().c_str());
+ SendControlMsgFromDelegate(kCtrlTagIRName, 0, int(strlen(ss.str().c_str())), ss.str().c_str());
}
-void NeuralAmpModeler::_UnsetModelMsg() {
+void NeuralAmpModeler::_UnsetModelMsg()
+{
this->_UnsetMsg(kCtrlTagModelName, this->mDefaultNAMString);
}
-void NeuralAmpModeler::_UnsetIRMsg() {
+void NeuralAmpModeler::_UnsetIRMsg()
+{
this->_UnsetMsg(kCtrlTagIRName, this->mDefaultIRString);
}
-void NeuralAmpModeler::_UnsetMsg(const int tag, const WDL_String &msg) {
+void NeuralAmpModeler::_UnsetMsg(const int tag, const WDL_String& msg)
+{
SendControlMsgFromDelegate(tag, 0, int(strlen(msg.Get())), msg.Get());
}
-void NeuralAmpModeler::_UpdateMeters(sample **inputPointer,
- sample **outputPointer,
- const size_t nFrames,
- const size_t nChansIn,
- const size_t nChansOut) {
+void NeuralAmpModeler::_UpdateMeters(sample** inputPointer, sample** outputPointer, const size_t nFrames,
+ const size_t nChansIn, const size_t nChansOut)
+{
// Right now, we didn't specify MAXNC when we initialized these, so it's 1.
const int nChansHack = 1;
- this->mInputSender.ProcessBlock(inputPointer, (int)nFrames,
- kCtrlTagInputMeter, nChansHack);
- this->mOutputSender.ProcessBlock(outputPointer, (int)nFrames,
- kCtrlTagOutputMeter, nChansHack);
+ this->mInputSender.ProcessBlock(inputPointer, (int)nFrames, kCtrlTagInputMeter, nChansHack);
+ this->mOutputSender.ProcessBlock(outputPointer, (int)nFrames, kCtrlTagOutputMeter, nChansHack);
}
diff --git a/NeuralAmpModeler/NeuralAmpModeler.h b/NeuralAmpModeler/NeuralAmpModeler.h
@@ -12,7 +12,8 @@
const int kNumPresets = 1;
-enum EParams {
+enum EParams
+{
// These need to be the first ones because I use their indices to place
// their rects in the GUI.
kInputLevel = 0,
@@ -30,7 +31,8 @@ enum EParams {
const int numKnobs = 6;
-enum ECtrlTags {
+enum ECtrlTags
+{
kCtrlTagModelName = 0,
kCtrlTagIRName,
kCtrlTagInputMeter,
@@ -39,30 +41,29 @@ enum ECtrlTags {
kNumCtrlTags
};
-class NeuralAmpModeler final : public iplug::Plugin {
+class NeuralAmpModeler final : public iplug::Plugin
+{
public:
- NeuralAmpModeler(const iplug::InstanceInfo &info);
+ NeuralAmpModeler(const iplug::InstanceInfo& info);
~NeuralAmpModeler();
- void ProcessBlock(iplug::sample **inputs, iplug::sample **outputs,
- int nFrames) override;
- void OnReset() override {
+ void ProcessBlock(iplug::sample** inputs, iplug::sample** outputs, int nFrames) override;
+ void OnReset() override
+ {
const auto sampleRate = this->GetSampleRate();
this->mInputSender.Reset(sampleRate);
this->mOutputSender.Reset(sampleRate);
}
- void OnIdle() override {
+ void OnIdle() override
+ {
this->mInputSender.TransmitData(*this);
this->mOutputSender.TransmitData(*this);
}
- bool SerializeState(iplug::IByteChunk &chunk) const override;
- int UnserializeState(const iplug::IByteChunk &chunk, int startPos) override;
+ bool SerializeState(iplug::IByteChunk& chunk) const override;
+ int UnserializeState(const iplug::IByteChunk& chunk, int startPos) override;
void OnUIOpen() override;
- bool OnHostRequestingSupportedViewConfiguration(int width,
- int height) override {
- return true;
- }
+ bool OnHostRequestingSupportedViewConfiguration(int width, int height) override { return true; }
private:
// Allocates mInputPointers and mOutputPointers
@@ -75,20 +76,19 @@ private:
// Deallocates mInputPointers and mOutputPointers
void _DeallocateIOPointers();
// Fallback that just copies inputs to outputs if mDSP doesn't hold a model.
- void _FallbackDSP(iplug::sample **inputs, iplug::sample **outputs,
- const size_t numChannels, const size_t numFrames);
+ void _FallbackDSP(iplug::sample** inputs, iplug::sample** outputs, const size_t numChannels, const size_t numFrames);
// Sizes based on mInputArray
size_t _GetBufferNumChannels() const;
size_t _GetBufferNumFrames() const;
// Gets a new Neural Amp Model object and stores it to mStagedNAM
// Returns an emptry string on success, or an error message on failure.
- std::string _GetNAM(const WDL_String &dspFile);
+ std::string _GetNAM(const WDL_String& dspFile);
// Gets the IR and stores to mStagedIR.
// Return status code so that error messages can be relayed if
// it wasn't successful.
- dsp::wav::LoadReturnCode _GetIR(const WDL_String &irPath);
+ dsp::wav::LoadReturnCode _GetIR(const WDL_String& irPath);
// Update the message about which model is loaded.
- void _SetModelMsg(const WDL_String &dspPath);
+ void _SetModelMsg(const WDL_String& dspPath);
bool _HaveModel() const { return this->mNAM != nullptr; };
// Prepare the input & output buffers
void _PrepareBuffers(const size_t numChannels, const size_t numFrames);
@@ -97,24 +97,21 @@ private:
// Copy the input buffer to the object, applying input level.
// :param nChansIn: In from external
// :param nChansOut: Out to the internal of the DSP routine
- void _ProcessInput(iplug::sample **inputs, const size_t nFrames,
- const size_t nChansIn, const size_t nChansOut);
+ void _ProcessInput(iplug::sample** inputs, const size_t nFrames, const size_t nChansIn, const size_t nChansOut);
// Copy the output to the output buffer, applying output level.
// :param nChansIn: In from internal
// :param nChansOut: Out to external
- void _ProcessOutput(iplug::sample **inputs, iplug::sample **outputs,
- const size_t nFrames, const size_t nChansIn,
+ void _ProcessOutput(iplug::sample** inputs, iplug::sample** outputs, const size_t nFrames, const size_t nChansIn,
const size_t nChansOut);
// Update the text in the IR area to say what's loaded.
- void _SetIRMsg(const WDL_String &irPath);
+ void _SetIRMsg(const WDL_String& irPath);
void _UnsetModelMsg();
void _UnsetIRMsg();
- void _UnsetMsg(const int tag, const WDL_String &msg);
+ void _UnsetMsg(const int tag, const WDL_String& msg);
// Update level meters
// Called within ProcessBlock().
// Assume _ProcessInput() and _ProcessOutput() were run immediately before.
- void _UpdateMeters(iplug::sample **inputPointer,
- iplug::sample **outputPointer, const size_t nFrames,
+ void _UpdateMeters(iplug::sample** inputPointer, iplug::sample** outputPointer, const size_t nFrames,
const size_t nChansIn, const size_t nChansOut);
// Member data
@@ -127,8 +124,8 @@ private:
// Output from NAM
std::vector<std::vector<iplug::sample>> mOutputArray;
// Pointer versions
- iplug::sample **mInputPointers;
- iplug::sample **mOutputPointers;
+ iplug::sample** mInputPointers;
+ iplug::sample** mOutputPointers;
// Noise gates
dsp::noise_gate::Trigger mNoiseGateTrigger;
@@ -156,8 +153,7 @@ private:
// Path to IR (.wav file)
WDL_String mIRPath;
- std::unordered_map<std::string, double> mNAMParams = {{"Input", 0.0},
- {"Output", 0.0}};
+ std::unordered_map<std::string, double> mNAMParams = {{"Input", 0.0}, {"Output", 0.0}};
iplug::IPeakAvgSender<> mInputSender;
iplug::IPeakAvgSender<> mOutputSender;
diff --git a/NeuralAmpModeler/choc_DisableAllWarnings.h b/NeuralAmpModeler/choc_DisableAllWarnings.h
@@ -36,43 +36,43 @@
*/
#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Weverything"
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Weverything"
#elif __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wall"
-#pragma GCC diagnostic ignored "-Wpragmas"
-#pragma GCC diagnostic ignored "-Wextra"
-#pragma GCC diagnostic ignored "-Wshadow"
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#pragma GCC diagnostic ignored "-Wconversion"
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#pragma GCC diagnostic ignored "-Wfloat-conversion"
-#pragma GCC diagnostic ignored "-Wswitch-enum"
-#pragma GCC diagnostic ignored "-Wswitch"
-#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wredundant-decls"
-#pragma GCC diagnostic ignored "-Wsubobject-linkage"
-#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
-#pragma GCC diagnostic ignored "-Wredundant-move"
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
-#pragma GCC diagnostic ignored "-Woverloaded-virtual"
-#pragma GCC diagnostic ignored "-Wc99-extensions"
-#pragma GCC diagnostic ignored "-Wmisleading-indentation"
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-#pragma GCC diagnostic ignored "-Wcast-function-type"
-#pragma GCC diagnostic ignored "-Wunused-label"
-#pragma GCC diagnostic ignored "-Wnarrowing"
-#pragma GCC diagnostic ignored "-Wparentheses"
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wall"
+ #pragma GCC diagnostic ignored "-Wpragmas"
+ #pragma GCC diagnostic ignored "-Wextra"
+ #pragma GCC diagnostic ignored "-Wshadow"
+ #pragma GCC diagnostic ignored "-Wunused-parameter"
+ #pragma GCC diagnostic ignored "-Wconversion"
+ #pragma GCC diagnostic ignored "-Wsign-conversion"
+ #pragma GCC diagnostic ignored "-Wsign-compare"
+ #pragma GCC diagnostic ignored "-Wfloat-conversion"
+ #pragma GCC diagnostic ignored "-Wswitch-enum"
+ #pragma GCC diagnostic ignored "-Wswitch"
+ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
+ #pragma GCC diagnostic ignored "-Wunused-variable"
+ #pragma GCC diagnostic ignored "-Wredundant-decls"
+ #pragma GCC diagnostic ignored "-Wsubobject-linkage"
+ #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+ #pragma GCC diagnostic ignored "-Wredundant-move"
+ #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+ #pragma GCC diagnostic ignored "-Woverloaded-virtual"
+ #pragma GCC diagnostic ignored "-Wc99-extensions"
+ #pragma GCC diagnostic ignored "-Wmisleading-indentation"
+ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+ #pragma GCC diagnostic ignored "-Wcast-function-type"
+ #pragma GCC diagnostic ignored "-Wunused-label"
+ #pragma GCC diagnostic ignored "-Wnarrowing"
+ #pragma GCC diagnostic ignored "-Wparentheses"
-#ifndef __MINGW32__
-#pragma GCC diagnostic ignored "-Wredundant-move"
-#endif
+ #ifndef __MINGW32__
+ #pragma GCC diagnostic ignored "-Wredundant-move"
+ #endif
#else
-#pragma warning(push, 0)
-#pragma warning(disable : 4702)
-#pragma warning(disable : 4706)
+ #pragma warning(push, 0)
+ #pragma warning(disable : 4702)
+ #pragma warning(disable : 4706)
#endif
diff --git a/NeuralAmpModeler/choc_ReenableAllWarnings.h b/NeuralAmpModeler/choc_ReenableAllWarnings.h
@@ -25,9 +25,9 @@
// choc_DisableAllWarnings.h and choc_ReenableAllWarnings.h
#if __clang__
-#pragma clang diagnostic pop
+ #pragma clang diagnostic pop
#elif __GNUC__
-#pragma GCC diagnostic pop
+ #pragma GCC diagnostic pop
#else
-#pragma warning(pop)
+ #pragma warning(pop)
#endif
diff --git a/NeuralAmpModeler/resources/NeuralAmpModelerAU.h b/NeuralAmpModeler/resources/NeuralAmpModelerAU.h
@@ -1,9 +1,9 @@
#include <TargetConditionals.h>
#if TARGET_OS_IOS == 1
-#import <UIKit/UIKit.h>
+ #import <UIKit/UIKit.h>
#else
-#import <Cocoa/Cocoa.h>
+ #import <Cocoa/Cocoa.h>
#endif
#define IPLUG_AUVIEWCONTROLLER IPlugAUViewController_vNeuralAmpModeler
diff --git a/NeuralAmpModeler/resources/resource.h b/NeuralAmpModeler/resources/resource.h
@@ -35,10 +35,10 @@
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 105
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1011
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
+ #ifndef APSTUDIO_READONLY_SYMBOLS
+ #define _APS_NEXT_RESOURCE_VALUE 105
+ #define _APS_NEXT_COMMAND_VALUE 40001
+ #define _APS_NEXT_CONTROL_VALUE 1011
+ #define _APS_NEXT_SYMED_VALUE 101
+ #endif
#endif
diff --git a/TemplateProject/TemplateProject.cpp b/TemplateProject/TemplateProject.cpp
@@ -5,33 +5,30 @@
// clang-format on
#if IPLUG_EDITOR
-#include "IControls.h"
+ #include "IControls.h"
#endif
-TemplateProject::TemplateProject(const InstanceInfo &info)
- : Plugin(info, MakeConfig(kNumParams, kNumPresets)) {
+TemplateProject::TemplateProject(const InstanceInfo& info)
+: Plugin(info, MakeConfig(kNumParams, kNumPresets))
+{
GetParam(kParamGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");
#if IPLUG_EDITOR // http://bit.ly/2S64BDd
- mMakeGraphicsFunc = [&]() {
- return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS);
- };
+ mMakeGraphicsFunc = [&]() { return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS); };
- mLayoutFunc = [&](IGraphics *pGraphics) {
+ mLayoutFunc = [&](IGraphics* pGraphics) {
const IRECT bounds = pGraphics->GetBounds();
const IRECT innerBounds = bounds.GetPadded(-10.f);
const IRECT sliderBounds = innerBounds.GetFromLeft(150).GetMidVPadded(100);
const IRECT versionBounds = innerBounds.GetFromTRHC(300, 20);
const IRECT titleBounds = innerBounds.GetCentredInside(200, 50);
- if (pGraphics->NControls()) {
+ if (pGraphics->NControls())
+ {
pGraphics->GetBackgroundControl()->SetTargetAndDrawRECTs(bounds);
- pGraphics->GetControlWithTag(kCtrlTagSlider)
- ->SetTargetAndDrawRECTs(sliderBounds);
- pGraphics->GetControlWithTag(kCtrlTagTitle)
- ->SetTargetAndDrawRECTs(titleBounds);
- pGraphics->GetControlWithTag(kCtrlTagVersionNumber)
- ->SetTargetAndDrawRECTs(versionBounds);
+ pGraphics->GetControlWithTag(kCtrlTagSlider)->SetTargetAndDrawRECTs(sliderBounds);
+ pGraphics->GetControlWithTag(kCtrlTagTitle)->SetTargetAndDrawRECTs(titleBounds);
+ pGraphics->GetControlWithTag(kCtrlTagVersionNumber)->SetTargetAndDrawRECTs(versionBounds);
return;
}
@@ -39,36 +36,34 @@ TemplateProject::TemplateProject(const InstanceInfo &info)
pGraphics->AttachCornerResizer(EUIResizerMode::Size, true);
pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
pGraphics->AttachPanelBackground(COLOR_LIGHT_GRAY);
- pGraphics->AttachControl(new IVSliderControl(sliderBounds, kParamGain),
- kCtrlTagSlider);
- pGraphics->AttachControl(
- new ITextControl(titleBounds, "TemplateProject", IText(30)),
- kCtrlTagTitle);
+ pGraphics->AttachControl(new IVSliderControl(sliderBounds, kParamGain), kCtrlTagSlider);
+ pGraphics->AttachControl(new ITextControl(titleBounds, "TemplateProject", IText(30)), kCtrlTagTitle);
WDL_String buildInfoStr;
GetBuildInfoStr(buildInfoStr, __DATE__, __TIME__);
pGraphics->AttachControl(
- new ITextControl(versionBounds, buildInfoStr.Get(),
- DEFAULT_TEXT.WithAlign(EAlign::Far)),
- kCtrlTagVersionNumber);
+ new ITextControl(versionBounds, buildInfoStr.Get(), DEFAULT_TEXT.WithAlign(EAlign::Far)), kCtrlTagVersionNumber);
};
#endif
}
#if IPLUG_EDITOR
-void TemplateProject::OnParentWindowResize(int width, int height) {
+void TemplateProject::OnParentWindowResize(int width, int height)
+{
if (GetUI())
GetUI()->Resize(width, height, 1.f, false);
}
#endif
#if IPLUG_DSP
-void TemplateProject::ProcessBlock(sample **inputs, sample **outputs,
- int nFrames) {
+void TemplateProject::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
+{
const int nChans = NOutChansConnected();
const double gain = GetParam(kParamGain)->Value() / 100.;
- for (int s = 0; s < nFrames; s++) {
- for (int c = 0; c < nChans; c++) {
+ for (int s = 0; s < nFrames; s++)
+ {
+ for (int c = 0; c < nChans; c++)
+ {
outputs[c][s] = inputs[c][s] * gain;
}
}
diff --git a/TemplateProject/TemplateProject.h b/TemplateProject/TemplateProject.h
@@ -4,26 +4,33 @@
const int kNumPresets = 1;
-enum EParams { kParamGain = 0, kNumParams };
+enum EParams
+{
+ kParamGain = 0,
+ kNumParams
+};
-enum ECtrlTags { kCtrlTagVersionNumber = 0, kCtrlTagSlider, kCtrlTagTitle };
+enum ECtrlTags
+{
+ kCtrlTagVersionNumber = 0,
+ kCtrlTagSlider,
+ kCtrlTagTitle
+};
using namespace iplug;
using namespace igraphics;
-class TemplateProject final : public Plugin {
+class TemplateProject final : public Plugin
+{
public:
- TemplateProject(const InstanceInfo &info);
+ TemplateProject(const InstanceInfo& info);
#if IPLUG_EDITOR
void OnParentWindowResize(int width, int height) override;
- bool OnHostRequestingSupportedViewConfiguration(int width,
- int height) override {
- return true;
- }
+ bool OnHostRequestingSupportedViewConfiguration(int width, int height) override { return true; }
#endif
#if IPLUG_DSP // http://bit.ly/2S64BDd
- void ProcessBlock(sample **inputs, sample **outputs, int nFrames) override;
+ void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override;
#endif
};
diff --git a/TemplateProject/resources/TemplateProjectAU.h b/TemplateProject/resources/TemplateProjectAU.h
@@ -1,9 +1,9 @@
#include <TargetConditionals.h>
#if TARGET_OS_IOS == 1
-#import <UIKit/UIKit.h>
+ #import <UIKit/UIKit.h>
#else
-#import <Cocoa/Cocoa.h>
+ #import <Cocoa/Cocoa.h>
#endif
#define IPLUG_AUVIEWCONTROLLER IPlugAUViewController_vTemplateProject
diff --git a/TemplateProject/resources/resource.h b/TemplateProject/resources/resource.h
@@ -35,10 +35,10 @@
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 105
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1011
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
+ #ifndef APSTUDIO_READONLY_SYMBOLS
+ #define _APS_NEXT_RESOURCE_VALUE 105
+ #define _APS_NEXT_COMMAND_VALUE 40001
+ #define _APS_NEXT_CONTROL_VALUE 1011
+ #define _APS_NEXT_SYMED_VALUE 101
+ #endif
#endif
diff --git a/format.bash b/format.bash
@@ -6,7 +6,7 @@
echo "Formatting..."
-git ls-files "*.h" "*.cpp" | xargs clang-format --style=llvm -i
+git ls-files "*.h" "*.cpp" | xargs clang-format -i .
echo "Formatting complete!"
echo "You can stage all of the files using:"