Skip to content

Commit

Permalink
No more anonymous namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Dec 6, 2023
1 parent 97d6c0b commit 6286a9a
Show file tree
Hide file tree
Showing 49 changed files with 425 additions and 425 deletions.
8 changes: 4 additions & 4 deletions src/BYOD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
#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";
const String logFileNameRoot = "BYOD_Log_";
} // namespace

BYOD::BYOD() : chowdsp::PluginBase<BYOD> (&undoManager),
logger ({ .logFileSubDir = logFileSubDir,
.logFileNameRoot = logFileNameRoot,
logger ({ .logFileSubDir = BYODPaths::logFileSubDir,
.logFileNameRoot = BYODPaths::logFileNameRoot,
.crashLogAnalysisCallback = [this] (const File& logFile)
{ crashLogFile.emplace (logFile); } }),
procStore (&undoManager)
Expand All @@ -23,7 +23,7 @@ BYOD::BYOD() : chowdsp::PluginBase<BYOD> (&undoManager),

Logger::writeToLog (chowdsp::PluginDiagnosticInfo::getDiagnosticsString (*this));

pluginSettings->initialise (settingsFilePath);
pluginSettings->initialise (BYODPaths::settingsFilePath);
procs = std::make_unique<ProcessorChain> (procStore, vts, presetManager, paramForwarder, [&] (int l)
{ updateSampleLatency (l); });
paramForwarder = std::make_unique<ParamForwardManager> (vts, *procs);
Expand Down
22 changes: 11 additions & 11 deletions src/gui/pedalboard/BoardComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "cables/CableViewConnectionHelper.h"
#include "processors/chain/ProcessorChainActionHelper.h"

namespace
namespace BoardDims
{
constexpr int editorWidth = 270;
constexpr int editorHeight = 180;
Expand Down Expand Up @@ -108,20 +108,20 @@ 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);

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<int> (jmin (400, width), jmin (250, height)).withCentre (getLocalBounds().getCentre()));

repaint();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -301,8 +301,8 @@ ProcessorEditor* BoardComponent::findEditorForProcessor (const BaseProcessor* pr

void BoardComponent::setEditorPosition (ProcessorEditor* editor, Rectangle<int> 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());
Expand Down
8 changes: 4 additions & 4 deletions src/gui/pedalboard/BoardViewport.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "BoardViewport.h"

namespace
namespace ViewportTags
{
const juce::Identifier zoomLevelTag { "zoom_level" };
}
Expand All @@ -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<double> (defaultZoomSettingID), nullptr);
scaleFactor = vts.state.getPropertyAsValue (zoomLevelTag, nullptr, true);
if (! vts.state.hasProperty (ViewportTags::zoomLevelTag))
vts.state.setProperty (ViewportTags::zoomLevelTag, pluginSettings->getProperty<double> (defaultZoomSettingID), nullptr);
scaleFactor = vts.state.getPropertyAsValue (ViewportTags::zoomLevelTag, nullptr, true);
setScaleFactor ((float) scaleFactor.getValue());

toggleTooltips (pluginSettings->getProperty<bool> (portTooltipsSettingID));
Expand Down
14 changes: 7 additions & 7 deletions src/gui/pedalboard/cables/CableViewConnectionHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
Expand All @@ -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)
{
Expand All @@ -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;
Expand All @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/gui/pedalboard/cables/CableViewPortLocationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../BoardComponent.h"
#include "CableDrawingHelpers.h"

namespace
namespace CableViewHelperMethods
{
bool wouldConnectingCreateFeedbackLoop (const BaseProcessor* sourceProc, const BaseProcessor* destProc, const OwnedArray<Cable>& cables)
{
Expand Down Expand Up @@ -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 {};
Expand All @@ -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 {};
Expand Down
6 changes: 3 additions & 3 deletions src/gui/pedalboard/editors/KnobsComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "gui/utils/LookAndFeels.h"
#include "processors/BaseProcessor.h"

namespace
namespace KnobDims
{
constexpr float nameHeightScale = 0.115f;
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/gui/pedalboard/editors/ProcessorEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "processors/chain/ProcessorChainActionHelper.h"
#include "processors/netlist_helpers/CircuitQuantity.h"

namespace
namespace EditorDims
{
constexpr float cornerSize = 5.0f;
}
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/gui/toolbar/SettingsButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
6 changes: 3 additions & 3 deletions src/gui/toolbar/UndoRedoComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "UndoRedoComponent.h"

namespace
namespace UndoRedoDims
{
constexpr int buttonPad = 10;
}
Expand Down Expand Up @@ -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));
}
8 changes: 4 additions & 4 deletions src/gui/utils/LevelMeterComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "LevelMeterComponent.h"

namespace
namespace LevelMeterConstants
{
constexpr auto maxDB = 6.0f;
constexpr auto minDB = -45.0f;
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;
Expand Down Expand Up @@ -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);
};

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/processors/chain/ProcessorChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "ProcessorChainStateHelper.h"
#include "processors/chain/ChainIOProcessor.h"

namespace
namespace ChainHelperFuncs
{
[[maybe_unused]] void printBufferLevels (const AudioBuffer<float>& buffer)
{
Expand Down Expand Up @@ -199,7 +199,7 @@ void ProcessorChain::processAudio (AudioBuffer<float>& 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)
{
Expand Down
Loading

0 comments on commit 6286a9a

Please sign in to comment.