From 6286a9a3aa72044d1d2e739caa3a48a87ac22bf7 Mon Sep 17 00:00:00 2001 From: jatin Date: Wed, 6 Dec 2023 01:45:07 -0800 Subject: [PATCH] No more anonymous namespaces --- src/BYOD.cpp | 8 +- src/gui/pedalboard/BoardComponent.cpp | 22 +++--- src/gui/pedalboard/BoardViewport.cpp | 8 +- .../cables/CableViewConnectionHelper.cpp | 14 ++-- .../cables/CableViewPortLocationHelper.cpp | 16 ++-- src/gui/pedalboard/editors/KnobsComponent.cpp | 6 +- .../pedalboard/editors/ProcessorEditor.cpp | 6 +- src/gui/toolbar/SettingsButton.cpp | 6 +- src/gui/toolbar/UndoRedoComponent.cpp | 6 +- src/gui/utils/LevelMeterComponent.cpp | 8 +- src/processors/chain/ProcessorChain.cpp | 4 +- .../chain/ProcessorChainStateHelper.cpp | 20 ++--- src/processors/drive/BlondeDrive.cpp | 24 +++--- src/processors/drive/GuitarMLAmp.cpp | 48 ++++++------ src/processors/drive/RONN.cpp | 11 +-- src/processors/drive/Warp.cpp | 6 +- .../drive/big_muff/BigMuffDrive.cpp | 13 ++-- src/processors/drive/junior_b/JuniorB.cpp | 14 ++-- .../drive/king_of_tone/KingOfToneDrive.cpp | 16 ++-- .../drive/muff_clipper/MuffClipper.cpp | 10 +-- .../drive/mxr_distortion/MXRDistortion.cpp | 12 +-- .../drive/waveshaper/Waveshaper.cpp | 14 ++-- src/processors/modulation/Chorus.cpp | 26 +++---- src/processors/modulation/Flanger.cpp | 15 ++-- src/processors/modulation/MIDIModulator.cpp | 12 +-- src/processors/modulation/Panner.cpp | 74 +++++++++---------- src/processors/modulation/ParamModulator.cpp | 32 ++++---- src/processors/modulation/Rotary.cpp | 8 +- src/processors/other/EnvelopeFilter.cpp | 40 +++++----- src/processors/other/LevelDetective.cpp | 32 ++++---- src/processors/other/ShimmerReverb.cpp | 18 ++--- src/processors/other/SmoothReverb.cpp | 32 ++++---- src/processors/other/cry_baby/CryBaby.cpp | 42 +++++------ src/processors/other/cry_baby/CryBabyNDK.cpp | 6 +- .../other/spring_reverb/SpringReverb.cpp | 16 ++-- src/processors/tone/BigMuffTone.cpp | 6 +- src/processors/tone/BlondeTone.cpp | 14 ++-- src/processors/tone/GraphicEQ.cpp | 8 +- src/processors/tone/HighCut.cpp | 6 +- src/processors/tone/LofiIrs.cpp | 26 +++---- src/processors/tone/StateVariableFilter.cpp | 34 ++++----- .../tone/amp_irs/AmpIRsSaveLoad.cpp | 16 ++-- .../tone/amp_irs/AmpIRsSelector.cpp | 14 ++-- src/processors/tone/baxandall/BaxandallEQ.cpp | 10 +-- src/processors/utility/CleanGain.cpp | 48 ++++++------ src/processors/utility/Oscilloscope.cpp | 6 +- src/processors/utility/Tuner.cpp | 6 +- src/state/StateManager.cpp | 6 +- src/state/presets/PresetManager.cpp | 5 -- 49 files changed, 425 insertions(+), 425 deletions(-) diff --git a/src/BYOD.cpp b/src/BYOD.cpp index 04dfff9f..8ad703d3 100644 --- a/src/BYOD.cpp +++ b/src/BYOD.cpp @@ -3,7 +3,7 @@ #include "state/StateManager.h" #include "state/presets/PresetManager.h" -namespace +namespace BYODPaths { const String settingsFilePath = "ChowdhuryDSP/BYOD/.plugin_settings.json"; const String logFileSubDir = "ChowdhuryDSP/BYOD/Logs"; @@ -11,8 +11,8 @@ const String logFileNameRoot = "BYOD_Log_"; } // namespace BYOD::BYOD() : chowdsp::PluginBase (&undoManager), - logger ({ .logFileSubDir = logFileSubDir, - .logFileNameRoot = logFileNameRoot, + logger ({ .logFileSubDir = BYODPaths::logFileSubDir, + .logFileNameRoot = BYODPaths::logFileNameRoot, .crashLogAnalysisCallback = [this] (const File& logFile) { crashLogFile.emplace (logFile); } }), procStore (&undoManager) @@ -23,7 +23,7 @@ BYOD::BYOD() : chowdsp::PluginBase (&undoManager), Logger::writeToLog (chowdsp::PluginDiagnosticInfo::getDiagnosticsString (*this)); - pluginSettings->initialise (settingsFilePath); + pluginSettings->initialise (BYODPaths::settingsFilePath); procs = std::make_unique (procStore, vts, presetManager, paramForwarder, [&] (int l) { updateSampleLatency (l); }); paramForwarder = std::make_unique (vts, *procs); diff --git a/src/gui/pedalboard/BoardComponent.cpp b/src/gui/pedalboard/BoardComponent.cpp index f82133f5..44199d16 100644 --- a/src/gui/pedalboard/BoardComponent.cpp +++ b/src/gui/pedalboard/BoardComponent.cpp @@ -2,7 +2,7 @@ #include "cables/CableViewConnectionHelper.h" #include "processors/chain/ProcessorChainActionHelper.h" -namespace +namespace BoardDims { constexpr int editorWidth = 270; constexpr int editorHeight = 180; @@ -108,12 +108,12 @@ void BoardComponent::resized() const auto width = getWidth(); const auto height = getHeight(); - const auto thisEditorWidth = getScaleDim (editorWidth, scaleFactor); - const auto thisEditorHeight = getScaleDim (editorHeight, scaleFactor); + const auto thisEditorWidth = BoardDims::getScaleDim (BoardDims::editorWidth, scaleFactor); + const auto thisEditorHeight = BoardDims::getScaleDim (BoardDims::editorHeight, scaleFactor); auto centreEditorHeight = (height - thisEditorHeight) / 2; - setEditorPosition (inputEditor.get(), Rectangle (editorPad, centreEditorHeight, thisEditorWidth / 2, thisEditorHeight)); - setEditorPosition (outputEditor.get(), Rectangle (width - (thisEditorWidth / 2 + editorPad), centreEditorHeight, thisEditorWidth / 2, thisEditorHeight)); + setEditorPosition (inputEditor.get(), Rectangle (BoardDims::editorPad, centreEditorHeight, thisEditorWidth / 2, thisEditorHeight)); + setEditorPosition (outputEditor.get(), Rectangle (width - (thisEditorWidth / 2 + BoardDims::editorPad), centreEditorHeight, thisEditorWidth / 2, thisEditorHeight)); for (auto* editor : processorEditors) setEditorPosition (editor); @@ -121,7 +121,7 @@ void BoardComponent::resized() cableView.setBounds (getLocalBounds()); cableView.updateCablePositions(); - newProcButton.setBounds (width - newButtonWidth, 0, newButtonWidth, newButtonWidth); + newProcButton.setBounds (width - BoardDims::newButtonWidth, 0, BoardDims::newButtonWidth, BoardDims::newButtonWidth); infoComp.setBounds (Rectangle (jmin (400, width), jmin (250, height)).withCentre (getLocalBounds().getCentre())); repaint(); @@ -252,14 +252,14 @@ void BoardComponent::showNewProcMenu (PopupMenu& menu, PopupMenu::Options& optio { if (addingFromNewProcButton) { - nextEditorPosition = getRandomPosition (*this); + nextEditorPosition = BoardDims::getRandomPosition (*this); } else { nextEditorPosition = mousePos; - const auto halfEditorWidth = getScaleDim (editorWidth, scaleFactor) / 2; - const auto halfEditorHeight = getScaleDim (editorHeight, scaleFactor) / 2; + const auto halfEditorWidth = BoardDims::getScaleDim (BoardDims::editorWidth, scaleFactor) / 2; + const auto halfEditorHeight = BoardDims::getScaleDim (BoardDims::editorHeight, scaleFactor) / 2; nextEditorPosition.x = jlimit (halfEditorWidth, getWidth() - halfEditorWidth, nextEditorPosition.x); nextEditorPosition.y = jlimit (halfEditorHeight, getHeight() - halfEditorHeight, nextEditorPosition.y); } @@ -301,8 +301,8 @@ ProcessorEditor* BoardComponent::findEditorForProcessor (const BaseProcessor* pr void BoardComponent::setEditorPosition (ProcessorEditor* editor, Rectangle bounds) { - const auto thisEditorWidth = getScaleDim (editorWidth, scaleFactor); - const auto thisEditorHeight = getScaleDim (editorHeight, scaleFactor); + const auto thisEditorWidth = BoardDims::getScaleDim (BoardDims::editorWidth, scaleFactor); + const auto thisEditorHeight = BoardDims::getScaleDim (BoardDims::editorHeight, scaleFactor); auto* proc = editor->getProcPtr(); auto position = proc->getPosition (getBounds()); diff --git a/src/gui/pedalboard/BoardViewport.cpp b/src/gui/pedalboard/BoardViewport.cpp index a5480c56..3035b45f 100644 --- a/src/gui/pedalboard/BoardViewport.cpp +++ b/src/gui/pedalboard/BoardViewport.cpp @@ -1,6 +1,6 @@ #include "BoardViewport.h" -namespace +namespace ViewportTags { const juce::Identifier zoomLevelTag { "zoom_level" }; } @@ -13,9 +13,9 @@ BoardViewport::BoardViewport (AudioProcessorValueTreeState& vts, pluginSettings->addProperties<&BoardViewport::globalSettingChanged> ({ { defaultZoomSettingID, 1.0 }, { portTooltipsSettingID, true } }, *this); - if (! vts.state.hasProperty (zoomLevelTag)) - vts.state.setProperty (zoomLevelTag, pluginSettings->getProperty (defaultZoomSettingID), nullptr); - scaleFactor = vts.state.getPropertyAsValue (zoomLevelTag, nullptr, true); + if (! vts.state.hasProperty (ViewportTags::zoomLevelTag)) + vts.state.setProperty (ViewportTags::zoomLevelTag, pluginSettings->getProperty (defaultZoomSettingID), nullptr); + scaleFactor = vts.state.getPropertyAsValue (ViewportTags::zoomLevelTag, nullptr, true); setScaleFactor ((float) scaleFactor.getValue()); toggleTooltips (pluginSettings->getProperty (portTooltipsSettingID)); diff --git a/src/gui/pedalboard/cables/CableViewConnectionHelper.cpp b/src/gui/pedalboard/cables/CableViewConnectionHelper.cpp index b4cafd07..e29fa700 100644 --- a/src/gui/pedalboard/cables/CableViewConnectionHelper.cpp +++ b/src/gui/pedalboard/cables/CableViewConnectionHelper.cpp @@ -3,7 +3,7 @@ #include "CableViewPortLocationHelper.h" #include "processors/chain/ProcessorChainActionHelper.h" -namespace +namespace CableConnectionMethods { void updateConnectionStatuses (const BoardComponent& board, const ConnectionInfo& connection, bool isConnected) { @@ -42,7 +42,7 @@ CableViewConnectionHelper::CableViewConnectionHelper (CableView& cv, BoardCompon void CableViewConnectionHelper::processorBeingAdded (BaseProcessor* newProc) { ScopedLock sl (cableView.cableMutex); - addConnectionsForProcessor (cables, newProc, board, cableView); + CableConnectionMethods::addConnectionsForProcessor (cables, newProc, board, cableView); } void CableViewConnectionHelper::processorBeingRemoved (const BaseProcessor* proc) @@ -51,7 +51,7 @@ void CableViewConnectionHelper::processorBeingRemoved (const BaseProcessor* proc { if (cables[i]->connectionInfo.startProc == proc || cables[i]->connectionInfo.endProc == proc) { - updateConnectionStatuses (board, cables[i]->connectionInfo, false); + CableConnectionMethods::updateConnectionStatuses (board, cables[i]->connectionInfo, false); ScopedLock sl (cableView.cableMutex); cables.remove (i); } @@ -77,8 +77,8 @@ void CableViewConnectionHelper::refreshConnections() } for (auto* proc : board.procChain.getProcessors()) - addConnectionsForProcessor (cables, proc, board, cableView); - addConnectionsForProcessor (cables, &board.procChain.getInputProcessor(), board, cableView); + CableConnectionMethods::addConnectionsForProcessor (cables, proc, board, cableView); + CableConnectionMethods::addConnectionsForProcessor (cables, &board.procChain.getInputProcessor(), board, cableView); for (auto* cable : cables) { @@ -90,7 +90,7 @@ void CableViewConnectionHelper::refreshConnections() void CableViewConnectionHelper::connectionAdded (const ConnectionInfo& info) { - updateConnectionStatuses (board, info, true); + CableConnectionMethods::updateConnectionStatuses (board, info, true); if (ignoreConnectionCallbacks) return; @@ -102,7 +102,7 @@ void CableViewConnectionHelper::connectionAdded (const ConnectionInfo& info) void CableViewConnectionHelper::connectionRemoved (const ConnectionInfo& info) { - updateConnectionStatuses (board, info, false); + CableConnectionMethods::updateConnectionStatuses (board, info, false); if (ignoreConnectionCallbacks) return; diff --git a/src/gui/pedalboard/cables/CableViewPortLocationHelper.cpp b/src/gui/pedalboard/cables/CableViewPortLocationHelper.cpp index 51aff642..ac8bfa4e 100644 --- a/src/gui/pedalboard/cables/CableViewPortLocationHelper.cpp +++ b/src/gui/pedalboard/cables/CableViewPortLocationHelper.cpp @@ -2,7 +2,7 @@ #include "../BoardComponent.h" #include "CableDrawingHelpers.h" -namespace +namespace CableViewHelperMethods { bool wouldConnectingCreateFeedbackLoop (const BaseProcessor* sourceProc, const BaseProcessor* destProc, const OwnedArray& cables) { @@ -66,13 +66,13 @@ CableView::EditorPort CableViewPortLocationHelper::getNearestInputPort (const ju for (const auto* editor : board.processorEditors) { - if (wouldConnectingCreateFeedbackLoop (sourceProc, editor->getProcPtr(), cables)) + if (CableViewHelperMethods::wouldConnectingCreateFeedbackLoop (sourceProc, editor->getProcPtr(), cables)) continue; // no feedback loops allowed - getClosestPort (pos, editor, minDistance, result, true, cableView.scaleFactor); + CableViewHelperMethods::getClosestPort (pos, editor, minDistance, result, true, cableView.scaleFactor); } - getClosestPort (pos, board.outputEditor.get(), minDistance, result, true, cableView.scaleFactor); + CableViewHelperMethods::getClosestPort (pos, board.outputEditor.get(), minDistance, result, true, cableView.scaleFactor); if (result.editor == nullptr || isInputPortConnected (result)) return {}; @@ -87,12 +87,12 @@ CableView::EditorPort CableViewPortLocationHelper::getNearestPort (const juce::P for (auto* editor : board.processorEditors) { - getClosestPort (pos, editor, minDistance, result, false, cableView.scaleFactor); - getClosestPort (pos, editor, minDistance, result, true, cableView.scaleFactor); + CableViewHelperMethods::getClosestPort (pos, editor, minDistance, result, false, cableView.scaleFactor); + CableViewHelperMethods::getClosestPort (pos, editor, minDistance, result, true, cableView.scaleFactor); } - getClosestPort (pos, board.inputEditor.get(), minDistance, result, false, cableView.scaleFactor); - getClosestPort (pos, board.outputEditor.get(), minDistance, result, true, cableView.scaleFactor); + CableViewHelperMethods::getClosestPort (pos, board.inputEditor.get(), minDistance, result, false, cableView.scaleFactor); + CableViewHelperMethods::getClosestPort (pos, board.outputEditor.get(), minDistance, result, true, cableView.scaleFactor); if (result.editor == nullptr) return {}; diff --git a/src/gui/pedalboard/editors/KnobsComponent.cpp b/src/gui/pedalboard/editors/KnobsComponent.cpp index 69f21bc4..1f78569c 100644 --- a/src/gui/pedalboard/editors/KnobsComponent.cpp +++ b/src/gui/pedalboard/editors/KnobsComponent.cpp @@ -2,7 +2,7 @@ #include "gui/utils/LookAndFeels.h" #include "processors/BaseProcessor.h" -namespace +namespace KnobDims { constexpr float nameHeightScale = 0.115f; } @@ -191,7 +191,7 @@ void KnobsComponent::paint (Graphics& g) { g.setColour (contrastColour.withAlpha (isEnabled() ? 1.0f : 0.6f)); - const auto nameHeight = proportionOfHeight (nameHeightScale); + const auto nameHeight = proportionOfHeight (KnobDims::nameHeightScale); const auto nameOffset = proportionOfHeight (0.157f); auto makeName = [&g, nameHeight, nameOffset] (Component& comp, const String& name, int offset = 0) { @@ -219,7 +219,7 @@ void KnobsComponent::resized() { int totalNumComponents = sliders.size() + boxes.size() + buttons.size() + customComponents.size(); - const auto nameHeight = proportionOfHeight (nameHeightScale); + const auto nameHeight = proportionOfHeight (KnobDims::nameHeightScale); int compHeight = getHeight() - nameHeight; int compWidth = totalNumComponents > 1 ? (getWidth() - 10) / totalNumComponents : compHeight; diff --git a/src/gui/pedalboard/editors/ProcessorEditor.cpp b/src/gui/pedalboard/editors/ProcessorEditor.cpp index 2c5c5ca3..6eedfc09 100644 --- a/src/gui/pedalboard/editors/ProcessorEditor.cpp +++ b/src/gui/pedalboard/editors/ProcessorEditor.cpp @@ -3,7 +3,7 @@ #include "processors/chain/ProcessorChainActionHelper.h" #include "processors/netlist_helpers/CircuitQuantity.h" -namespace +namespace EditorDims { constexpr float cornerSize = 5.0f; } @@ -170,11 +170,11 @@ void ProcessorEditor::paint (Graphics& g) (float) getWidth(), false }; g.setGradientFill (grad); - g.fillRoundedRectangle (getLocalBounds().toFloat(), cornerSize); + g.fillRoundedRectangle (getLocalBounds().toFloat(), EditorDims::cornerSize); if (procUI.backgroundImage != nullptr) { - auto backgroundBounds = getLocalBounds().reduced ((int) cornerSize); + auto backgroundBounds = getLocalBounds().reduced ((int) EditorDims::cornerSize); procUI.backgroundImage->drawWithin (g, backgroundBounds.toFloat(), RectanglePlacement::stretchToFit, 1.0f); } diff --git a/src/gui/toolbar/SettingsButton.cpp b/src/gui/toolbar/SettingsButton.cpp index b18f34be..0bda417c 100644 --- a/src/gui/toolbar/SettingsButton.cpp +++ b/src/gui/toolbar/SettingsButton.cpp @@ -4,7 +4,7 @@ #include "processors/chain/ProcessorChainPortMagnitudesHelper.h" #include "state/ParamForwardManager.h" -namespace +namespace SettingsColours { const Colour onColour = Colours::yellow; const Colour offColour = Colours::white; @@ -101,7 +101,7 @@ void SettingsButton::defaultZoomMenu (PopupMenu& menu, int itemID) item.text = String (int (zoomLevel * 100.0)) + "%"; item.action = [this, zoomLevel] { pluginSettings->setProperty (BoardViewport::defaultZoomSettingID, zoomLevel); }; - item.colour = isWithin (zoomLevel, curDefaultZoomLevel, 0.001) ? onColour : offColour; + item.colour = isWithin (zoomLevel, curDefaultZoomLevel, 0.001) ? SettingsColours::onColour : SettingsColours::offColour; defaultZoomMenu.addItem (item); } @@ -124,7 +124,7 @@ void SettingsButton::addPluginSettingMenuOption (const String& name, const Setti item.text = name; item.action = [this, id, isCurrentlyOn] { pluginSettings->setProperty (id, ! isCurrentlyOn); }; - item.colour = isCurrentlyOn ? onColour : offColour; + item.colour = isCurrentlyOn ? SettingsColours::onColour : SettingsColours::offColour; menu.addItem (item); } diff --git a/src/gui/toolbar/UndoRedoComponent.cpp b/src/gui/toolbar/UndoRedoComponent.cpp index 1f335fe7..fb16e7db 100644 --- a/src/gui/toolbar/UndoRedoComponent.cpp +++ b/src/gui/toolbar/UndoRedoComponent.cpp @@ -1,6 +1,6 @@ #include "UndoRedoComponent.h" -namespace +namespace UndoRedoDims { constexpr int buttonPad = 10; } @@ -59,9 +59,9 @@ void UndoRedoComponent::resized() return rect.withHeight (rect.getWidth()).withCentre ({ rect.getCentreX(), b.getCentreY() }); }; - const auto undoBounds = bounds.removeFromLeft (baseWidth).withTrimmedLeft (buttonPad).withTrimmedRight (buttonPad / 2); + const auto undoBounds = bounds.removeFromLeft (baseWidth).withTrimmedLeft (UndoRedoDims::buttonPad).withTrimmedRight (UndoRedoDims::buttonPad / 2); undoButton.setBounds (makeSquareAndCentreY (undoBounds)); - const auto redoBounds = bounds.removeFromLeft (baseWidth).withTrimmedRight (buttonPad).withTrimmedLeft (buttonPad / 2); + const auto redoBounds = bounds.removeFromLeft (baseWidth).withTrimmedRight (UndoRedoDims::buttonPad).withTrimmedLeft (UndoRedoDims::buttonPad / 2); redoButton.setBounds (makeSquareAndCentreY (redoBounds)); } diff --git a/src/gui/utils/LevelMeterComponent.cpp b/src/gui/utils/LevelMeterComponent.cpp index 3bcb4f89..599cd0ca 100644 --- a/src/gui/utils/LevelMeterComponent.cpp +++ b/src/gui/utils/LevelMeterComponent.cpp @@ -1,6 +1,6 @@ #include "LevelMeterComponent.h" -namespace +namespace LevelMeterConstants { constexpr auto maxDB = 6.0f; constexpr auto minDB = -45.0f; @@ -8,7 +8,7 @@ constexpr auto dBRange = maxDB - minDB; } // namespace LevelMeterComponent::LevelMeterComponent (const LevelDataType& levelData) : rmsLevels (levelData), - dbLevels ({ minDB, minDB }), + dbLevels ({ LevelMeterConstants::minDB, LevelMeterConstants::minDB }), dbLevelsPrev ({ 0.0f, 0.0f }) { constexpr int timerHz = 24; @@ -42,7 +42,7 @@ void LevelMeterComponent::paint (Graphics& g) auto getYForDB = [height] (float dB) { - auto normLevel = jmin (jmax (dB - minDB, 0.0f) / dBRange, 1.0f); + auto normLevel = jmin (jmax (dB - LevelMeterConstants::minDB, 0.0f) / LevelMeterConstants::dBRange, 1.0f); return int ((1.0f - normLevel) * (float) height); }; @@ -62,7 +62,7 @@ void LevelMeterComponent::timerCallback() { dbLevels[ch] = Decibels::gainToDecibels (levelDetector[ch].processSample (rmsLevels[ch])); - if (std::abs (dbLevels[ch] - dbLevelsPrev[ch]) > 0.5f && dbLevels[ch] > minDB && dbLevelsPrev[ch] > minDB) + if (std::abs (dbLevels[ch] - dbLevelsPrev[ch]) > 0.5f && dbLevels[ch] > LevelMeterConstants::minDB && dbLevelsPrev[ch] > LevelMeterConstants::minDB) { dbLevelsPrev[ch] = dbLevels[ch]; needsRepaint = true; diff --git a/src/processors/chain/ProcessorChain.cpp b/src/processors/chain/ProcessorChain.cpp index 7fdb0255..5b687834 100644 --- a/src/processors/chain/ProcessorChain.cpp +++ b/src/processors/chain/ProcessorChain.cpp @@ -4,7 +4,7 @@ #include "ProcessorChainStateHelper.h" #include "processors/chain/ChainIOProcessor.h" -namespace +namespace ChainHelperFuncs { [[maybe_unused]] void printBufferLevels (const AudioBuffer& buffer) { @@ -199,7 +199,7 @@ void ProcessorChain::processAudio (AudioBuffer& buffer, const MidiBuffer& } bool outProcessed = false; - const auto& processMidiBuffer = getMidiBufferToUse (hostMidiBuffer, internalMidiBuffer, ioProcessor.getOversamplingFactor()); + const auto& processMidiBuffer = ChainHelperFuncs::getMidiBufferToUse (hostMidiBuffer, internalMidiBuffer, ioProcessor.getOversamplingFactor()); for (auto* processor : procs) { diff --git a/src/processors/chain/ProcessorChainStateHelper.cpp b/src/processors/chain/ProcessorChainStateHelper.cpp index 9c48a70e..ffc68348 100644 --- a/src/processors/chain/ProcessorChainStateHelper.cpp +++ b/src/processors/chain/ProcessorChainStateHelper.cpp @@ -3,7 +3,7 @@ #include "state/ParamForwardManager.h" #include "state/presets/PresetManager.h" -namespace +namespace ChainStateHelperFuncs { String getPortTag (int portIdx) { @@ -70,7 +70,7 @@ std::unique_ptr ProcessorChainStateHelper::saveProcChain() auto saveProcessor = [&] (BaseProcessor* proc) { - auto procXml = std::make_unique (getProcessorTagName (proc)); + auto procXml = std::make_unique (ChainStateHelperFuncs::getProcessorTagName (proc)); procXml->addChildElement (proc->toXML().release()); for (int portIdx = 0; portIdx < proc->getNumOutputs(); ++portIdx) @@ -79,7 +79,7 @@ std::unique_ptr ProcessorChainStateHelper::saveProcChain() if (numOutputs == 0) continue; - auto portElement = std::make_unique (getPortTag (portIdx)); + auto portElement = std::make_unique (ChainStateHelperFuncs::getPortTag (portIdx)); for (int cIdx = 0; cIdx < numOutputs; ++cIdx) { auto& connection = proc->getOutputConnection (portIdx, cIdx); @@ -91,8 +91,8 @@ std::unique_ptr ProcessorChainStateHelper::saveProcChain() jassert (connection.endProc == &chain.outputProcessor); } - portElement->setAttribute (getConnectionTag (cIdx), processorIdx); - portElement->setAttribute (getConnectionEndTag (cIdx), connection.endPort); + portElement->setAttribute (ChainStateHelperFuncs::getConnectionTag (cIdx), processorIdx); + portElement->setAttribute (ChainStateHelperFuncs::getConnectionEndTag (cIdx), connection.endPort); } procXml->addChildElement (portElement.release()); @@ -142,14 +142,14 @@ void ProcessorChainStateHelper::loadProcChainInternal (const XmlElement* xml, ProcConnectionMap connectionMap; for (int portIdx = 0; portIdx < newProc->getNumOutputs(); ++portIdx) { - if (auto* portElement = procXml->getChildByName (getPortTag (portIdx))) + if (auto* portElement = procXml->getChildByName (ChainStateHelperFuncs::getPortTag (portIdx))) { auto numConnections = portElement->getNumAttributes() / 2; PortMap portConnections (numConnections); for (int cIdx = 0; cIdx < numConnections; ++cIdx) { - auto processorIdx = portElement->getIntAttribute (getConnectionTag (cIdx)); - auto endPort = portElement->getIntAttribute (getConnectionEndTag (cIdx)); + auto processorIdx = portElement->getIntAttribute (ChainStateHelperFuncs::getConnectionTag (cIdx)); + auto endPort = portElement->getIntAttribute (ChainStateHelperFuncs::getConnectionEndTag (cIdx)); portConnections[cIdx] = std::make_pair (processorIdx, endPort); } @@ -174,7 +174,7 @@ void ProcessorChainStateHelper::loadProcChainInternal (const XmlElement* xml, continue; } - const auto procName = getProcessorName (procXml->getTagName()); + const auto procName = ChainStateHelperFuncs::getProcessorName (procXml->getTagName()); if (procName == chain.inputProcessor.getName()) { loadProcessorState (procXml, &chain.inputProcessor, connectionMaps, ! loadingPreset); @@ -255,7 +255,7 @@ bool ProcessorChainStateHelper::validateProcChainState (const XmlElement* xml, c for (auto* procXml : xml->getChildIterator()) { - const auto procName = getProcessorName (procXml->getTagName()); + const auto procName = ChainStateHelperFuncs::getProcessorName (procXml->getTagName()); if (procName == chowdsp::toString (InputProcessor::name) || procName == chowdsp::toString (OutputProcessor::name)) continue; diff --git a/src/processors/drive/BlondeDrive.cpp b/src/processors/drive/BlondeDrive.cpp index 15484a22..4aa3651d 100644 --- a/src/processors/drive/BlondeDrive.cpp +++ b/src/processors/drive/BlondeDrive.cpp @@ -1,7 +1,7 @@ #include "BlondeDrive.h" #include "../ParameterHelpers.h" -namespace +namespace BlondeDriveTags { const String driveTag = "drive"; const String characterTag = "char"; @@ -81,16 +81,16 @@ void processDrive (double* left, double* right, const double* A, xsimd::batch (vts, driveTag)); + driveParamSmooth.setParameterHandle (getParameterPointer (vts, BlondeDriveTags::driveTag)); driveParamSmooth.mappingFunction = [] (float x) { return 1.0f - x; }; - biasParamSmooth.setParameterHandle (getParameterPointer (vts, biasTag)); + biasParamSmooth.setParameterHandle (getParameterPointer (vts, BlondeDriveTags::biasTag)); biasParamSmooth.mappingFunction = [] (float x) { return x * 0.5f; }; @@ -105,10 +105,10 @@ ParamLayout BlondeDrive::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - createPercentParameter (params, driveTag, "Drive", 0.5f); - createBipolarPercentParameter (params, characterTag, "Character", 0.0f); - createPercentParameter (params, biasTag, "Bias", 0.5f); - emplace_param (params, hiQTag, "High Quality", false); + createPercentParameter (params, BlondeDriveTags::driveTag, "Drive", 0.5f); + createBipolarPercentParameter (params, BlondeDriveTags::characterTag, "Character", 0.0f); + createPercentParameter (params, BlondeDriveTags::biasTag, "Bias", 0.5f); + emplace_param (params, BlondeDriveTags::hiQTag, "High Quality", false); return { params.begin(), params.end() }; } @@ -163,9 +163,9 @@ void BlondeDrive::processAudio (AudioBuffer& buffer) auto* rightData = doubleBuffer.getWritePointer (1 % numChannels); if (hiQParam->get()) - processDrive<12> (leftData, rightData, driveData, state, numSamples); + BlondeDriveTags::processDrive<12> (leftData, rightData, driveData, state, numSamples); else - processDrive (leftData, rightData, driveData, state, numSamples); + BlondeDriveTags::processDrive (leftData, rightData, driveData, state, numSamples); buffer.makeCopyOf (doubleBuffer, true); diff --git a/src/processors/drive/GuitarMLAmp.cpp b/src/processors/drive/GuitarMLAmp.cpp index 16fb631a..2ce68cec 100644 --- a/src/processors/drive/GuitarMLAmp.cpp +++ b/src/processors/drive/GuitarMLAmp.cpp @@ -2,7 +2,7 @@ #include "gui/utils/ErrorMessageView.h" #include "gui/utils/ModulatableSlider.h" -namespace +namespace RONNTags { const juce::StringArray guitarMLModelResources { "BluesJrAmp_VolKnob_json", @@ -29,10 +29,10 @@ constexpr std::string_view modelNameTag = "byod_guitarml_model_name"; GuitarMLAmp::GuitarMLAmp (UndoManager* um) : BaseProcessor ("GuitarML", createParameterLayout(), um) { using namespace ParameterHelpers; - loadParameterPointer (gainParam, vts, gainTag); - conditionParam.setParameterHandle (getParameterPointer (vts, conditionTag)); - loadParameterPointer (sampleRateCorrectionFilterParam, vts, sampleRateCorrFilterTag); - addPopupMenuParameter (sampleRateCorrFilterTag); + loadParameterPointer (gainParam, vts, RONNTags::gainTag); + conditionParam.setParameterHandle (getParameterPointer (vts, RONNTags::conditionTag)); + loadParameterPointer (sampleRateCorrectionFilterParam, vts, RONNTags::sampleRateCorrFilterTag); + addPopupMenuParameter (RONNTags::sampleRateCorrFilterTag); loadModel (0); // load Blues Jr. model by default @@ -61,9 +61,9 @@ ParamLayout GuitarMLAmp::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - createGainDBParameter (params, gainTag, "Gain", -18.0f, 18.0f, 0.0f); - createPercentParameter (params, conditionTag, "Condition", 0.5f); - emplace_param (params, sampleRateCorrFilterTag, "Sample Rate Correction Filter", true); + createGainDBParameter (params, RONNTags::gainTag, "Gain", -18.0f, 18.0f, 0.0f); + createPercentParameter (params, RONNTags::conditionTag, "Condition", 0.5f); + emplace_param (params, RONNTags::sampleRateCorrFilterTag, "Sample Rate Correction Filter", true); return { params.begin(), params.end() }; } @@ -121,7 +121,7 @@ void GuitarMLAmp::loadModelFromJson (const chowdsp::json& modelJson, const Strin cachedModel = modelJson; if (newModelName.isNotEmpty()) - cachedModel[modelNameTag] = newModelName; + cachedModel[RONNTags::modelNameTag] = newModelName; modelChangeBroadcaster(); } @@ -130,14 +130,14 @@ void GuitarMLAmp::loadModel (int modelIndex, Component* parentComponent) { normalizationGain = 1.0f; - if (juce::isPositiveAndBelow (modelIndex, numBuiltInModels)) + if (juce::isPositiveAndBelow (modelIndex, RONNTags::numBuiltInModels)) { int modelDataSize = 0; - const auto* modelData = BinaryData::getNamedResource (guitarMLModelResources[modelIndex].toRawUTF8(), modelDataSize); + const auto* modelData = BinaryData::getNamedResource (RONNTags::guitarMLModelResources[modelIndex].toRawUTF8(), modelDataSize); jassert (modelData != nullptr); const auto modelJson = chowdsp::JSONUtils::fromBinaryData (modelData, modelDataSize); - loadModelFromJson (modelJson, guitarMLModelNames[modelIndex]); + loadModelFromJson (modelJson, RONNTags::guitarMLModelNames[modelIndex]); // The Mesa model is a bit loud, so let's normalize the level down a bit // Eventually it would be good to do this sort of thing programmatically. @@ -145,7 +145,7 @@ void GuitarMLAmp::loadModel (int modelIndex, Component* parentComponent) if (modelIndex == 2) normalizationGain = 0.5f; } - else if (modelIndex == numBuiltInModels) + else if (modelIndex == RONNTags::numBuiltInModels) { customModelChooser = std::make_shared ("GuitarML Model", File {}, "*.json", true, false, parentComponent); customModelChooser->launchAsync (FileBrowserComponent::FileChooserFlags::canSelectFiles, @@ -200,7 +200,7 @@ void GuitarMLAmp::loadModel (int modelIndex, Component* parentComponent) String GuitarMLAmp::getCurrentModelName() const { - return cachedModel.value (modelNameTag, ""); + return cachedModel.value (RONNTags::modelNameTag, ""); } void GuitarMLAmp::prepare (double sampleRate, int samplesPerBlock) @@ -275,14 +275,14 @@ void GuitarMLAmp::processAudio (AudioBuffer& buffer) std::unique_ptr GuitarMLAmp::toXML() { auto xml = BaseProcessor::toXML(); - xml->setAttribute (customModelTag, cachedModel.dump()); + xml->setAttribute (RONNTags::customModelTag, cachedModel.dump()); return std::move (xml); } void GuitarMLAmp::fromXML (XmlElement* xml, const chowdsp::Version& version, bool loadPosition) { - const auto modelJsonString = xml->getStringAttribute (customModelTag, {}); + const auto modelJsonString = xml->getStringAttribute (RONNTags::customModelTag, {}); try { const auto& modelJson = chowdsp::json::parse (modelJsonString.toStdString()); @@ -314,10 +314,10 @@ bool GuitarMLAmp::getCustomComponents (OwnedArray& customComps, chowd ModelChangeBroadcaster& modelChangeCaster, chowdsp::HostContextProvider& hcp) : currentModelArch (modelArchitecture), - gainSlider (*getParameterPointer (vts, gainTag), hcp), - conditionSlider (*getParameterPointer (vts, conditionTag), hcp), - gainAttach (vts, gainTag, gainSlider), - conditionAttach (vts, conditionTag, conditionSlider) + gainSlider (*getParameterPointer (vts, RONNTags::gainTag), hcp), + conditionSlider (*getParameterPointer (vts, RONNTags::conditionTag), hcp), + gainAttach (vts, RONNTags::gainTag, gainSlider), + conditionAttach (vts, RONNTags::conditionTag, conditionSlider) { for (auto* s : { &gainSlider, &conditionSlider }) addChildComponent (s); @@ -327,7 +327,7 @@ bool GuitarMLAmp::getCustomComponents (OwnedArray& customComps, chowd modelChangeCallback = modelChangeCaster.connect<&MainParamSlider::updateSliderVisibility> (this); - this->setName (conditionTag + "__" + gainTag + "__"); + Component::setName (RONNTags::conditionTag + "__" + RONNTags::gainTag + "__"); } void colourChanged() override @@ -389,9 +389,9 @@ bool GuitarMLAmp::getCustomComponents (OwnedArray& customComps, chowd public: ModelChoiceBox (GuitarMLAmp& processor, ModelChangeBroadcaster& modelChangeCaster) { - addItemList (guitarMLModelNames, 1); + addItemList (RONNTags::guitarMLModelNames, 1); addSeparator(); - addItem ("Custom", guitarMLModelNames.size() + 1); + addItem ("Custom", RONNTags::guitarMLModelNames.size() + 1); setText (processor.getCurrentModelName(), dontSendNotification); modelChangeCallback = modelChangeCaster.connect ([this, &processor] @@ -402,7 +402,7 @@ bool GuitarMLAmp::getCustomComponents (OwnedArray& customComps, chowd processor.loadModel (getSelectedItemIndex(), getTopLevelComponent()); }; - this->setName (modelTag + "__box"); + Component::setName (RONNTags::modelTag + "__box"); } void visibilityChanged() override diff --git a/src/processors/drive/RONN.cpp b/src/processors/drive/RONN.cpp index 555b56b2..4bc7f40f 100644 --- a/src/processors/drive/RONN.cpp +++ b/src/processors/drive/RONN.cpp @@ -1,6 +1,6 @@ #include "RONN.h" -namespace +namespace RONNRandom { int randomSeeds[5] = { 1, 101, 2048, 5005, 9001 }; @@ -114,7 +114,7 @@ ParamLayout RONN::createParameterLayout() createGainDBParameter (params, "gain_db", "Gain", -12.0f, 12.0f, 0.0f); StringArray seeds; - for (int sInt : randomSeeds) + for (int sInt : RONNRandom::randomSeeds) seeds.add (String (sInt)); params.push_back (std::make_unique ("seed", "Random Seed", seeds, 0)); @@ -127,7 +127,7 @@ void RONN::parameterChanged (const String& parameterID, float newValue) return; auto seedIdx = int (newValue); - reloadModel (randomSeeds[seedIdx]); + reloadModel (RONNRandom::randomSeeds[seedIdx]); needsPrebuffering = true; } @@ -136,8 +136,9 @@ void RONN::reloadModel (int randomSeed) // set up random distributions std::default_random_engine generator ((std::default_random_engine::result_type) randomSeed); static std::normal_distribution normal (0.0f, 0.05f); - static Orthogonal ortho; - static GlorotUniform glorot; + using namespace RONNRandom; + static RONNRandom::Orthogonal ortho; + static RONNRandom::GlorotUniform glorot; auto denseInWeights = createRandomVec2 (generator, normal, 8, 1); auto denseInBias = createRandomVec (generator, normal, 8); diff --git a/src/processors/drive/Warp.cpp b/src/processors/drive/Warp.cpp index 4a26b00e..0898f19a 100644 --- a/src/processors/drive/Warp.cpp +++ b/src/processors/drive/Warp.cpp @@ -1,7 +1,7 @@ #include "Warp.h" #include "../ParameterHelpers.h" -namespace +namespace WarpFuncs { inline float f_NL (float x, float fbDrive) noexcept { @@ -104,14 +104,14 @@ void Warp::processAudio (AudioBuffer& buffer) { const auto freqHz = freqHzSmooth[ch].getNextValue(); const auto gainDB = gainDBSmooth[ch].getNextValue(); - filt.biquad.calcCoefs (freqHz, calcQ (gainDB), Decibels::decibelsToGain (gainDB), fs); + filt.biquad.calcCoefs (freqHz, WarpFuncs::calcQ (gainDB), Decibels::decibelsToGain (gainDB), fs); filt.fbMult = fbSmooth[ch].getNextValue(); filt.driveAmt = 0.1f * (freqHz / fs) * (96000.0f / 500.0f); }; auto processSample = [] (float x, float fbDrive, auto& f) { - auto [y0, y1] = newton_raphson<4> (x, f.y1, f.biquad.b[0], f.biquad.z[1], f.fbMult, fbDrive); + auto [y0, y1] = WarpFuncs::newton_raphson<4> (x, f.y1, f.biquad.b[0], f.biquad.z[1], f.fbMult, fbDrive); f.biquad.processSample (y0, f.driveAmt); f.y1 = y1; diff --git a/src/processors/drive/big_muff/BigMuffDrive.cpp b/src/processors/drive/big_muff/BigMuffDrive.cpp index 85130621..7eb50fb5 100644 --- a/src/processors/drive/big_muff/BigMuffDrive.cpp +++ b/src/processors/drive/big_muff/BigMuffDrive.cpp @@ -1,7 +1,7 @@ #include "BigMuffDrive.h" #include "../../ParameterHelpers.h" -namespace +namespace BigMuffDriveRanges { const auto cutoffRange = ParameterHelpers::createNormalisableRange (500.0f, 22000.0f, 1200.0f); float harmParamToCutoffHz (float harmParam) @@ -11,7 +11,7 @@ float harmParamToCutoffHz (float harmParam) const auto sustainRange = ParameterHelpers::createNormalisableRange (0.4f, 2.0f, 1.0f); const auto levelRange = ParameterHelpers::createNormalisableRange (-60.0f, 0.0f, -9.0f); -} // namespace +} // namespace BigMuffDriveRanges BigMuffDrive::BigMuffDrive (UndoManager* um) : BaseProcessor ("Muff Drive", createParameterLayout(), um) { @@ -53,7 +53,7 @@ void BigMuffDrive::prepare (double sampleRate, int samplesPerBlock) fs = (float) sampleRate; cutoffSmooth.reset (sampleRate, 0.02); - cutoffSmooth.setCurrentAndTargetValue (harmParamToCutoffHz (*harmParam)); + cutoffSmooth.setCurrentAndTargetValue (BigMuffDriveRanges::harmParamToCutoffHz (*harmParam)); for (auto& filt : inputFilter) { filt.calcCoefs (cutoffSmooth.getTargetValue(), fs); @@ -104,7 +104,7 @@ void BigMuffDrive::processInputStage (AudioBuffer& buffer) const auto numChannels = buffer.getNumChannels(); const auto numSamples = buffer.getNumSamples(); - cutoffSmooth.setTargetValue (harmParamToCutoffHz (*harmParam)); + cutoffSmooth.setTargetValue (BigMuffDriveRanges::harmParamToCutoffHz (*harmParam)); if (cutoffSmooth.isSmoothing()) { if (numChannels == 1) @@ -141,7 +141,7 @@ void BigMuffDrive::processInputStage (AudioBuffer& buffer) } } - sustainGain.setGainLinear (sustainRange.convertFrom0to1 (*sustainParam)); + sustainGain.setGainLinear (BigMuffDriveRanges::sustainRange.convertFrom0to1 (*sustainParam)); dsp::AudioBlock block { buffer }; sustainGain.process (dsp::ProcessContextReplacing { block }); } @@ -176,7 +176,8 @@ void BigMuffDrive::processAudio (AudioBuffer& buffer) for (int ch = 0; ch < numChannels; ++ch) dcBlocker[ch].processBlock (buffer.getWritePointer (ch), numSamples); - auto outGain = Decibels::decibelsToGain (levelRange.convertFrom0to1 (*levelParam), levelRange.start); + auto outGain = Decibels::decibelsToGain (BigMuffDriveRanges::levelRange.convertFrom0to1 (*levelParam), + BigMuffDriveRanges::levelRange.start); outGain *= Decibels::decibelsToGain (13.0f); // makeup from level lost in clipping stages outGain *= numStages % 2 == 0 ? 1.0f : -1.0f; outLevel.setGainLinear (outGain); diff --git a/src/processors/drive/junior_b/JuniorB.cpp b/src/processors/drive/junior_b/JuniorB.cpp index 79771d56..6a5c28a0 100644 --- a/src/processors/drive/junior_b/JuniorB.cpp +++ b/src/processors/drive/junior_b/JuniorB.cpp @@ -1,7 +1,7 @@ #include "JuniorB.h" #include "processors/ParameterHelpers.h" -namespace +namespace JuniorBTags { const String driveTag = "juniorb_drive"; const String blendTag = "juniorb_blend"; @@ -11,9 +11,9 @@ const String stagesTag = "juniorb_nstages"; JuniorB::JuniorB (UndoManager* um) : BaseProcessor ("Junior B", createParameterLayout(), um) { using namespace chowdsp::ParamUtils; - loadParameterPointer (driveParamPct, vts, driveTag); - loadParameterPointer (blendParamPct, vts, blendTag); - loadParameterPointer (stagesParam, vts, stagesTag); + loadParameterPointer (driveParamPct, vts, JuniorBTags::driveTag); + loadParameterPointer (blendParamPct, vts, JuniorBTags::blendTag); + loadParameterPointer (stagesParam, vts, JuniorBTags::stagesTag); uiOptions.backgroundColour = Colours::slategrey.darker (0.2f); uiOptions.info.description = "Virtual analog emulation first stage from the Fender Pro-Junior Amplifier."; @@ -25,9 +25,9 @@ ParamLayout JuniorB::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - createPercentParameter (params, driveTag, "Tube Drive", 0.5f); - createPercentParameter (params, blendTag, "Tube Blend", 1.0f); - emplace_param (params, stagesTag, "Stages", StringArray { "1 Stage", "2 Stages", "3 Stages", "4 Stages" }, 1); + createPercentParameter (params, JuniorBTags::driveTag, "Tube Drive", 0.5f); + createPercentParameter (params, JuniorBTags::blendTag, "Tube Blend", 1.0f); + emplace_param (params, JuniorBTags::stagesTag, "Stages", StringArray { "1 Stage", "2 Stages", "3 Stages", "4 Stages" }, 1); return { params.begin(), params.end() }; } diff --git a/src/processors/drive/king_of_tone/KingOfToneDrive.cpp b/src/processors/drive/king_of_tone/KingOfToneDrive.cpp index fc16b9e2..5edbc0a6 100644 --- a/src/processors/drive/king_of_tone/KingOfToneDrive.cpp +++ b/src/processors/drive/king_of_tone/KingOfToneDrive.cpp @@ -1,7 +1,7 @@ #include "KingOfToneDrive.h" #include "processors/netlist_helpers/CircuitQuantity.h" -namespace +namespace ToneKingCoeffs { template void calcDriveAmpCoefs (FilterType& filter, float driveParam, float fs, const KingOfToneDrive::Components& components) @@ -113,7 +113,7 @@ KingOfToneDrive::KingOfToneDrive (UndoManager* um) : BaseProcessor ("Tone King", { components.R9 = self.value.load(); for (auto& filt : overdriveStageBypass) - calcDriveStageBypassedCoefs (filt, fs, components); + ToneKingCoeffs::calcDriveStageBypassedCoefs (filt, fs, components); for (auto& wdf : overdrive) wdf.R9_C7_Vin.setResistanceValue (components.R9); }, @@ -126,7 +126,7 @@ KingOfToneDrive::KingOfToneDrive (UndoManager* um) : BaseProcessor ("Tone King", { components.R10 = self.value.load(); for (auto& filt : overdriveStageBypass) - calcDriveStageBypassedCoefs (filt, fs, components); + ToneKingCoeffs::calcDriveStageBypassedCoefs (filt, fs, components); for (auto& wdf : overdrive) wdf.R10.setResistanceValue (components.R10); }, @@ -198,7 +198,7 @@ KingOfToneDrive::KingOfToneDrive (UndoManager* um) : BaseProcessor ("Tone King", { components.C7 = self.value.load(); for (auto& filt : overdriveStageBypass) - calcDriveStageBypassedCoefs (filt, fs, components); + ToneKingCoeffs::calcDriveStageBypassedCoefs (filt, fs, components); for (auto& wdf : overdrive) wdf.R9_C7_Vin.setCapacitanceValue (components.C7); }, @@ -231,7 +231,7 @@ void KingOfToneDrive::prepare (double sampleRate, int samplesPerBlock) for (auto& filt : driveAmp) { filt.reset(); - calcDriveAmpCoefs (filt, *driveParam, fs, components); + ToneKingCoeffs::calcDriveAmpCoefs (filt, *driveParam, fs, components); } for (auto& driveParamSm : driveParamSmooth) @@ -246,7 +246,7 @@ void KingOfToneDrive::prepare (double sampleRate, int samplesPerBlock) for (auto& filt : overdriveStageBypass) { filt.reset(); - calcDriveStageBypassedCoefs (filt, fs, components); + ToneKingCoeffs::calcDriveStageBypassedCoefs (filt, fs, components); } dcBlocker.prepare (sampleRate, samplesPerBlock); @@ -295,14 +295,14 @@ void KingOfToneDrive::processAudio (AudioBuffer& buffer) driveParamSmooth[ch].setTargetValue (*driveParam); if (! driveParamSmooth[ch].isSmoothing()) { - calcDriveAmpCoefs (driveAmp[ch], driveParamSmooth[ch].getNextValue(), fs, components); + ToneKingCoeffs::calcDriveAmpCoefs (driveAmp[ch], driveParamSmooth[ch].getNextValue(), fs, components); driveAmp[ch].processBlock (x, numSamples); } else { for (int n = 0; n < numSamples; ++n) { - calcDriveAmpCoefs (driveAmp[ch], driveParamSmooth[ch].getNextValue(), fs, components); + ToneKingCoeffs::calcDriveAmpCoefs (driveAmp[ch], driveParamSmooth[ch].getNextValue(), fs, components); x[n] = driveAmp[ch].processSample (x[n]); } } diff --git a/src/processors/drive/muff_clipper/MuffClipper.cpp b/src/processors/drive/muff_clipper/MuffClipper.cpp index 8dd19153..7fe77f9f 100644 --- a/src/processors/drive/muff_clipper/MuffClipper.cpp +++ b/src/processors/drive/muff_clipper/MuffClipper.cpp @@ -1,7 +1,7 @@ #include "MuffClipper.h" #include "../../ParameterHelpers.h" -namespace +namespace MuffClipperRanges { const auto cutoffRange = ParameterHelpers::createNormalisableRange (500.0f, 22000.0f, 1200.0f); float harmParamToCutoffHz (float harmParam) @@ -55,7 +55,7 @@ void MuffClipper::prepare (double sampleRate, int samplesPerBlock) fs = (float) sampleRate; cutoffSmooth.reset (sampleRate, 0.02); - cutoffSmooth.setCurrentAndTargetValue (harmParamToCutoffHz (*harmParam)); + cutoffSmooth.setCurrentAndTargetValue (MuffClipperRanges::harmParamToCutoffHz (*harmParam)); for (auto& filt : inputFilter) { filt.calcCoefs (cutoffSmooth.getTargetValue(), fs); @@ -118,7 +118,7 @@ void MuffClipper::processInputStage (AudioBuffer& buffer) const auto numChannels = buffer.getNumChannels(); const auto numSamples = buffer.getNumSamples(); - cutoffSmooth.setTargetValue (harmParamToCutoffHz (*harmParam)); + cutoffSmooth.setTargetValue (MuffClipperRanges::harmParamToCutoffHz (*harmParam)); if (cutoffSmooth.isSmoothing()) { if (numChannels == 1) @@ -155,7 +155,7 @@ void MuffClipper::processInputStage (AudioBuffer& buffer) } } - sustainGain.setGainLinear (sustainRange.convertFrom0to1 (*sustainParam)); + sustainGain.setGainLinear (MuffClipperRanges::sustainRange.convertFrom0to1 (*sustainParam)); dsp::AudioBlock block { buffer }; sustainGain.process (dsp::ProcessContextReplacing { block }); } @@ -183,7 +183,7 @@ void MuffClipper::processAudio (AudioBuffer& buffer) for (int ch = 0; ch < numChannels; ++ch) dcBlocker[ch].processBlock (buffer.getWritePointer (ch), numSamples); - auto outGain = Decibels::decibelsToGain (levelRange.convertFrom0to1 (*levelParam), levelRange.start); + auto outGain = Decibels::decibelsToGain (MuffClipperRanges::levelRange.convertFrom0to1 (*levelParam), MuffClipperRanges::levelRange.start); outGain *= Decibels::decibelsToGain (13.0f); // makeup from level lost in clipping stage outGain *= -1.0f; outLevel.setGainLinear (outGain); diff --git a/src/processors/drive/mxr_distortion/MXRDistortion.cpp b/src/processors/drive/mxr_distortion/MXRDistortion.cpp index d17755f0..851253a7 100644 --- a/src/processors/drive/mxr_distortion/MXRDistortion.cpp +++ b/src/processors/drive/mxr_distortion/MXRDistortion.cpp @@ -1,12 +1,11 @@ #include "MXRDistortion.h" #include "processors/netlist_helpers/CircuitQuantity.h" -using namespace ParameterHelpers; - -namespace +namespace MXRDistortionParams { float paramSkew (float paramVal) { + using namespace ParameterHelpers; return 1.0f - iLogPot (iLogPot (0.5f * paramVal + 0.5f)); } @@ -119,6 +118,7 @@ MXRDistortion::MXRDistortion (UndoManager* um) : BaseProcessor ("Distortion Plus ParamLayout MXRDistortion::createParameterLayout() { + using namespace ParameterHelpers; auto params = createBaseParams(); createPercentParameter (params, "dist", "Distortion", 0.5f); createPercentParameter (params, "level", "Level", 0.5f); @@ -131,7 +131,7 @@ void MXRDistortion::prepare (double sampleRate, int samplesPerBlock) for (auto& wdfProc : wdf) { wdfProc.prepare (sampleRate); - wdfProc.setParams (paramSkew (*distParam)); + wdfProc.setParams (MXRDistortionParams::paramSkew (*distParam)); } dcBlocker.prepare (sampleRate, samplesPerBlock); @@ -156,7 +156,7 @@ void MXRDistortion::processAudio (AudioBuffer& buffer) for (int ch = 0; ch < buffer.getNumChannels(); ++ch) { - wdf[ch].setParams (paramSkew (*distParam)); + wdf[ch].setParams (MXRDistortionParams::paramSkew (*distParam)); auto* x = buffer.getWritePointer (ch); for (int n = 0; n < buffer.getNumSamples(); ++n) @@ -165,6 +165,6 @@ void MXRDistortion::processAudio (AudioBuffer& buffer) dcBlocker.processAudio (buffer); - gain.setGainLinear (Decibels::decibelsToGain (levelSkew.convertFrom0to1 (*levelParam), levelSkew.start)); + gain.setGainLinear (Decibels::decibelsToGain (MXRDistortionParams::levelSkew.convertFrom0to1 (*levelParam), MXRDistortionParams::levelSkew.start)); gain.process (context); } diff --git a/src/processors/drive/waveshaper/Waveshaper.cpp b/src/processors/drive/waveshaper/Waveshaper.cpp index a4421462..c53faeeb 100644 --- a/src/processors/drive/waveshaper/Waveshaper.cpp +++ b/src/processors/drive/waveshaper/Waveshaper.cpp @@ -1,7 +1,7 @@ #include "Waveshaper.h" #include "../../ParameterHelpers.h" -namespace +namespace WaveshaperTags { const String shapeTag = "shape"; } @@ -11,7 +11,7 @@ using namespace SurgeWaveshapers; Waveshaper::Waveshaper (UndoManager* um) : BaseProcessor ("Waveshaper", createParameterLayout(), um) { chowdsp::ParamUtils::loadParameterPointer (driveParam, vts, "drive"); - shapeParam = vts.getRawParameterValue (shapeTag); + shapeParam = vts.getRawParameterValue (WaveshaperTags::shapeTag); // borrowed from: https://github.com/surge-synthesizer/surge/blob/main/src/surge-fx/SurgeLookAndFeel.h const Colour surgeOrange = Colour (255, 144, 0); @@ -31,7 +31,7 @@ ParamLayout Waveshaper::createParameterLayout() auto params = createBaseParams(); createGainDBParameter (params, "drive", "Drive", -6.0f, 30.0f, 0.0f); - params.push_back (std::make_unique (shapeTag, "Shape", wst_names, wst_ojd)); + params.push_back (std::make_unique (WaveshaperTags::shapeTag, "Shape", wst_names, wst_ojd)); return { params.begin(), params.end() }; } @@ -159,19 +159,19 @@ bool Waveshaper::getCustomComponents (OwnedArray& customComps, chowds { WaveshapeComboBox (AudioProcessorValueTreeState& vtState, chowdsp::HostContextProvider& hcp) : vts (vtState) { - auto* param = vts.getParameter (shapeTag); + auto* param = vts.getParameter (WaveshaperTags::shapeTag); attachment = std::make_unique (*param, *this, vts.undoManager); - shapeParam = vts.getRawParameterValue (shapeTag); + shapeParam = vts.getRawParameterValue (WaveshaperTags::shapeTag); refreshBox(); hcp.registerParameterComponent (*this, *param); - this->setName (shapeTag + "__box"); + Component::setName (WaveshaperTags::shapeTag + "__box"); } void visibilityChanged() override { - setName (vts.getParameter (shapeTag)->name); + setName (vts.getParameter (WaveshaperTags::shapeTag)->name); } void refreshBox() diff --git a/src/processors/modulation/Chorus.cpp b/src/processors/modulation/Chorus.cpp index 11698255..445b3e2e 100644 --- a/src/processors/modulation/Chorus.cpp +++ b/src/processors/modulation/Chorus.cpp @@ -2,16 +2,8 @@ #include "../BufferHelpers.h" #include "../ParameterHelpers.h" -namespace +namespace ChorusTags { -constexpr float rate1Low = 0.005f; -constexpr float rate1High = 5.0f; -constexpr float rate2Low = 0.5f; -constexpr float rate2High = 40.0f; - -constexpr float delay1Ms = 0.6f; -constexpr float delay2Ms = 0.2f; - const String delayTypeTag = "delay_type"; } // namespace @@ -39,9 +31,9 @@ Chorus::Chorus (UndoManager* um) : BaseProcessor ( loadParameterPointer (depthParam, vts, "depth"); loadParameterPointer (fbParam, vts, "feedback"); loadParameterPointer (mixParam, vts, "mix"); - delayTypeParam = vts.getRawParameterValue (delayTypeTag); + delayTypeParam = vts.getRawParameterValue (ChorusTags::delayTypeTag); - addPopupMenuParameter (delayTypeTag); + addPopupMenuParameter (ChorusTags::delayTypeTag); uiOptions.backgroundColour = Colours::purple.brighter (0.25f); uiOptions.powerColour = Colours::yellow.brighter (0.1f); @@ -60,7 +52,7 @@ ParamLayout Chorus::createParameterLayout() createPercentParameter (params, "feedback", "Feedback", 0.0f); createPercentParameter (params, "mix", "Mix", 0.5f); - emplace_param (params, delayTypeTag, "Delay Type", StringArray { "Clean", "Lo-Fi" }, 0); + emplace_param (params, ChorusTags::delayTypeTag, "Delay Type", StringArray { "Clean", "Lo-Fi" }, 0); return { params.begin(), params.end() }; } @@ -93,7 +85,7 @@ void Chorus::prepare (double sampleRate, int samplesPerBlock) } // set phase offsets - constexpr float piOver3 = MathConstants::pi / 3.0f; + static constexpr float piOver3 = MathConstants::pi / 3.0f; slowLFOs[0][0].reset (-piOver3); fastLFOs[0][0].reset (-piOver3); slowLFOs[1][1].reset (piOver3); @@ -159,6 +151,11 @@ void Chorus::processModulation (int numSamples) } else { + static constexpr float rate1Low = 0.005f; + static constexpr float rate1High = 5.0f; + static constexpr float rate2Low = 0.5f; + static constexpr float rate2High = 40.0f; + auto slowRate = rate1Low * std::pow (rate1High / rate1Low, *rateParam); auto fastRate = rate2Low * std::pow (rate2High / rate2Low, *rateParam); @@ -207,6 +204,9 @@ void Chorus::processChorus (AudioBuffer& buffer, DelayArrType& delay) else fbAmount *= 0.5f; + static constexpr float delay1Ms = 0.6f; + static constexpr float delay2Ms = 0.2f; + fbSmooth[ch].setTargetValue (fbAmount); slowSmooth[ch].setTargetValue (delay1Ms * 0.001f * fs * *depthParam); fastSmooth[ch].setTargetValue (delay2Ms * 0.001f * fs * *depthParam); diff --git a/src/processors/modulation/Flanger.cpp b/src/processors/modulation/Flanger.cpp index 431fcda8..60fc67aa 100644 --- a/src/processors/modulation/Flanger.cpp +++ b/src/processors/modulation/Flanger.cpp @@ -2,12 +2,8 @@ #include "../BufferHelpers.h" #include "../ParameterHelpers.h" -namespace +namespace FlangerTags { -constexpr float rateLow = 0.5f; -constexpr float rateHigh = 40.0f; -constexpr float delayMs = 0.001f; - const String delayTypeTag = "delay_type"; } // namespace @@ -36,9 +32,9 @@ Flanger::Flanger (UndoManager* um) : BaseProcessor ( loadParameterPointer (delayOffsetParam, vts, "delayOffset"); loadParameterPointer (fbParam, vts, "feedback"); loadParameterPointer (mixParam, vts, "mix"); - delayTypeParam = vts.getRawParameterValue (delayTypeTag); + delayTypeParam = vts.getRawParameterValue (FlangerTags::delayTypeTag); - addPopupMenuParameter (delayTypeTag); + addPopupMenuParameter (FlangerTags::delayTypeTag); uiOptions.backgroundColour = Colour (106, 102, 190); uiOptions.powerColour = Colours::yellow.brighter (0.1f); @@ -64,7 +60,7 @@ ParamLayout Flanger::createParameterLayout() createPercentParameter (params, "feedback", "Feedback", 0.0f); createPercentParameter (params, "mix", "Mix", 0.5f); - emplace_param (params, delayTypeTag, "Delay Type", StringArray { "Clean", "Lo-Fi" }, 0); + emplace_param (params, FlangerTags::delayTypeTag, "Delay Type", StringArray { "Clean", "Lo-Fi" }, 0); return { params.begin(), params.end() }; } @@ -143,6 +139,8 @@ void Flanger::processModulation (int numSamples) } else { + static constexpr float rateLow = 0.5f; + static constexpr float rateHigh = 40.0f; auto rate = rateLow * std::pow (rateHigh / rateLow, *rateParam); for (int ch = 0; ch < 2; ++ch) { @@ -183,6 +181,7 @@ void Flanger::processFlanger (AudioBuffer& buffer, DelayArrType& delay) fbSmooth[ch].setTargetValue (fbAmount); + static constexpr float delayMs = 0.001f; delaySmoothSamples[ch].setTargetValue (delayMs * fs * delayAmountParam->getCurrentValue()); delayOffsetSmoothSamples[ch].setTargetValue (delayMs * fs * delayOffsetParam->getCurrentValue()); diff --git a/src/processors/modulation/MIDIModulator.cpp b/src/processors/modulation/MIDIModulator.cpp index b5663bd5..13c968fc 100644 --- a/src/processors/modulation/MIDIModulator.cpp +++ b/src/processors/modulation/MIDIModulator.cpp @@ -1,7 +1,7 @@ #include "MIDIModulator.h" #include "processors/ParameterHelpers.h" -namespace +namespace MidiModulatorTags { const String bipolarTag = "bipolar"; const String midiMapTag = "midi_map_cc"; @@ -20,21 +20,21 @@ MidiModulator::MidiModulator (UndoManager* um) { return PortType::modulation; }) { midiModSmooth.setRampLength (0.025); - ParameterHelpers::loadParameterPointer (bipolarParam, vts, bipolarTag); + ParameterHelpers::loadParameterPointer (bipolarParam, vts, MidiModulatorTags::bipolarTag); uiOptions.backgroundColour = Colours::forestgreen.brighter (0.1f); uiOptions.powerColour = Colours::whitesmoke; uiOptions.info.description = "Module that allows MIDI controller changes to be used as a modulation source."; uiOptions.info.authors = StringArray { "Jatin Chowdhury" }; - addPopupMenuParameter (bipolarTag); + addPopupMenuParameter (MidiModulatorTags::bipolarTag); } ParamLayout MidiModulator::createParameterLayout() { using namespace ParameterHelpers; auto params = createBaseParams(); - emplace_param (params, bipolarTag, "Bipolar", true); + emplace_param (params, MidiModulatorTags::bipolarTag, "Bipolar", true); return { params.begin(), params.end() }; } @@ -101,14 +101,14 @@ void MidiModulator::processAudioBypassed (AudioBuffer& buffer) std::unique_ptr MidiModulator::toXML() { auto xml = BaseProcessor::toXML(); - xml->setAttribute (midiMapTag, mappedModController); + xml->setAttribute (MidiModulatorTags::midiMapTag, mappedModController); return xml; } void MidiModulator::fromXML (XmlElement* xml, const chowdsp::Version& version, bool loadPosition) { BaseProcessor::fromXML (xml, version, loadPosition); - mappedModController = xml->getIntAttribute (midiMapTag, 1); + mappedModController = xml->getIntAttribute (MidiModulatorTags::midiMapTag, 1); } //=================================================================== diff --git a/src/processors/modulation/Panner.cpp b/src/processors/modulation/Panner.cpp index 4dcb3af0..09723140 100644 --- a/src/processors/modulation/Panner.cpp +++ b/src/processors/modulation/Panner.cpp @@ -3,7 +3,7 @@ #include "gui/utils/ModulatableSlider.h" #include "processors/ParameterHelpers.h" -namespace +namespace PannerTags { const String mainPanTag = "main_pan"; const String leftPanTag = "left_pan"; @@ -35,24 +35,24 @@ Panner::Panner (UndoManager* um) : BaseProcessor ( }) { using namespace ParameterHelpers; - loadParameterPointer (mainPan, vts, mainPanTag); - loadParameterPointer (leftPan, vts, leftPanTag); - loadParameterPointer (rightPan, vts, rightPanTag); - loadParameterPointer (stereoWidth, vts, stereoWidthTag); - loadParameterPointer (modDepth, vts, modDepthTag); - loadParameterPointer (modRateHz, vts, modRateHzTag); - panMode = vts.getRawParameterValue (panModeTag); - stereoMode = vts.getRawParameterValue (stereoModeTag); + loadParameterPointer (mainPan, vts, PannerTags::mainPanTag); + loadParameterPointer (leftPan, vts, PannerTags::leftPanTag); + loadParameterPointer (rightPan, vts, PannerTags::rightPanTag); + loadParameterPointer (stereoWidth, vts, PannerTags::stereoWidthTag); + loadParameterPointer (modDepth, vts, PannerTags::modDepthTag); + loadParameterPointer (modRateHz, vts, PannerTags::modRateHzTag); + panMode = vts.getRawParameterValue (PannerTags::panModeTag); + stereoMode = vts.getRawParameterValue (PannerTags::stereoModeTag); uiOptions.backgroundColour = Colours::grey.brighter (0.25f); uiOptions.powerColour = Colours::red.brighter (0.1f); - uiOptions.paramIDsToSkip = { mainPanTag, leftPanTag }; + uiOptions.paramIDsToSkip = { PannerTags::mainPanTag, PannerTags::leftPanTag }; uiOptions.info.description = "Panning effect with mode and modulation options."; uiOptions.info.authors = StringArray { "Jatin Chowdhury" }; - addPopupMenuParameter (panModeTag); - addPopupMenuParameter (stereoModeTag); - disableWhenInputConnected ({ modRateHzTag }, ModulationInput); + addPopupMenuParameter (PannerTags::panModeTag); + addPopupMenuParameter (PannerTags::stereoModeTag); + disableWhenInputConnected ({ PannerTags::modRateHzTag }, ModulationInput); } ParamLayout Panner::createParameterLayout() @@ -60,16 +60,16 @@ ParamLayout Panner::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - createBipolarPercentParameter (params, mainPanTag, "Pan"); - createBipolarPercentParameter (params, leftPanTag, "Left Pan", -1.0f); - createBipolarPercentParameter (params, rightPanTag, "Right Pan", 1.0f); - createPercentParameter (params, stereoWidthTag, "Width", 1.0f); + createBipolarPercentParameter (params, PannerTags::mainPanTag, "Pan"); + createBipolarPercentParameter (params, PannerTags::leftPanTag, "Left Pan", -1.0f); + createBipolarPercentParameter (params, PannerTags::rightPanTag, "Right Pan", 1.0f); + createPercentParameter (params, PannerTags::stereoWidthTag, "Width", 1.0f); - createPercentParameter (params, modDepthTag, "Depth", 0.0f); - createFreqParameter (params, modRateHzTag, "Rate", 0.5f, 10.0f, 2.0f, 1.0f); + createPercentParameter (params, PannerTags::modDepthTag, "Depth", 0.0f); + createFreqParameter (params, PannerTags::modRateHzTag, "Rate", 0.5f, 10.0f, 2.0f, 1.0f); - emplace_param (params, panModeTag, "Pan Mode", StringArray { "Linear", "Constant Gain", "Constant Power" }, 1); - emplace_param (params, stereoModeTag, "Stereo Mode", StringArray { "Stereo", "Dual" }, 0); + emplace_param (params, PannerTags::panModeTag, "Pan Mode", StringArray { "Linear", "Constant Gain", "Constant Power" }, 1); + emplace_param (params, PannerTags::stereoModeTag, "Stereo Mode", StringArray { "Stereo", "Dual" }, 0); return { params.begin(), params.end() }; } @@ -262,13 +262,13 @@ bool Panner::getCustomComponents (OwnedArray& customComps, chowdsp::H public: PanSlider1 (AudioProcessorValueTreeState& vtState, std::atomic_bool& isStereo, chowdsp::HostContextProvider& hcp) : vts (vtState), - mainPanSlider (*getParameterPointer (vts, mainPanTag), hcp), - leftPanSlider (*getParameterPointer (vts, leftPanTag), hcp), - mainPanAttach (vts, mainPanTag, mainPanSlider), - leftPanAttach (vts, leftPanTag, leftPanSlider), + mainPanSlider (*getParameterPointer (vts, PannerTags::mainPanTag), hcp), + leftPanSlider (*getParameterPointer (vts, PannerTags::leftPanTag), hcp), + mainPanAttach (vts, PannerTags::mainPanTag, mainPanSlider), + leftPanAttach (vts, PannerTags::leftPanTag, leftPanSlider), isStereoInput (isStereo), stereoAttach ( - *vts.getParameter (stereoModeTag), + *vts.getParameter (PannerTags::stereoModeTag), [this] (float newValue) { updateSliderVisibility (newValue == 1.0f); }, vts.undoManager) @@ -279,7 +279,7 @@ bool Panner::getCustomComponents (OwnedArray& customComps, chowdsp::H hcp.registerParameterComponent (mainPanSlider, mainPanSlider.getParameter()); hcp.registerParameterComponent (leftPanSlider, leftPanSlider.getParameter()); - this->setName (mainPanTag + "__" + leftPanTag + "__"); + Component::setName (PannerTags::mainPanTag + "__" + PannerTags::leftPanTag + "__"); } void colourChanged() override @@ -305,14 +305,14 @@ bool Panner::getCustomComponents (OwnedArray& customComps, chowdsp::H mainPanSlider.setVisible (! dualPanOn); leftPanSlider.setVisible (dualPanOn); - setName (vts.getParameter (dualPanOn ? leftPanTag : mainPanTag)->name); + setName (vts.getParameter (dualPanOn ? PannerTags::leftPanTag : PannerTags::mainPanTag)->name); if (auto* parent = getParentComponent()) parent->repaint(); } void visibilityChanged() override { - updateSliderVisibility (vts.getRawParameterValue (stereoModeTag)->load() == 1.0f); + updateSliderVisibility (vts.getRawParameterValue (PannerTags::stereoModeTag)->load() == 1.0f); } void resized() override @@ -346,13 +346,13 @@ bool Panner::getCustomComponents (OwnedArray& customComps, chowdsp::H public: PanSlider2 (AudioProcessorValueTreeState& vtState, std::atomic_bool& isStereo, chowdsp::HostContextProvider& hcp) : vts (vtState), - widthSlider (*getParameterPointer (vts, stereoWidthTag), hcp), - rightPanSlider (*getParameterPointer (vts, rightPanTag), hcp), - widthAttach (vts, stereoWidthTag, widthSlider), - rightPanAttach (vts, rightPanTag, rightPanSlider), + widthSlider (*getParameterPointer (vts, PannerTags::stereoWidthTag), hcp), + rightPanSlider (*getParameterPointer (vts, PannerTags::rightPanTag), hcp), + widthAttach (vts, PannerTags::stereoWidthTag, widthSlider), + rightPanAttach (vts, PannerTags::rightPanTag, rightPanSlider), isStereoInput (isStereo), stereoAttach ( - *vts.getParameter (stereoModeTag), + *vts.getParameter (PannerTags::stereoModeTag), [this] (float newValue) { updateSliderVisibility (newValue == 1.0f); }, vts.undoManager) @@ -363,7 +363,7 @@ bool Panner::getCustomComponents (OwnedArray& customComps, chowdsp::H hcp.registerParameterComponent (widthSlider, widthSlider.getParameter()); hcp.registerParameterComponent (rightPanSlider, rightPanSlider.getParameter()); - this->setName (stereoWidthTag + "__" + rightPanTag + "__"); + Component::setName (PannerTags::stereoWidthTag + "__" + PannerTags::rightPanTag + "__"); startTimerHz (10); } @@ -393,14 +393,14 @@ bool Panner::getCustomComponents (OwnedArray& customComps, chowdsp::H widthSlider.setVisible (! dualPanOn); rightPanSlider.setVisible (dualPanOn); - setName (vts.getParameter (dualPanOn ? rightPanTag : stereoWidthTag)->name); + setName (vts.getParameter (dualPanOn ? PannerTags::rightPanTag : PannerTags::stereoWidthTag)->name); if (auto* parent = getParentComponent()) parent->repaint(); } void visibilityChanged() override { - updateSliderVisibility (vts.getRawParameterValue (stereoModeTag)->load() == 1.0f); + updateSliderVisibility (vts.getRawParameterValue (PannerTags::stereoModeTag)->load() == 1.0f); } void resized() override diff --git a/src/processors/modulation/ParamModulator.cpp b/src/processors/modulation/ParamModulator.cpp index 8efcf2d3..75b601df 100644 --- a/src/processors/modulation/ParamModulator.cpp +++ b/src/processors/modulation/ParamModulator.cpp @@ -2,7 +2,7 @@ #include "gui/utils/ModulatableSlider.h" #include "processors/ParameterHelpers.h" -namespace +namespace ParamModulatorTags { const String unipolarModTag = "unipolar_mod"; const String bipolarModTag = "bipolar_mod"; @@ -22,25 +22,25 @@ ParamModulator::ParamModulator (UndoManager* um) { return PortType::modulation; }) { using namespace ParameterHelpers; - loadParameterPointer (unipolarModParam, vts, unipolarModTag); - loadParameterPointer (bipolarModParam, vts, bipolarModTag); - loadParameterPointer (bipolarModeParam, vts, bipolarModeTag); + loadParameterPointer (unipolarModParam, vts, ParamModulatorTags::unipolarModTag); + loadParameterPointer (bipolarModParam, vts, ParamModulatorTags::bipolarModTag); + loadParameterPointer (bipolarModeParam, vts, ParamModulatorTags::bipolarModeTag); uiOptions.backgroundColour = Colours::yellowgreen.darker (0.1f); uiOptions.powerColour = Colours::red.brighter (0.05f); uiOptions.info.description = "Module that uses a parameter as a modulation source."; uiOptions.info.authors = StringArray { "Jatin Chowdhury" }; - addPopupMenuParameter (bipolarModeTag); + addPopupMenuParameter (ParamModulatorTags::bipolarModeTag); } ParamLayout ParamModulator::createParameterLayout() { using namespace ParameterHelpers; auto params = createBaseParams(); - createPercentParameter (params, unipolarModTag, "Modulation", 0.0f); - createBipolarPercentParameter (params, bipolarModTag, "Modulation +/-", 0.0f); - emplace_param (params, bipolarModeTag, "Bipolar", true); + createPercentParameter (params, ParamModulatorTags::unipolarModTag, "Modulation", 0.0f); + createBipolarPercentParameter (params, ParamModulatorTags::bipolarModTag, "Modulation +/-", 0.0f); + emplace_param (params, ParamModulatorTags::bipolarModeTag, "Bipolar", true); return { params.begin(), params.end() }; } @@ -83,12 +83,12 @@ bool ParamModulator::getCustomComponents (OwnedArray& customComps, ch public: ControlSlider (AudioProcessorValueTreeState& vtState, chowdsp::HostContextProvider& hcp) : vts (vtState), - unipolarSlider (*getParameterPointer (vts, unipolarModTag), hcp), - bipolarSlider (*getParameterPointer (vts, bipolarModTag), hcp), - unipolarAttach (vts, unipolarModTag, unipolarSlider), - bipolarAttach (vts, bipolarModTag, bipolarSlider), + unipolarSlider (*getParameterPointer (vts, ParamModulatorTags::unipolarModTag), hcp), + bipolarSlider (*getParameterPointer (vts, ParamModulatorTags::bipolarModTag), hcp), + unipolarAttach (vts, ParamModulatorTags::unipolarModTag, unipolarSlider), + bipolarAttach (vts, ParamModulatorTags::bipolarModTag, bipolarSlider), modeAttach ( - *vts.getParameter (bipolarModeTag), + *vts.getParameter (ParamModulatorTags::bipolarModeTag), [this] (float newValue) { updateSliderVisibility (newValue == 1.0f); }, vts.undoManager) @@ -99,7 +99,7 @@ bool ParamModulator::getCustomComponents (OwnedArray& customComps, ch hcp.registerParameterComponent (bipolarSlider, bipolarSlider.getParameter()); hcp.registerParameterComponent (unipolarSlider, unipolarSlider.getParameter()); - this->setName (unipolarModTag + "__" + bipolarModTag + "__"); + Component::setName (ParamModulatorTags::unipolarModTag + "__" + ParamModulatorTags::bipolarModTag + "__"); } void colourChanged() override @@ -122,14 +122,14 @@ bool ParamModulator::getCustomComponents (OwnedArray& customComps, ch unipolarSlider.setVisible (! isBipolar); bipolarSlider.setVisible (isBipolar); - setName (vts.getParameter (isBipolar ? bipolarModTag : unipolarModTag)->name); + setName (vts.getParameter (isBipolar ? ParamModulatorTags::bipolarModTag : ParamModulatorTags::unipolarModTag)->name); if (auto* parent = getParentComponent()) parent->repaint(); } void visibilityChanged() override { - updateSliderVisibility (vts.getRawParameterValue (bipolarModeTag)->load() == 1.0f); + updateSliderVisibility (vts.getRawParameterValue (ParamModulatorTags::bipolarModeTag)->load() == 1.0f); } void resized() override diff --git a/src/processors/modulation/Rotary.cpp b/src/processors/modulation/Rotary.cpp index ffdfdd03..e2d3eaa0 100644 --- a/src/processors/modulation/Rotary.cpp +++ b/src/processors/modulation/Rotary.cpp @@ -2,7 +2,7 @@ #include "../BufferHelpers.h" #include "../ParameterHelpers.h" -namespace +namespace RotaryTags { const String stereoTag = "stereo"; } @@ -27,9 +27,9 @@ Rotary::Rotary (UndoManager* um) : BaseProcessor ( }) { chowdsp::ParamUtils::loadParameterPointer (rateHzParam, vts, "rate"); - chowdsp::ParamUtils::loadParameterPointer (stereoParam, vts, stereoTag); + chowdsp::ParamUtils::loadParameterPointer (stereoParam, vts, RotaryTags::stereoTag); - addPopupMenuParameter (stereoTag); + addPopupMenuParameter (RotaryTags::stereoTag); auto* depthParamHandle = dynamic_cast (vts.getParameter ("depth")); spectralDepthSmoothed.setParameterHandle (depthParamHandle); @@ -51,7 +51,7 @@ ParamLayout Rotary::createParameterLayout() createFreqParameter (params, "rate", "Rate", 0.25f, 8.0f, 1.0f, 1.0f); createPercentParameter (params, "depth", "Depth", 0.5f); - emplace_param (params, stereoTag, "Stereo", false); + emplace_param (params, RotaryTags::stereoTag, "Stereo", false); return { params.begin(), params.end() }; } diff --git a/src/processors/other/EnvelopeFilter.cpp b/src/processors/other/EnvelopeFilter.cpp index e827f303..0bf43589 100644 --- a/src/processors/other/EnvelopeFilter.cpp +++ b/src/processors/other/EnvelopeFilter.cpp @@ -3,7 +3,7 @@ #include "../ParameterHelpers.h" #include "gui/utils/ModulatableSlider.h" -namespace +namespace EnvelopeFilterTags { constexpr int mSize = 16; @@ -44,12 +44,12 @@ EnvelopeFilter::EnvelopeFilter (UndoManager* um) : BaseProcessor ( loadParameterPointer (freqParam, vts, "freq"); loadParameterPointer (resParam, vts, "res"); loadParameterPointer (speedParam, vts, "speed"); - loadParameterPointer (senseParam, vts, senseTag); - loadParameterPointer (freqModParam, vts, freqModTag); + loadParameterPointer (senseParam, vts, EnvelopeFilterTags::senseTag); + loadParameterPointer (freqModParam, vts, EnvelopeFilterTags::freqModTag); filterTypeParam = vts.getRawParameterValue ("filter_type"); - directControlParam = vts.getRawParameterValue (directControlTag); + directControlParam = vts.getRawParameterValue (EnvelopeFilterTags::directControlTag); - addPopupMenuParameter (directControlTag); + addPopupMenuParameter (EnvelopeFilterTags::directControlTag); uiOptions.backgroundColour = Colours::purple.brighter(); uiOptions.powerColour = Colours::yellow.darker (0.1f); @@ -67,12 +67,12 @@ ParamLayout EnvelopeFilter::createParameterLayout() createPercentParameter (params, "res", "Resonance", 0.5f); createFreqParameter (params, "freq", "Freq.", 100.0f, 1000.0f, 250.0f, 250.0f); createPercentParameter (params, "speed", "Speed", 0.5f); - createPercentParameter (params, senseTag, "Sensitivity", 0.5f); - createPercentParameter (params, freqModTag, "Freq. Mod", 0.0f); + createPercentParameter (params, EnvelopeFilterTags::senseTag, "Sensitivity", 0.5f); + createPercentParameter (params, EnvelopeFilterTags::freqModTag, "Freq. Mod", 0.0f); emplace_param (params, "filter_type", "Type", StringArray { "Lowpass", "Bandpass", "Highpass" }, 0); - emplace_param (params, directControlTag, "Direct Control", false); + emplace_param (params, EnvelopeFilterTags::directControlTag, "Direct Control", false); return { params.begin(), params.end() }; } @@ -93,7 +93,7 @@ void EnvelopeFilter::prepare (double sampleRate, int samplesPerBlock) void EnvelopeFilter::fillLevelBuffer (AudioBuffer& buffer, bool directControlOn) { const auto numSamples = buffer.getNumSamples(); - auto speed = speedRange.convertFrom0to1 (1.0f - *speedParam); + auto speed = EnvelopeFilterTags::speedRange.convertFrom0to1 (1.0f - *speedParam); levelOutBuffer.setSize (1, numSamples, false, false, true); levelOutBuffer.clear(); @@ -139,10 +139,10 @@ void processFilter (AudioBuffer& buffer, chowdsp::SVFMultiMode& fi auto* x = buffer.getWritePointer (ch); int i = 0; - for (int n = 0; n < numSamples - mSize; n += mSize) + for (int n = 0; n < numSamples - EnvelopeFilterTags::mSize; n += EnvelopeFilterTags::mSize) { filter.setCutoffFrequency (getModFreq (i)); - for (; i < n + mSize; ++i) + for (; i < n + EnvelopeFilterTags::mSize; ++i) x[i] = filter.processSample (ch, x[i]); } @@ -163,7 +163,7 @@ void EnvelopeFilter::processAudio (AudioBuffer& buffer) if (inputsConnected.contains (AudioInput)) { auto filterFreqHz = freqParam->getCurrentValue(); - filter.setQValue (getQ (resParam->getCurrentValue())); + filter.setQValue (EnvelopeFilterTags::getQ (resParam->getCurrentValue())); auto freqModGain = directControlOn ? 10.0f : (20.0f * senseParam->getCurrentValue()); auto* levelPtr = levelOutBuffer.getReadPointer (0); @@ -252,12 +252,12 @@ bool EnvelopeFilter::getCustomComponents (OwnedArray& customComps, ch public: ControlSlider (AudioProcessorValueTreeState& vtState, chowdsp::HostContextProvider& hcp) : vts (vtState), - freqModSlider (*getParameterPointer (vts, freqModTag), hcp), - sensitivitySlider (*getParameterPointer (vts, senseTag), hcp), - freqModAttach (vts, freqModTag, freqModSlider), - senseAttach (vts, senseTag, sensitivitySlider), + freqModSlider (*getParameterPointer (vts, EnvelopeFilterTags::freqModTag), hcp), + sensitivitySlider (*getParameterPointer (vts, EnvelopeFilterTags::senseTag), hcp), + freqModAttach (vts, EnvelopeFilterTags::freqModTag, freqModSlider), + senseAttach (vts, EnvelopeFilterTags::senseTag, sensitivitySlider), directControlAttach ( - *vts.getParameter (directControlTag), + *vts.getParameter (EnvelopeFilterTags::directControlTag), [this] (float newValue) { updateSliderVisibility (newValue == 1.0f); }, vts.undoManager) @@ -268,7 +268,7 @@ bool EnvelopeFilter::getCustomComponents (OwnedArray& customComps, ch hcp.registerParameterComponent (freqModSlider, freqModSlider.getParameter()); hcp.registerParameterComponent (sensitivitySlider, sensitivitySlider.getParameter()); - this->setName (senseTag + "__" + freqModTag + "__"); + Component::setName (EnvelopeFilterTags::senseTag + "__" + EnvelopeFilterTags::freqModTag + "__"); } void colourChanged() override @@ -291,14 +291,14 @@ bool EnvelopeFilter::getCustomComponents (OwnedArray& customComps, ch sensitivitySlider.setVisible (! directControlOn); freqModSlider.setVisible (directControlOn); - setName (vts.getParameter (directControlOn ? freqModTag : senseTag)->name); + setName (vts.getParameter (directControlOn ? EnvelopeFilterTags::freqModTag : EnvelopeFilterTags::senseTag)->name); if (auto* parent = getParentComponent()) parent->repaint(); } void visibilityChanged() override { - updateSliderVisibility (vts.getRawParameterValue (directControlTag)->load() == 1.0f); + updateSliderVisibility (vts.getRawParameterValue (EnvelopeFilterTags::directControlTag)->load() == 1.0f); } void resized() override diff --git a/src/processors/other/LevelDetective.cpp b/src/processors/other/LevelDetective.cpp index bad8b9f1..ce02ba83 100644 --- a/src/processors/other/LevelDetective.cpp +++ b/src/processors/other/LevelDetective.cpp @@ -4,7 +4,7 @@ using namespace chowdsp::compressor; -namespace +namespace LevelDetectiveTags { const auto powerColour = Colours::gold.darker (0.1f); const auto backgroundColour = Colours::teal.darker (0.1f); @@ -28,10 +28,10 @@ LevelDetective::LevelDetective (UndoManager* um) : BaseProcessor ( }) { using namespace ParameterHelpers; - loadParameterPointer (attackMsParam, vts, attackTag); - loadParameterPointer (releaseMsParam, vts, releaseTag); - uiOptions.backgroundColour = backgroundColour; - uiOptions.powerColour = powerColour; + loadParameterPointer (attackMsParam, vts, LevelDetectiveTags::attackTag); + loadParameterPointer (releaseMsParam, vts, LevelDetectiveTags::releaseTag); + uiOptions.backgroundColour = LevelDetectiveTags::backgroundColour; + uiOptions.powerColour = LevelDetectiveTags::powerColour; uiOptions.info.description = "A simple envelope follower"; uiOptions.info.authors = StringArray { "Rachel Locke" }; } @@ -41,8 +41,8 @@ ParamLayout LevelDetective::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - createTimeMsParameter (params, attackTag, "Attack", createNormalisableRange (1.0f, 100.0f, 10.0f), 10.0f); - createTimeMsParameter (params, releaseTag, "Release", createNormalisableRange (10.0f, 1000.0f, 100.0f), 400.0f); + createTimeMsParameter (params, LevelDetectiveTags::attackTag, "Attack", createNormalisableRange (1.0f, 100.0f, 10.0f), 10.0f); + createTimeMsParameter (params, LevelDetectiveTags::releaseTag, "Release", createNormalisableRange (10.0f, 1000.0f, 100.0f), 400.0f); return { params.begin(), params.end() }; } @@ -102,10 +102,10 @@ bool LevelDetective::getCustomComponents (OwnedArray& customComps, ch explicit LevelDetectiveEditor (LevelDetectorVisualizer& viz, AudioProcessorValueTreeState& vtState, chowdsp::HostContextProvider& hcp) : visualiser (viz), vts (vtState), - attackSlider (*getParameterPointer (vts, attackTag), hcp), - releaseSlider (*getParameterPointer (vts, releaseTag), hcp), - attackAttach (vts, attackTag, attackSlider), - releaseAttach (vts, releaseTag, releaseSlider) + attackSlider (*getParameterPointer (vts, LevelDetectiveTags::attackTag), hcp), + releaseSlider (*getParameterPointer (vts, LevelDetectiveTags::releaseTag), hcp), + attackAttach (vts, LevelDetectiveTags::attackTag, attackSlider), + releaseAttach (vts, LevelDetectiveTags::releaseTag, releaseSlider) { attackLabel.setText ("Attack", juce::dontSendNotification); releaseLabel.setText ("Release", juce::dontSendNotification); @@ -119,18 +119,18 @@ bool LevelDetective::getCustomComponents (OwnedArray& customComps, ch { s->setSliderStyle (Slider::RotaryHorizontalVerticalDrag); s->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); - s->setColour (Slider::textBoxHighlightColourId, powerColour.withAlpha (0.55f)); - s->setColour (Slider::thumbColourId, powerColour); + s->setColour (Slider::textBoxHighlightColourId, LevelDetectiveTags::powerColour.withAlpha (0.55f)); + s->setColour (Slider::thumbColourId, LevelDetectiveTags::powerColour); addAndMakeVisible (s); } - visualiser.backgroundColour = backgroundColour.darker (0.4f); - visualiser.audioColour = powerColour; + visualiser.backgroundColour = LevelDetectiveTags::backgroundColour.darker (0.4f); + visualiser.audioColour = LevelDetectiveTags::powerColour; hcp.registerParameterComponent (attackSlider, attackSlider.getParameter()); hcp.registerParameterComponent (releaseSlider, releaseSlider.getParameter()); - this->setName (attackTag + "__" + releaseTag + "__"); + Component::setName (LevelDetectiveTags::attackTag + "__" + LevelDetectiveTags::releaseTag + "__"); addAndMakeVisible (visualiser); } diff --git a/src/processors/other/ShimmerReverb.cpp b/src/processors/other/ShimmerReverb.cpp index b9d09101..89aa8b20 100644 --- a/src/processors/other/ShimmerReverb.cpp +++ b/src/processors/other/ShimmerReverb.cpp @@ -1,7 +1,7 @@ #include "ShimmerReverb.h" #include "processors/ParameterHelpers.h" -namespace +namespace ShimmerReverbTags { const String shiftTag = "shift"; const String sizeTag = "size"; @@ -54,10 +54,10 @@ const float* ShimmerReverb::ShimmerFDNConfig::doFeedbackProcess (ShimmerFDNConfi ShimmerReverb::ShimmerReverb (UndoManager* um) : BaseProcessor ("Shimmer Reverb", createParameterLayout(), um) { using namespace ParameterHelpers; - shiftParam.setParameterHandle (getParameterPointer (vts, shiftTag)); - sizeParam.setParameterHandle (getParameterPointer (vts, sizeTag)); - feedbackParam.setParameterHandle (getParameterPointer (vts, feedbackTag)); - loadParameterPointer (mixParam, vts, mixTag); + shiftParam.setParameterHandle (getParameterPointer (vts, ShimmerReverbTags::shiftTag)); + sizeParam.setParameterHandle (getParameterPointer (vts, ShimmerReverbTags::sizeTag)); + feedbackParam.setParameterHandle (getParameterPointer (vts, ShimmerReverbTags::feedbackTag)); + loadParameterPointer (mixParam, vts, ShimmerReverbTags::mixTag); uiOptions.backgroundColour = Colours::lightgrey; uiOptions.powerColour = Colours::darksalmon.darker (0.2f); @@ -71,15 +71,15 @@ ParamLayout ShimmerReverb::createParameterLayout() auto params = createBaseParams(); emplace_param (params, - shiftTag, + ShimmerReverbTags::shiftTag, "Shift", NormalisableRange { -12.0f, 12.0f }, -12.0f, &floatValToString, &stringToFloatVal); - createPercentParameter (params, sizeTag, "Size", 1.0f); - createPercentParameter (params, feedbackTag, "Decay", 1.0f); - createPercentParameter (params, mixTag, "Mix", 0.5f); + createPercentParameter (params, ShimmerReverbTags::sizeTag, "Size", 1.0f); + createPercentParameter (params, ShimmerReverbTags::feedbackTag, "Decay", 1.0f); + createPercentParameter (params, ShimmerReverbTags::mixTag, "Mix", 0.5f); return { params.begin(), params.end() }; } diff --git a/src/processors/other/SmoothReverb.cpp b/src/processors/other/SmoothReverb.cpp index 19fe54cb..4bf03c78 100644 --- a/src/processors/other/SmoothReverb.cpp +++ b/src/processors/other/SmoothReverb.cpp @@ -1,7 +1,7 @@ #include "SmoothReverb.h" #include "../ParameterHelpers.h" -namespace +namespace SmoothReverbTags { const String decayTag = "decay"; const String relaxTag = "relax"; @@ -19,11 +19,11 @@ constexpr auto preDelay2CutoffHz = 2000.0f; SmoothReverb::SmoothReverb (UndoManager* um) : BaseProcessor ("Smooth Reverb", createParameterLayout(), um) { using namespace ParameterHelpers; - loadParameterPointer (decayMsParam, vts, decayTag); - loadParameterPointer (relaxParam, vts, relaxTag); - loadParameterPointer (lowCutHzParam, vts, lowCutTag); - loadParameterPointer (highCutHzParam, vts, highCutTag); - loadParameterPointer (mixPctParam, vts, mixTag); + loadParameterPointer (decayMsParam, vts, SmoothReverbTags::decayTag); + loadParameterPointer (relaxParam, vts, SmoothReverbTags::relaxTag); + loadParameterPointer (lowCutHzParam, vts, SmoothReverbTags::lowCutTag); + loadParameterPointer (highCutHzParam, vts, SmoothReverbTags::highCutTag); + loadParameterPointer (mixPctParam, vts, SmoothReverbTags::mixTag); uiOptions.backgroundColour = Colour { 0xFF8BBBD5 }; uiOptions.powerColour = Colour { 0xFFCC4514 }; @@ -36,14 +36,14 @@ ParamLayout SmoothReverb::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - createTimeMsParameter (params, decayTag, "Decay", createNormalisableRange (500.0f, 5000.0f, 1500.0f), 1500.0f); - createPercentParameter (params, relaxTag, "Relax", 0.5f); + createTimeMsParameter (params, SmoothReverbTags::decayTag, "Decay", createNormalisableRange (500.0f, 5000.0f, 1500.0f), 1500.0f); + createPercentParameter (params, SmoothReverbTags::relaxTag, "Relax", 0.5f); // @TODO: can we figure out a way to combine these two parameters as one slider on the UI? - createFreqParameter (params, lowCutTag, "Low Cut", 20.0f, 2000.0f, 200.0f, 200.0f); - createFreqParameter (params, highCutTag, "High Cut", 500.0f, 20000.0f, 8000.0f, 8000.0f); + createFreqParameter (params, SmoothReverbTags::lowCutTag, "Low Cut", 20.0f, 2000.0f, 200.0f, 200.0f); + createFreqParameter (params, SmoothReverbTags::highCutTag, "High Cut", 500.0f, 20000.0f, 8000.0f, 8000.0f); - createPercentParameter (params, mixTag, "Mix", 0.5f); + createPercentParameter (params, SmoothReverbTags::mixTag, "Mix", 0.5f); return { params.begin(), params.end() }; } @@ -56,12 +56,12 @@ void SmoothReverb::prepare (double sampleRate, int samplesPerBlock) preDelay2.prepare (spec); preDelayFilt.prepare (spec); - float preDelayCutoffHzVec alignas (16)[] = { preDelay1CutoffHz, preDelay2CutoffHz, 0.0f, 0.0f }; + float preDelayCutoffHzVec alignas (16)[] = { SmoothReverbTags::preDelay1CutoffHz, SmoothReverbTags::preDelay2CutoffHz, 0.0f, 0.0f }; preDelayFilt.setCutoffFrequency (xsimd::load_aligned (preDelayCutoffHzVec)); fs = (float) sampleRate; - preDelay1.setDelay (preDelay1LengthMs * 0.001f * fs); - preDelay2.setDelay (preDelay2LengthMs * 0.001f * fs); + preDelay1.setDelay (SmoothReverbTags::preDelay1LengthMs * 0.001f * fs); + preDelay2.setDelay (SmoothReverbTags::preDelay2LengthMs * 0.001f * fs); reverbInternal = std::make_unique(); reverbInternal->diffuser.prepare (sampleRate); @@ -98,8 +98,8 @@ void SmoothReverb::processReverb (float* left, float* right, int numSamples) const auto curDecayParam = decayMsParam->getCurrentValue(); const auto modFactor = 2.5f * std::pow (curDecayParam / 5000.0f, 1.25f); const auto delayFactor = 1.0f + (modFactor * *relaxParam) * curLevel; - const auto baseDelay1 = preDelay1LengthMs * 0.001f * fs; - const auto baseDelay2 = preDelay2LengthMs * 0.001f * fs; + const auto baseDelay1 = SmoothReverbTags::preDelay1LengthMs * 0.001f * fs; + const auto baseDelay2 = SmoothReverbTags::preDelay2LengthMs * 0.001f * fs; preDelay1.setDelay (baseDelay1 * delayFactor); preDelay2.setDelay (baseDelay2 * delayFactor); diff --git a/src/processors/other/cry_baby/CryBaby.cpp b/src/processors/other/cry_baby/CryBaby.cpp index 531ffa93..38a47ef4 100644 --- a/src/processors/other/cry_baby/CryBaby.cpp +++ b/src/processors/other/cry_baby/CryBaby.cpp @@ -5,7 +5,7 @@ #include "processors/ParameterHelpers.h" #include "processors/netlist_helpers/CircuitQuantity.h" -namespace +namespace CryBabyTags { const String controlFreqTag = "control_freq"; const String depthTag = "depth"; @@ -38,12 +38,12 @@ CryBaby::CryBaby (UndoManager* um) }) { using namespace ParameterHelpers; - loadParameterPointer (controlFreqParam, vts, controlFreqTag); - loadParameterPointer (attackParam, vts, attackTag); - loadParameterPointer (releaseParam, vts, releaseTag); - loadParameterPointer (directControlParam, vts, directControlTag); + loadParameterPointer (controlFreqParam, vts, CryBabyTags::controlFreqTag); + loadParameterPointer (attackParam, vts, CryBabyTags::attackTag); + loadParameterPointer (releaseParam, vts, CryBabyTags::releaseTag); + loadParameterPointer (directControlParam, vts, CryBabyTags::directControlTag); - depthSmooth.setParameterHandle (getParameterPointer (vts, depthTag)); + depthSmooth.setParameterHandle (getParameterPointer (vts, CryBabyTags::depthTag)); depthSmooth.setRampLength (0.025); alphaSmooth.setRampLength (0.01); @@ -55,8 +55,8 @@ CryBaby::CryBaby (UndoManager* um) uiOptions.info.description = "\"Wah\" effect based on the Dunlop Cry Baby pedal."; uiOptions.info.authors = StringArray { "Jatin Chowdhury" }; - addPopupMenuParameter (directControlTag); - disableWhenInputConnected ({ attackTag, releaseTag }, LevelInput); + addPopupMenuParameter (CryBabyTags::directControlTag); + disableWhenInputConnected ({ CryBabyTags::attackTag, CryBabyTags::releaseTag }, LevelInput); } CryBaby::~CryBaby() = default; @@ -66,11 +66,11 @@ ParamLayout CryBaby::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - createPercentParameter (params, controlFreqTag, "Freq", 0.5f); - createBipolarPercentParameter (params, depthTag, "Depth", 0.5f); - createTimeMsParameter (params, attackTag, "Attack", createNormalisableRange (0.1f, 20.0f, 2.0f), 1.0f); - createTimeMsParameter (params, releaseTag, "Release", createNormalisableRange (1.0f, 200.0f, 20.0f), 25.0f); - emplace_param (params, directControlTag, "Direct Control", false); + createPercentParameter (params, CryBabyTags::controlFreqTag, "Freq", 0.5f); + createBipolarPercentParameter (params, CryBabyTags::depthTag, "Depth", 0.5f); + createTimeMsParameter (params, CryBabyTags::attackTag, "Attack", createNormalisableRange (0.1f, 20.0f, 2.0f), 1.0f); + createTimeMsParameter (params, CryBabyTags::releaseTag, "Release", createNormalisableRange (1.0f, 200.0f, 20.0f), 25.0f); + emplace_param (params, CryBabyTags::directControlTag, "Direct Control", false); return { params.begin(), params.end() }; } @@ -90,12 +90,12 @@ void CryBaby::prepare (double sampleRate, int samplesPerBlock) needsOversampling = sampleRate < 88'200.0f; if (needsOversampling) { - upsampler.prepare ({ sampleRate, (uint32_t) samplesPerBlock, 2 }, oversampleRatio); - downsampler.prepare ({ oversampleRatio * sampleRate, oversampleRatio * (uint32_t) samplesPerBlock, 2 }, oversampleRatio); + upsampler.prepare ({ sampleRate, (uint32_t) samplesPerBlock, 2 }, CryBabyTags::oversampleRatio); + downsampler.prepare ({ CryBabyTags::oversampleRatio * sampleRate, CryBabyTags::oversampleRatio * (uint32_t) samplesPerBlock, 2 }, CryBabyTags::oversampleRatio); } ndk_model = std::make_unique(); - ndk_model->reset ((needsOversampling ? oversampleRatio : 1.0) * sampleRate); + ndk_model->reset ((needsOversampling ? CryBabyTags::oversampleRatio : 1.0) * sampleRate); const auto alpha = (double) alphaSmooth.getCurrentValue(); ndk_model->update_pots ({ (1.0 - alpha) * CryBabyNDK::VR1, alpha * CryBabyNDK::VR1 }); @@ -165,7 +165,7 @@ void CryBaby::processAudio (AudioBuffer& buffer) if (needsOversampling) { const auto osBufferView = upsampler.process (audioOutBuffer); - processBlockNDK (osBufferView, oversampleRatio); + processBlockNDK (osBufferView, CryBabyTags::oversampleRatio); downsampler.process (osBufferView, audioOutBuffer); } else @@ -226,7 +226,7 @@ bool CryBaby::getCustomComponents (OwnedArray& customComps, chowdsp:: : vts (vtState), internalSlider (*chowdsp::ParamUtils::getParameterPointer (vts, tag), hcp), attach (vts, tag, internalSlider), - directControlAttach (*chowdsp::ParamUtils::getParameterPointer (vts, directControlTag), + directControlAttach (*chowdsp::ParamUtils::getParameterPointer (vts, CryBabyTags::directControlTag), [this] (float newValue) { internalSlider.setEnabled (newValue < 0.5f); @@ -272,9 +272,9 @@ bool CryBaby::getCustomComponents (OwnedArray& customComps, chowdsp:: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomSlider) }; - customComps.add (std::make_unique (vts, attackTag, hcp)); - customComps.add (std::make_unique (vts, releaseTag, hcp)); - customComps.add (std::make_unique (vts, depthTag, hcp)); + customComps.add (std::make_unique (vts, CryBabyTags::attackTag, hcp)); + customComps.add (std::make_unique (vts, CryBabyTags::releaseTag, hcp)); + customComps.add (std::make_unique (vts, CryBabyTags::depthTag, hcp)); return true; } diff --git a/src/processors/other/cry_baby/CryBabyNDK.cpp b/src/processors/other/cry_baby/CryBabyNDK.cpp index e6c85cd2..47801930 100644 --- a/src/processors/other/cry_baby/CryBabyNDK.cpp +++ b/src/processors/other/cry_baby/CryBabyNDK.cpp @@ -9,7 +9,7 @@ JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4459) #include "CryBabyNDK.h" -namespace +namespace CryBabyComponents { // START USER ENTRIES constexpr auto R1 = 68.0e3; @@ -43,6 +43,7 @@ constexpr auto BetaR_Q2 = 4.0; void CryBabyNDK::reset (T fs) { + using namespace CryBabyComponents; const auto Gr = Eigen::DiagonalMatrix { (T) 1 / R1, (T) 1 / R2, (T) 1 / R3, (T) 1 / R4, (T) 1 / R5, (T) 1 / R6, (T) 1 / R7, (T) 1 / R8, (T) 1 / R9, (T) 1 / R10 }; const auto Gx = Eigen::DiagonalMatrix { (T) 2 * fs * C1, (T) 2 * fs * C2, (T) 2 * fs * C3, (T) 2 * fs * C4, (T) 2 * fs * C5, (T) 1 / ((T) 2 * fs * L1) }; const auto Z = Eigen::DiagonalMatrix { 1, 1, 1, 1, 1, -1 }; @@ -136,6 +137,8 @@ void CryBabyNDK::reset (T fs) void CryBabyNDK::update_pots (const std::array& pot_values) { + using namespace CryBabyComponents; + Eigen::Matrix Rv = Eigen::Matrix::Zero(); Rv (0, 0) = pot_values[0]; Rv (1, 1) = pot_values[1]; @@ -160,6 +163,7 @@ void CryBabyNDK::update_pots (const std::array& pot_values) void CryBabyNDK::process (std::span channel_data, size_t ch) noexcept { + using namespace CryBabyComponents; Eigen::Vector u_n_var; Eigen::Vector p_n; Eigen::Matrix Jac = Eigen::Matrix::Zero(); diff --git a/src/processors/other/spring_reverb/SpringReverb.cpp b/src/processors/other/spring_reverb/SpringReverb.cpp index 5188ab6a..e2339f7c 100644 --- a/src/processors/other/spring_reverb/SpringReverb.cpp +++ b/src/processors/other/spring_reverb/SpringReverb.cpp @@ -1,6 +1,6 @@ #include "SpringReverb.h" -namespace +namespace SpringReverbConstants { constexpr int downsampleFactor = 2; constexpr double preDelayMs = 2.0; @@ -18,15 +18,15 @@ SpringReverb::SpringReverb (double sampleRate) int SpringReverb::prepareRebuffering (const dsp::ProcessSpec& spec) { - const auto blockSizeDouble = (preDelayMs * 0.001) * spec.sampleRate; + const auto blockSizeDouble = (SpringReverbConstants::preDelayMs * 0.001) * spec.sampleRate; const auto upsampledBlockSize = int (std::round (blockSizeDouble * 0.5) * 2.0); dsp::ProcessSpec smallBufferSpec { spec.sampleRate, (uint32) upsampledBlockSize, spec.numChannels }; - downsample.prepare (smallBufferSpec, downsampleFactor); - upsample.prepare (smallBufferSpec, downsampleFactor); + downsample.prepare (smallBufferSpec, SpringReverbConstants::downsampleFactor); + upsample.prepare (smallBufferSpec, SpringReverbConstants::downsampleFactor); - fs = (float) spec.sampleRate / (float) downsampleFactor; - blockSize = upsampledBlockSize / downsampleFactor; + fs = (float) spec.sampleRate / (float) SpringReverbConstants::downsampleFactor; + blockSize = upsampledBlockSize / SpringReverbConstants::downsampleFactor; downsampledBuffer.setSize (2, blockSize); dsp::ProcessSpec dsSpec { (double) fs, (uint32) blockSize, 2 }; delay.prepare (dsSpec); @@ -47,7 +47,7 @@ int SpringReverb::prepareRebuffering (const dsp::ProcessSpec& spec) z[1] = 0.0f; shakeCounter = -1; - shakeBuffer.setSize (1, int (fs * largeShakeSeconds * 3.0f) + blockSize); + shakeBuffer.setSize (1, int (fs * SpringReverbConstants::largeShakeSeconds * 3.0f) + blockSize); shortShakeBuffer.setSize (1, blockSize); return upsampledBlockSize; @@ -63,7 +63,7 @@ void SpringReverb::setParams (const Params& params) if (params.shake && shakeCounter < 0) // start shaking { float shakeAmount = rand.nextFloat(); - float shakeSeconds = smallShakeSeconds + (largeShakeSeconds - smallShakeSeconds) * shakeAmount; + float shakeSeconds = SpringReverbConstants::smallShakeSeconds + (SpringReverbConstants::largeShakeSeconds - SpringReverbConstants::smallShakeSeconds) * shakeAmount; shakeSeconds *= 1.0f + 0.5f * params.size; shakeCounter = int (fs * shakeSeconds); diff --git a/src/processors/tone/BigMuffTone.cpp b/src/processors/tone/BigMuffTone.cpp index bdc49b2c..1933f364 100644 --- a/src/processors/tone/BigMuffTone.cpp +++ b/src/processors/tone/BigMuffTone.cpp @@ -2,7 +2,7 @@ #include "processors/ParameterHelpers.h" #include "processors/netlist_helpers/CircuitQuantity.h" -namespace +namespace BigMuffToneComponents { auto createComponentSets() { @@ -24,7 +24,7 @@ auto createComponentSets() } // namespace BigMuffTone::BigMuffTone (UndoManager* um) : BaseProcessor ("Muff Tone", createParameterLayout(), um), - componentSets (createComponentSets()) + componentSets (BigMuffToneComponents::createComponentSets()) { using namespace ParameterHelpers; loadParameterPointer (toneParam, vts, "tone"); @@ -107,7 +107,7 @@ ParamLayout BigMuffTone::createParameterLayout() StringArray types; types.ensureStorageAllocated ((int) numComponentSets); - for (const auto& set : createComponentSets()) + for (const auto& set : BigMuffToneComponents::createComponentSets()) types.add (set.name.data()); emplace_param (params, "type", "Type", types, 2); diff --git a/src/processors/tone/BlondeTone.cpp b/src/processors/tone/BlondeTone.cpp index 7be1380c..1ea2c285 100644 --- a/src/processors/tone/BlondeTone.cpp +++ b/src/processors/tone/BlondeTone.cpp @@ -1,7 +1,7 @@ #include "BlondeTone.h" #include "../ParameterHelpers.h" -namespace +namespace BlondeToneTags { const String bassTag = "bass"; const String midTag = "mid"; @@ -11,9 +11,9 @@ const String trebleTag = "treble"; BlondeTone::BlondeTone (UndoManager* um) : BaseProcessor ("Blonde Tone", createParameterLayout(), um) { using namespace ParameterHelpers; - loadParameterPointer (bassParam, vts, bassTag); - loadParameterPointer (midsParam, vts, midTag); - loadParameterPointer (trebleParam, vts, trebleTag); + loadParameterPointer (bassParam, vts, BlondeToneTags::bassTag); + loadParameterPointer (midsParam, vts, BlondeToneTags::midTag); + loadParameterPointer (trebleParam, vts, BlondeToneTags::trebleTag); magic_enum::enum_for_each ([this] (auto val) { filters.setBandOnOff (val, true); }); @@ -29,9 +29,9 @@ ParamLayout BlondeTone::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - createBipolarPercentParameter (params, bassTag, "Bass", 0.0f); - createBipolarPercentParameter (params, midTag, "Mids", 0.0f); - createBipolarPercentParameter (params, trebleTag, "Treble", 0.0f); + createBipolarPercentParameter (params, BlondeToneTags::bassTag, "Bass", 0.0f); + createBipolarPercentParameter (params, BlondeToneTags::midTag, "Mids", 0.0f); + createBipolarPercentParameter (params, BlondeToneTags::trebleTag, "Treble", 0.0f); return { params.begin(), params.end() }; } diff --git a/src/processors/tone/GraphicEQ.cpp b/src/processors/tone/GraphicEQ.cpp index 63f301d6..ba63f048 100644 --- a/src/processors/tone/GraphicEQ.cpp +++ b/src/processors/tone/GraphicEQ.cpp @@ -1,7 +1,7 @@ #include "GraphicEQ.h" #include "../ParameterHelpers.h" -namespace +namespace GraphicEQParams { const StringArray freqLabels { "100", "220", "500", "1k", "2.2k", "5k" }; @@ -34,7 +34,7 @@ ParamLayout GraphicEQ::createParameterLayout() auto params = createBaseParams(); for (int i = 0; i < nBands; ++i) - createGainDBParameter (params, "gain_" + String (i), freqLabels[i], -12.0f, 12.0f, 0.0f); + createGainDBParameter (params, "gain_" + String (i), GraphicEQParams::freqLabels[i], -12.0f, 12.0f, 0.0f); return { params.begin(), params.end() }; } @@ -71,7 +71,7 @@ void GraphicEQ::processAudio (AudioBuffer& buffer) for (int n = 0; n < numSamples; ++n) { auto curGainDB = gainDBSmooth[ch][i].getNextValue(); - auto curQ = calcQ (curGainDB); + auto curQ = GraphicEQParams::calcQ (curGainDB); filter[ch][i].calcCoefsDB (bandFreqs[i], curQ, curGainDB, fs); x[n] = filter[ch][i].processSample (x[n]); } @@ -79,7 +79,7 @@ void GraphicEQ::processAudio (AudioBuffer& buffer) else { auto curGainDB = gainDBSmooth[ch][i].getNextValue(); - auto curQ = calcQ (curGainDB); + auto curQ = GraphicEQParams::calcQ (curGainDB); filter[ch][i].calcCoefsDB (bandFreqs[i], curQ, curGainDB, fs); filter[ch][i].processBlock (x, numSamples); } diff --git a/src/processors/tone/HighCut.cpp b/src/processors/tone/HighCut.cpp index 04e57ac6..18eb9563 100644 --- a/src/processors/tone/HighCut.cpp +++ b/src/processors/tone/HighCut.cpp @@ -1,7 +1,7 @@ #include "HighCut.h" #include "../ParameterHelpers.h" -namespace +namespace HighCutParams { constexpr float freq2Rv2 (float cutoff, float C8, float R3) { @@ -35,7 +35,7 @@ void HighCut::prepare (double sampleRate, int samplesPerBlock) fs = (float) sampleRate; Rv2.reset (sampleRate, 0.025); - Rv2.setCurrentAndTargetValue (freq2Rv2 (*cutoffParam, C8, R3)); + Rv2.setCurrentAndTargetValue (HighCutParams::freq2Rv2 (*cutoffParam, C8, R3)); calcCoefs (Rv2.getCurrentValue()); for (auto& filt : iir) @@ -46,7 +46,7 @@ void HighCut::processAudio (AudioBuffer& buffer) { const auto numChannels = buffer.getNumChannels(); - Rv2.setTargetValue (freq2Rv2 (*cutoffParam, C8, R3)); + Rv2.setTargetValue (HighCutParams::freq2Rv2 (*cutoffParam, C8, R3)); auto x = buffer.getArrayOfWritePointers(); if (Rv2.isSmoothing()) diff --git a/src/processors/tone/LofiIrs.cpp b/src/processors/tone/LofiIrs.cpp index 248fe847..ff9c4279 100644 --- a/src/processors/tone/LofiIrs.cpp +++ b/src/processors/tone/LofiIrs.cpp @@ -1,7 +1,7 @@ #include "LofiIrs.h" #include "../ParameterHelpers.h" -namespace +namespace LofiIRTags { const StringArray irNames { "Casio 1", @@ -24,7 +24,7 @@ const String gainTag = "gain"; LofiIrs::LofiIrs (UndoManager* um) : BaseProcessor ("LoFi IRs", createParameterLayout(), um), convolution (getSharedConvolutionMessageQueue()) { - for (const auto& irName : irNames) + for (const auto& irName : LofiIRTags::irNames) { auto binaryName = irName.replaceCharacter (' ', '_') + "_wav"; int binarySize; @@ -34,9 +34,9 @@ LofiIrs::LofiIrs (UndoManager* um) : BaseProcessor ("LoFi IRs", createParameterL } using namespace ParameterHelpers; - vts.addParameterListener (irTag, this); - loadParameterPointer (mixParam, vts, mixTag); - loadParameterPointer (gainParam, vts, gainTag); + vts.addParameterListener (LofiIRTags::irTag, this); + loadParameterPointer (mixParam, vts, LofiIRTags::mixTag); + loadParameterPointer (gainParam, vts, LofiIRTags::gainTag); uiOptions.backgroundColour = Colours::darkgrey.brighter (0.15f); uiOptions.powerColour = Colours::red.darker (0.1f); @@ -46,7 +46,7 @@ LofiIrs::LofiIrs (UndoManager* um) : BaseProcessor ("LoFi IRs", createParameterL LofiIrs::~LofiIrs() { - vts.removeParameterListener (irTag, this); + vts.removeParameterListener (LofiIRTags::irTag, this); } ParamLayout LofiIrs::createParameterLayout() @@ -54,24 +54,24 @@ ParamLayout LofiIrs::createParameterLayout() using namespace ParameterHelpers; auto params = createBaseParams(); - params.push_back (std::make_unique (irTag, + params.push_back (std::make_unique (LofiIRTags::irTag, "IR", - irNames, + LofiIRTags::irNames, 0)); - createGainDBParameter (params, gainTag, "Gain", -18.0f, 18.0f, 0.0f); - createPercentParameter (params, mixTag, "Mix", 1.0f); + createGainDBParameter (params, LofiIRTags::gainTag, "Gain", -18.0f, 18.0f, 0.0f); + createPercentParameter (params, LofiIRTags::mixTag, "Mix", 1.0f); return { params.begin(), params.end() }; } void LofiIrs::parameterChanged (const String& parameterID, float newValue) { - if (parameterID != irTag) + if (parameterID != LofiIRTags::irTag) return; auto irIdx = (int) newValue; - auto& irData = irMap[irNames[irIdx]]; + auto& irData = irMap[LofiIRTags::irNames[irIdx]]; convolution.loadImpulseResponse (irData.first, irData.second, dsp::Convolution::Stereo::yes, dsp::Convolution::Trim::yes, 0); } @@ -79,7 +79,7 @@ void LofiIrs::prepare (double sampleRate, int samplesPerBlock) { dsp::ProcessSpec spec { sampleRate, (uint32) samplesPerBlock, 2 }; convolution.prepare (spec); - parameterChanged (irTag, vts.getRawParameterValue (irTag)->load()); + parameterChanged (LofiIRTags::irTag, vts.getRawParameterValue (LofiIRTags::irTag)->load()); gain.prepare (spec); gain.setRampDurationSeconds (0.01); diff --git a/src/processors/tone/StateVariableFilter.cpp b/src/processors/tone/StateVariableFilter.cpp index ea22c683..e5560bb2 100644 --- a/src/processors/tone/StateVariableFilter.cpp +++ b/src/processors/tone/StateVariableFilter.cpp @@ -2,7 +2,7 @@ #include "../ParameterHelpers.h" #include "gui/utils/ModulatableSlider.h" -namespace +namespace SVFTags { const String modeTag = "mode"; const String multiModeTag = "multi_mode"; @@ -14,11 +14,11 @@ StateVariableFilter::StateVariableFilter (UndoManager* um) : BaseProcessor ("SVF using namespace ParameterHelpers; loadParameterPointer (freqParam, vts, "freq"); loadParameterPointer (qParam, vts, "q_value"); - modeParam = vts.getRawParameterValue (modeTag); - multiModeOnOffParam = vts.getRawParameterValue (multiModeTag); - loadParameterPointer (multiModeParam, vts, multiModeTypeTag); + modeParam = vts.getRawParameterValue (SVFTags::modeTag); + multiModeOnOffParam = vts.getRawParameterValue (SVFTags::multiModeTag); + loadParameterPointer (multiModeParam, vts, SVFTags::multiModeTypeTag); - addPopupMenuParameter (multiModeTag); + addPopupMenuParameter (SVFTags::multiModeTag); uiOptions.backgroundColour = Colours::blanchedalmond; uiOptions.powerColour = Colours::red.darker (0.25f); @@ -43,13 +43,13 @@ ParamLayout StateVariableFilter::createParameterLayout() &stringToFloatVal); emplace_param (params, - modeTag, + SVFTags::modeTag, "Mode", StringArray { "LPF", "HPF", "BPF" }, 0); - emplace_param (params, multiModeTag, "Multi-Mode", true); - createPercentParameter (params, multiModeTypeTag, "Mode", 0.0f); + emplace_param (params, SVFTags::multiModeTag, "Multi-Mode", true); + createPercentParameter (params, SVFTags::multiModeTypeTag, "Mode", 0.0f); return { params.begin(), params.end() }; } @@ -135,7 +135,7 @@ void StateVariableFilter::fromXML (XmlElement* xml, const chowdsp::Version& vers { // Multi-mode behaviour was only added in version 1.0.2, so we need to // make sure we don't break older patches. - vts.getParameter (multiModeTag)->setValueNotifyingHost (0.0f); + vts.getParameter (SVFTags::multiModeTag)->setValueNotifyingHost (0.0f); } } @@ -147,11 +147,11 @@ bool StateVariableFilter::getCustomComponents (OwnedArray& customComp public: ModeControl (AudioProcessorValueTreeState& vtState, chowdsp::HostContextProvider& hcp) : vts (vtState), - modeSelectorAttach (vts, modeTag, modeSelector), - multiModeSlider (*getParameterPointer (vts, multiModeTypeTag), hcp), - multiModeAttach (vts, multiModeTypeTag, multiModeSlider), + modeSelectorAttach (vts, SVFTags::modeTag, modeSelector), + multiModeSlider (*getParameterPointer (vts, SVFTags::multiModeTypeTag), hcp), + multiModeAttach (vts, SVFTags::multiModeTypeTag, multiModeSlider), multiModeOnOffAttach ( - *vts.getParameter (multiModeTag), + *vts.getParameter (SVFTags::multiModeTag), [this] (float newValue) { updateControlVisibility (newValue == 1.0f); }, vts.undoManager) @@ -159,7 +159,7 @@ bool StateVariableFilter::getCustomComponents (OwnedArray& customComp addChildComponent (modeSelector); addChildComponent (multiModeSlider); - const auto* modeChoiceParam = getParameterPointer (vts, modeTag); + const auto* modeChoiceParam = getParameterPointer (vts, SVFTags::modeTag); modeSelector.addItemList (modeChoiceParam->choices, 1); modeSelector.setSelectedItemIndex (0); modeSelector.setScrollWheelEnabled (true); @@ -167,7 +167,7 @@ bool StateVariableFilter::getCustomComponents (OwnedArray& customComp hcp.registerParameterComponent (multiModeSlider, multiModeSlider.getParameter()); - this->setName (modeTag + "__" + multiModeTypeTag + "__"); + Component::setName (SVFTags::modeTag + "__" + SVFTags::multiModeTypeTag + "__"); } void colourChanged() override @@ -194,12 +194,12 @@ bool StateVariableFilter::getCustomComponents (OwnedArray& customComp modeSelector.setVisible (! multiModeOn); multiModeSlider.setVisible (multiModeOn); - setName (vts.getParameter (multiModeOn ? multiModeTypeTag : modeTag)->name); + setName (vts.getParameter (multiModeOn ? SVFTags::multiModeTypeTag : SVFTags::modeTag)->name); } void visibilityChanged() override { - updateControlVisibility (vts.getRawParameterValue (multiModeTag)->load() == 1.0f); + updateControlVisibility (vts.getRawParameterValue (SVFTags::multiModeTag)->load() == 1.0f); } void resized() override diff --git a/src/processors/tone/amp_irs/AmpIRsSaveLoad.cpp b/src/processors/tone/amp_irs/AmpIRsSaveLoad.cpp index 89805e3a..9d05f16a 100644 --- a/src/processors/tone/amp_irs/AmpIRsSaveLoad.cpp +++ b/src/processors/tone/amp_irs/AmpIRsSaveLoad.cpp @@ -66,7 +66,7 @@ void AmpIRs::loadIRFromCurrentState() loadIRFromStream (std::make_unique (*irState.data, true), irState.name, irState.file, nullptr); } -namespace +namespace AmpIRSaveLoadTags { const String irNameTag { "ir_custom_name" }; const String irDataTag { "ir_custom_data" }; @@ -79,10 +79,10 @@ std::unique_ptr AmpIRs::toXML() if (irState.data != nullptr) { - xml->setAttribute (irNameTag, irState.name); - xml->setAttribute (irDataTag, Base64::toBase64 (irState.data->getData(), irState.data->getSize())); + xml->setAttribute (AmpIRSaveLoadTags::irNameTag, irState.name); + xml->setAttribute (AmpIRSaveLoadTags::irDataTag, Base64::toBase64 (irState.data->getData(), irState.data->getSize())); if (irState.file != File {}) - xml->setAttribute (irFileTag, irState.file.getFullPathName()); + xml->setAttribute (AmpIRSaveLoadTags::irFileTag, irState.file.getFullPathName()); } return std::move (xml); @@ -95,12 +95,12 @@ void AmpIRs::fromXML (XmlElement* xml, const chowdsp::Version& version, bool loa using namespace chowdsp::version_literals; if (version >= "1.1.4"_v) { - if (xml->hasAttribute (irNameTag) && xml->hasAttribute (irDataTag)) + if (xml->hasAttribute (AmpIRSaveLoadTags::irNameTag) && xml->hasAttribute (AmpIRSaveLoadTags::irDataTag)) { - irState.name = xml->getStringAttribute (irNameTag); - irState.file = xml->getStringAttribute (irFileTag); + irState.name = xml->getStringAttribute (AmpIRSaveLoadTags::irNameTag); + irState.file = xml->getStringAttribute (AmpIRSaveLoadTags::irFileTag); - const auto& irDataRaw = xml->getStringAttribute (irDataTag); + const auto& irDataRaw = xml->getStringAttribute (AmpIRSaveLoadTags::irDataTag); MemoryOutputStream outStream { (size_t) irDataRaw.length() }; const auto successfulRead = Base64::convertFromBase64 (outStream, irDataRaw); if (! successfulRead) diff --git a/src/processors/tone/amp_irs/AmpIRsSelector.cpp b/src/processors/tone/amp_irs/AmpIRsSelector.cpp index b12444cc..d6ff158d 100644 --- a/src/processors/tone/amp_irs/AmpIRsSelector.cpp +++ b/src/processors/tone/amp_irs/AmpIRsSelector.cpp @@ -1,6 +1,6 @@ #include "AmpIRs.h" -namespace +namespace AmpIRFileUtils { constexpr chowdsp::GlobalPluginSettings::SettingID userIRFolderID { "user_ir_folder" }; @@ -109,7 +109,7 @@ struct AmpIRsSelector : ComboBox, chowdsp::TrackedByBroadcasters AmpIRsSelector (AudioProcessorValueTreeState& vtState, AmpIRs& proc, chowdsp::HostContextProvider& hcp) : ampIRs (proc), vts (vtState) { - pluginSettings->addProperties<&AmpIRsSelector::globalSettingChanged> ({ { userIRFolderID, String() } }, *this); + pluginSettings->addProperties<&AmpIRsSelector::globalSettingChanged> ({ { AmpIRFileUtils::userIRFolderID, String() } }, *this); refreshUserIRs(); refreshBox(); @@ -132,7 +132,7 @@ struct AmpIRsSelector : ComboBox, chowdsp::TrackedByBroadcasters void globalSettingChanged (chowdsp::GlobalPluginSettings::SettingID settingID) { - if (settingID != userIRFolderID) + if (settingID != AmpIRFileUtils::userIRFolderID) return; refreshUserIRs(); @@ -167,7 +167,7 @@ struct AmpIRsSelector : ComboBox, chowdsp::TrackedByBroadcasters } if (userIRFiles.size() > 0) - menu->addSubMenu ("User:", IRFileTree::createPopupMenu (menuIdx, userIRFiles.getNodes(), ampIRs, getTopLevelComponent())); + menu->addSubMenu ("User:", AmpIRFileUtils::IRFileTree::createPopupMenu (menuIdx, userIRFiles.getNodes(), ampIRs, getTopLevelComponent())); menu->addSeparator(); @@ -305,7 +305,7 @@ struct AmpIRsSelector : ComboBox, chowdsp::TrackedByBroadcasters void refreshUserIRs() { - const auto userIRsFolder = File { pluginSettings->getProperty (userIRFolderID) }; + const auto userIRsFolder = File { pluginSettings->getProperty (AmpIRFileUtils::userIRFolderID) }; if (! userIRsFolder.isDirectory()) return; @@ -357,7 +357,7 @@ struct AmpIRsSelector : ComboBox, chowdsp::TrackedByBroadcasters if (fc.getResults().isEmpty()) return; const auto irFile = fc.getResult(); - pluginSettings->setProperty (userIRFolderID, irFile.getFullPathName()); + pluginSettings->setProperty (AmpIRFileUtils::userIRFolderID, irFile.getFullPathName()); }); } @@ -367,7 +367,7 @@ struct AmpIRsSelector : ComboBox, chowdsp::TrackedByBroadcasters chowdsp::ScopedCallback onIRChanged; chowdsp::SharedPluginSettings pluginSettings; - IRFileTree userIRFiles; + AmpIRFileUtils::IRFileTree userIRFiles; }; bool AmpIRs::getCustomComponents (OwnedArray& customComps, chowdsp::HostContextProvider& hcp) diff --git a/src/processors/tone/baxandall/BaxandallEQ.cpp b/src/processors/tone/baxandall/BaxandallEQ.cpp index bc268ae3..0ea3aa5c 100644 --- a/src/processors/tone/baxandall/BaxandallEQ.cpp +++ b/src/processors/tone/baxandall/BaxandallEQ.cpp @@ -2,7 +2,7 @@ #include "processors/ParameterHelpers.h" #include "processors/netlist_helpers/CircuitQuantity.h" -namespace +namespace BaxandallParams { float skewParam (float val) { @@ -155,10 +155,10 @@ void BaxandallEQ::prepare (double sampleRate, int /*samplesPerBlock*/) wdfCircuit[ch].prepare (sampleRate); bassSmooth[ch].reset (sampleRate, 0.05); - bassSmooth[ch].setCurrentAndTargetValue (skewParam (*bassParam)); + bassSmooth[ch].setCurrentAndTargetValue (BaxandallParams::skewParam (*bassParam)); trebleSmooth[ch].reset (sampleRate, 0.05); - trebleSmooth[ch].setCurrentAndTargetValue (skewParam (*trebleParam)); + trebleSmooth[ch].setCurrentAndTargetValue (BaxandallParams::skewParam (*trebleParam)); } } @@ -169,8 +169,8 @@ void BaxandallEQ::processAudio (AudioBuffer& buffer) for (int ch = 0; ch < numChannels; ++ch) { - bassSmooth[ch].setTargetValue (skewParam (*bassParam)); - trebleSmooth[ch].setTargetValue (skewParam (*trebleParam)); + bassSmooth[ch].setTargetValue (BaxandallParams::skewParam (*bassParam)); + trebleSmooth[ch].setTargetValue (BaxandallParams::skewParam (*trebleParam)); auto* x = buffer.getWritePointer (ch); if (bassSmooth[ch].isSmoothing() || trebleSmooth[ch].isSmoothing()) diff --git a/src/processors/utility/CleanGain.cpp b/src/processors/utility/CleanGain.cpp index baa519cb..db330804 100644 --- a/src/processors/utility/CleanGain.cpp +++ b/src/processors/utility/CleanGain.cpp @@ -2,7 +2,7 @@ #include "../ParameterHelpers.h" #include "gui/utils/ModulatableSlider.h" -namespace +namespace GainTags { const String gainTag = "gain"; const String invertTag = "invert"; @@ -17,24 +17,24 @@ const Colour invertedColour = Colours::red; CleanGain::CleanGain (UndoManager* um) : BaseProcessor ("Clean Gain", createParameterLayout(), um), invertAttach ( - *vts.getParameter (invertTag), + *vts.getParameter (GainTags::invertTag), [this] (float newValue) { - uiOptions.powerColour = newValue > 0.5f ? invertedColour : regularColour; + uiOptions.powerColour = newValue > 0.5f ? GainTags::invertedColour : GainTags::regularColour; uiOptionsChanged(); }, um) { - chowdsp::ParamUtils::loadParameterPointer (gainDBParam, vts, gainTag); - chowdsp::ParamUtils::loadParameterPointer (extGainDBParam, vts, extGainTag); - chowdsp::ParamUtils::loadParameterPointer (invertParam, vts, invertTag); - chowdsp::ParamUtils::loadParameterPointer (extendParam, vts, extendTag); + chowdsp::ParamUtils::loadParameterPointer (gainDBParam, vts, GainTags::gainTag); + chowdsp::ParamUtils::loadParameterPointer (extGainDBParam, vts, GainTags::extGainTag); + chowdsp::ParamUtils::loadParameterPointer (invertParam, vts, GainTags::invertTag); + chowdsp::ParamUtils::loadParameterPointer (extendParam, vts, GainTags::extendTag); - addPopupMenuParameter (invertTag); - addPopupMenuParameter (extendTag); + addPopupMenuParameter (GainTags::invertTag); + addPopupMenuParameter (GainTags::extendTag); uiOptions.backgroundColour = Colours::darkgrey.brighter (0.35f).withRotatedHue (0.25f); - uiOptions.powerColour = regularColour; + uiOptions.powerColour = GainTags::regularColour; uiOptions.info.description = "Simple linear gain boost."; uiOptions.info.authors = StringArray { "Jatin Chowdhury" }; } @@ -43,22 +43,22 @@ ParamLayout CleanGain::createParameterLayout() { using namespace ParameterHelpers; auto params = createBaseParams(); - createGainDBParameter (params, gainTag, "Gain", -18.0f, 18.0f, 0.0f); + createGainDBParameter (params, GainTags::gainTag, "Gain", -18.0f, 18.0f, 0.0f); const auto extGainToString = [] (float x) - { return x <= negativeInfinityDB ? "-inf dB" : String (x, 2, false) + " dB"; }; + { return x <= GainTags::negativeInfinityDB ? "-inf dB" : String (x, 2, false) + " dB"; }; auto stringToExtGain = [] (const String& t) { return t.getFloatValue(); }; emplace_param (params, - extGainTag, + GainTags::extGainTag, "Extended Gain", - createNormalisableRange (negativeInfinityDB, 30.0f, 0.0f), + createNormalisableRange (GainTags::negativeInfinityDB, 30.0f, 0.0f), 0.0f, extGainToString, stringToExtGain); - emplace_param (params, invertTag, "Invert", false); - emplace_param (params, extendTag, "Extend", false); + emplace_param (params, GainTags::invertTag, "Invert", false); + emplace_param (params, GainTags::extendTag, "Extend", false); return { params.begin(), params.end() }; } @@ -74,7 +74,7 @@ void CleanGain::processAudio (AudioBuffer& buffer) { const auto invertGain = invertParam->get() ? -1.0f : 1.0f; const auto gainDB = extendParam->get() ? extGainDBParam->getCurrentValue() : gainDBParam->getCurrentValue(); - const auto gainLinear = gainDB <= negativeInfinityDB ? 0.0f : Decibels::decibelsToGain (gainDB) * invertGain; + const auto gainLinear = gainDB <= GainTags::negativeInfinityDB ? 0.0f : Decibels::decibelsToGain (gainDB) * invertGain; gain.setGainLinear (gainLinear); dsp::AudioBlock block { buffer }; @@ -90,12 +90,12 @@ bool CleanGain::getCustomComponents (OwnedArray& customComps, chowdsp public: GainSlider (AudioProcessorValueTreeState& vtState, chowdsp::HostContextProvider& hcp) : vts (vtState), - gainSlider (*getParameterPointer (vts, gainTag), hcp), - extGainSlider (*getParameterPointer (vts, extGainTag), hcp), - gainAttach (vts, gainTag, gainSlider), - extGainAttach (vts, extGainTag, extGainSlider), + gainSlider (*getParameterPointer (vts, GainTags::gainTag), hcp), + extGainSlider (*getParameterPointer (vts, GainTags::extGainTag), hcp), + gainAttach (vts, GainTags::gainTag, gainSlider), + extGainAttach (vts, GainTags::extGainTag, extGainSlider), extendAttach ( - *vts.getParameter (extendTag), + *vts.getParameter (GainTags::extendTag), [this] (float newValue) { updateSliderVisibility (newValue == 1.0f); }, vts.undoManager) @@ -106,7 +106,7 @@ bool CleanGain::getCustomComponents (OwnedArray& customComps, chowdsp hcp.registerParameterComponent (gainSlider, gainSlider.getParameter()); hcp.registerParameterComponent (extGainSlider, extGainSlider.getParameter()); - Slider::setName (gainTag + "__" + extGainTag + "__"); + Slider::setName (GainTags::gainTag + "__" + GainTags::extGainTag + "__"); } void colourChanged() override @@ -134,7 +134,7 @@ bool CleanGain::getCustomComponents (OwnedArray& customComps, chowdsp void visibilityChanged() override { - updateSliderVisibility (vts.getRawParameterValue (extendTag)->load() == 1.0f); + updateSliderVisibility (vts.getRawParameterValue (GainTags::extendTag)->load() == 1.0f); } void resized() override diff --git a/src/processors/utility/Oscilloscope.cpp b/src/processors/utility/Oscilloscope.cpp index 3aff0d40..3b81ad8c 100644 --- a/src/processors/utility/Oscilloscope.cpp +++ b/src/processors/utility/Oscilloscope.cpp @@ -1,7 +1,7 @@ #include "Oscilloscope.h" #include "../ParameterHelpers.h" -namespace +namespace ScopeConstants { constexpr int scopeFps = 30; } @@ -58,7 +58,7 @@ void Oscilloscope::ScopeBackgroundTask::prepareTask (double sampleRate, int /*sa requstedBlockSize = samplesToDisplay + triggerBuffer; - waitMs = int (1000.0 / (double) scopeFps); + waitMs = int (1000.0 / (double) ScopeConstants::scopeFps); } void Oscilloscope::ScopeBackgroundTask::resetTask() @@ -121,7 +121,7 @@ bool Oscilloscope::getCustomComponents (OwnedArray& customComps, chow explicit ScopeComp (ScopeBackgroundTask& sTask) : scopeTask (sTask) { scopeTask.setShouldBeRunning (true); - startTimerHz (scopeFps); + startTimerHz (ScopeConstants::scopeFps); } ~ScopeComp() override diff --git a/src/processors/utility/Tuner.cpp b/src/processors/utility/Tuner.cpp index dcc2d32c..f2425052 100644 --- a/src/processors/utility/Tuner.cpp +++ b/src/processors/utility/Tuner.cpp @@ -1,7 +1,7 @@ #include "Tuner.h" #include "../ParameterHelpers.h" -namespace +namespace TunerConstants { constexpr int tunerRefreshHz = 24; } @@ -55,7 +55,7 @@ void Tuner::TunerBackgroundTask::prepareTask (double sampleRate, int /*samplesPe tuner.prepare (sampleRate); requestedBlockSize = tuner.getAutocorrelationSize(); - freqValSmoother.reset ((double) tunerRefreshHz, 0.15); + freqValSmoother.reset ((double) TunerConstants::tunerRefreshHz, 0.15); freqValSmoother.setCurrentAndTargetValue ((double) tuner.getCurrentFrequencyHz()); } @@ -85,7 +85,7 @@ bool Tuner::getCustomComponents (OwnedArray& customComps, chowdsp::Ho explicit TunerComp (TunerBackgroundTask& tTask) : tunerTask (tTask) { tunerTask.setShouldBeRunning (true); - startTimerHz (tunerRefreshHz); + startTimerHz (TunerConstants::tunerRefreshHz); } ~TunerComp() override diff --git a/src/state/StateManager.cpp b/src/state/StateManager.cpp index c7a0b5e8..9db45a5d 100644 --- a/src/state/StateManager.cpp +++ b/src/state/StateManager.cpp @@ -2,7 +2,7 @@ #include "gui/GUIConstants.h" #include "processors/chain/ProcessorChainStateHelper.h" -namespace +namespace StateManagerTags { const Identifier statePluginVersionTag = "state_plugin_version"; } @@ -18,12 +18,12 @@ StateManager::StateManager (AudioProcessorValueTreeState& vtState, ProcessorChai void StateManager::setCurrentPluginVersionInXML (XmlElement* xml) { - xml->setAttribute (statePluginVersionTag, JucePlugin_VersionString); + xml->setAttribute (StateManagerTags::statePluginVersionTag, JucePlugin_VersionString); } chowdsp::Version StateManager::getPluginVersionFromXML (const XmlElement* xml) { - return chowdsp::Version { xml->getStringAttribute (statePluginVersionTag, "1.0.1") }; + return chowdsp::Version { xml->getStringAttribute (StateManagerTags::statePluginVersionTag, "1.0.1") }; } std::unique_ptr StateManager::saveState() diff --git a/src/state/presets/PresetManager.cpp b/src/state/presets/PresetManager.cpp index 884c6446..35015c0f 100644 --- a/src/state/presets/PresetManager.cpp +++ b/src/state/presets/PresetManager.cpp @@ -8,11 +8,6 @@ #include #endif -namespace -{ -const String presetTag = "preset"; -} // namespace - class ChangePresetAction : public UndoableAction { public: