Skip to content

Commit

Permalink
Updating submodules and improved preset search (#350)
Browse files Browse the repository at this point in the history
* Updating submodules and improved preset search

* Apply clang-format

* Trying to fix CI failures

* More CI fixing

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jatinchowdhury18 and github-actions[bot] committed Feb 23, 2024
1 parent 169420b commit dd6f2f2
Show file tree
Hide file tree
Showing 41 changed files with 140 additions and 105 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/arm-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
runs-on: macos-13

steps:
- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.2'

- name: Get latest CMake
uses: lukka/get-cmake@latest

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
sudo apt-get update
sudo apt install libasound2-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libxrender-dev libfreetype6-dev libglu1-mesa-dev libjack-jackd2-dev
- name: Set Xcode version
if: runner.os == 'MacOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.2'

- name: Get latest CMake
uses: lukka/get-cmake@latest

Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
[submodule "modules/chowdsp_wdf"]
path = modules/chowdsp_wdf
url = https://github.com/Chowdhury-DSP/chowdsp_wdf
[submodule "modules/fuzzysearchdatabase"]
path = modules/fuzzysearchdatabase
url = https://bitbucket.org/j_norberg/fuzzysearchdatabase.git
[submodule "modules/ea_variant"]
path = modules/ea_variant
url = https://github.com/eyalamirmusic/Variant
Expand Down
3 changes: 2 additions & 1 deletion modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ target_link_libraries(juce_plugin_modules
chowdsp::chowdsp_rhythm
chowdsp::chowdsp_presets
chowdsp::chowdsp_serialization
chowdsp::chowdsp_logging
chowdsp::chowdsp_units
chowdsp::chowdsp_fuzzy_search
chowdsp::chowdsp_wdf
chowdsp::chowdsp_visualizers
RTNeural
Expand Down Expand Up @@ -85,7 +87,6 @@ target_include_directories(juce_plugin_modules
${CMAKE_SOURCE_DIR}/modules/magic_enum/include
${CMAKE_SOURCE_DIR}/modules/RTNeural/modules/xsimd/include
$<TARGET_PROPERTY:sst-cpputils,INTERFACE_INCLUDE_DIRECTORIES>
${CMAKE_SOURCE_DIR}/modules/fuzzysearchdatabase/src
)

set_target_properties(juce_plugin_modules PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion modules/JUCE
Submodule JUCE updated 450 files
2 changes: 1 addition & 1 deletion modules/chowdsp_utils
Submodule chowdsp_utils updated 281 files
1 change: 0 additions & 1 deletion modules/fuzzysearchdatabase
Submodule fuzzysearchdatabase deleted from 23122d
10 changes: 6 additions & 4 deletions src/BYOD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const String logFileNameRoot = "BYOD_Log_";
} // namespace BYODPaths

BYOD::BYOD() : chowdsp::PluginBase<BYOD> (&undoManager),
logger ({ .logFileSubDir = BYODPaths::logFileSubDir,
.logFileNameRoot = BYODPaths::logFileNameRoot,
.crashLogAnalysisCallback = [this] (const File& logFile)
{ crashLogFile.emplace (logFile); } }),
logger ({
.logFileSubDir = BYODPaths::logFileSubDir,
.logFileNameRoot = BYODPaths::logFileNameRoot,
},
[this] (const File& logFile)
{ crashLogFile.emplace (logFile); }),
procStore (&undoManager)
{
#if PERFETTO
Expand Down
15 changes: 12 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,20 @@ if (MSVC)
target_compile_options(BYOD PRIVATE /bigobj)
endif ()

file(GLOB_RECURSE juce_module_sources
file(GLOB_RECURSE module_sources
# JUCE module format is already unity building
${CMAKE_CURRENT_SOURCE_DIR}/../modules/JUCE/modules/juce_*/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../modules/JUCE/modules/juce_*/*.mm
${CMAKE_CURRENT_SOURCE_DIR}/../modules/JUCE/modules/chowdsp_utils/modules/*/chowdsp_*/*.cpp)
set_source_files_properties(${juce_module_sources}
${CMAKE_CURRENT_SOURCE_DIR}/../modules/JUCE/modules/chowdsp_utils/modules/*/chowdsp_*/*.cpp

# files that include "byod_jai_lib.h" have issues with unity builds
${CMAKE_CURRENT_SOURCE_DIR}/jai/SharedJaiContext.cpp
${CMAKE_CURRENT_SOURCE_DIR}/processors/other/krusher/Krusher.cpp

# already a massive cpp file!
${CMAKE_CURRENT_SOURCE_DIR}/processors/ProcessorStore.cpp
)
set_source_files_properties(${module_sources}
TARGET_DIRECTORY BYOD
PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE SKIP_UNITY_BUILD_INCLUSION TRUE)
set_target_properties(BYOD PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 8)
Expand Down
16 changes: 8 additions & 8 deletions src/gui/pedalboard/BoardComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ void BoardComponent::resized()
const auto thisEditorHeight = BoardDims::getScaleDim (BoardDims::editorHeight, scaleFactor);
auto centreEditorHeight = (height - thisEditorHeight) / 2;

setEditorPosition (inputEditor.get(), Rectangle (BoardDims::editorPad, centreEditorHeight, thisEditorWidth / 2, thisEditorHeight));
setEditorPosition (outputEditor.get(), Rectangle (width - (thisEditorWidth / 2 + BoardDims::editorPad), centreEditorHeight, thisEditorWidth / 2, thisEditorHeight));
setEditorPosition (inputEditor.get(), juce::Rectangle (BoardDims::editorPad, centreEditorHeight, thisEditorWidth / 2, thisEditorHeight));
setEditorPosition (outputEditor.get(), juce::Rectangle (width - (thisEditorWidth / 2 + BoardDims::editorPad), centreEditorHeight, thisEditorWidth / 2, thisEditorHeight));

for (auto* editor : processorEditors)
setEditorPosition (editor);
Expand All @@ -122,7 +122,7 @@ void BoardComponent::resized()
cableView.updateCablePositions();

newProcButton.setBounds (width - BoardDims::newButtonWidth, 0, BoardDims::newButtonWidth, BoardDims::newButtonWidth);
infoComp.setBounds (Rectangle<int> (jmin (400, width), jmin (250, height)).withCentre (getLocalBounds().getCentre()));
infoComp.setBounds (juce::Rectangle<int> (jmin (400, width), jmin (250, height)).withCentre (getLocalBounds().getCentre()));

repaint();
}
Expand Down Expand Up @@ -299,7 +299,7 @@ ProcessorEditor* BoardComponent::findEditorForProcessor (const BaseProcessor* pr
return nullptr;
}

void BoardComponent::setEditorPosition (ProcessorEditor* editor, Rectangle<int> bounds)
void BoardComponent::setEditorPosition (ProcessorEditor* editor, juce::Rectangle<int> bounds)
{
const auto thisEditorWidth = BoardDims::getScaleDim (BoardDims::editorWidth, scaleFactor);
const auto thisEditorHeight = BoardDims::getScaleDim (BoardDims::editorHeight, scaleFactor);
Expand All @@ -308,17 +308,17 @@ void BoardComponent::setEditorPosition (ProcessorEditor* editor, Rectangle<int>
auto position = proc->getPosition (getBounds());
if (position == juce::Point (0, 0) && getWidth() > 0 && getHeight() > 0) // no position set yet
{
if (bounds == Rectangle<int> {})
bounds = Rectangle (thisEditorWidth, thisEditorHeight).withCentre (nextEditorPosition);
if (bounds == juce::Rectangle<int> {})
bounds = juce::Rectangle (thisEditorWidth, thisEditorHeight).withCentre (nextEditorPosition);

editor->setBounds (bounds);
proc->setPosition (editor->getBounds().getTopLeft(), getBounds());
editor->setTopLeftPosition (proc->getPosition (getLocalBounds()));
}
else
{
if (bounds == Rectangle<int> {})
bounds = Rectangle (thisEditorWidth, thisEditorHeight);
if (bounds == juce::Rectangle<int> {})
bounds = juce::Rectangle (thisEditorWidth, thisEditorHeight);

editor->setBounds (bounds.withPosition (position));
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/pedalboard/BoardComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BoardComponent final : public Component

private:
void showNewProcMenu (PopupMenu& menu, PopupMenu::Options& options, juce::Point<int> mousePos, ConnectionInfo* connectionInfo = nullptr);
void setEditorPosition (ProcessorEditor* editor, Rectangle<int> bounds = {});
void setEditorPosition (ProcessorEditor* editor, juce::Rectangle<int> bounds = {});
void mouseDown (const MouseEvent& e) override;
void mouseDrag (const MouseEvent& e) override;
void mouseUp (const MouseEvent& e) override;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/pedalboard/BoardViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void BoardViewport::resized()
comp.setBounds (0, 0, width, height);

constexpr int buttonDim = 34;
auto buttonRect = Rectangle { 0, height - buttonDim, buttonDim, buttonDim };
auto buttonRect = juce::Rectangle { 0, height - buttonDim, buttonDim, buttonDim };
plusButton.setBounds (buttonRect.reduced (1));
minusButton.setBounds (buttonRect.withX (buttonDim).reduced (1));
scaleLabel.setBounds (2 * buttonDim, height - buttonDim, 100, buttonDim);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/pedalboard/cables/Cable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void Cable::drawCableShadow (Graphics& g, float thickness)

void Cable::drawCableEndCircle (Graphics& g, juce::Point<float> centre, Colour colour) const
{
auto circle = (Rectangle { minCableThickness, minCableThickness } * 2.4f * scaleFactor.load()).withCentre (centre);
auto circle = (juce::Rectangle { minCableThickness, minCableThickness } * 2.4f * scaleFactor.load()).withCentre (centre);
g.setColour (colour);
g.fillEllipse (circle);

Expand Down
2 changes: 1 addition & 1 deletion src/gui/pedalboard/cables/CableDrawingHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ constexpr float glowSizeFactor = 2.5f;
juce::Rectangle<float> getPortGlowBounds (juce::Point<int> location, float scaleFactor)
{
const auto glowDim = (float) getPortDistanceLimit (scaleFactor) * glowSizeFactor;
auto glowBounds = (Rectangle (glowDim, glowDim)).withCentre (location.toFloat());
auto glowBounds = (juce::Rectangle (glowDim, glowDim)).withCentre (location.toFloat());

return glowBounds;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/pedalboard/editors/EditorSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EditorSelector::EditorSelector (const BoardComponent& boardComp) : board (boardC
{
}

void EditorSelector::findLassoItemsInArea (Array<ProcessorEditor*>& results, const Rectangle<int>& area)
void EditorSelector::findLassoItemsInArea (Array<ProcessorEditor*>& results, const juce::Rectangle<int>& area)
{
const auto checkAndAddEditor = [&results, area] (ProcessorEditor* editor)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/pedalboard/editors/EditorSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class EditorSelector : public LassoSource<ProcessorEditor*>
public:
explicit EditorSelector (const BoardComponent&);

void findLassoItemsInArea (Array<ProcessorEditor*>& results, const Rectangle<int>& area) override;
void findLassoItemsInArea (Array<ProcessorEditor*>& results, const juce::Rectangle<int>& area) override;
SelectedItemSet<ProcessorEditor*>& getLassoSelection() override { return selectedEditorSet; }

private:
Expand Down
40 changes: 20 additions & 20 deletions src/gui/pedalboard/editors/KnobsComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void KnobsComponent::paint (Graphics& g)
font = Font (font.getHeight() - 0.5f).boldened();

g.setFont (font);
Rectangle<int> nameBox (comp.getX(), comp.getY() - nameOffset + offset, comp.getWidth(), nameHeight);
juce::Rectangle<int> nameBox (comp.getX(), comp.getY() - nameOffset + offset, comp.getWidth(), nameHeight);
g.drawFittedText (name, nameBox, Justification::centred, 1);
};

Expand Down Expand Up @@ -238,7 +238,7 @@ void KnobsComponent::resized()
if (boxes.size() > 0)
{
compWidth = getWidth() - yDim;
boxes[0]->setBounds (Rectangle (compWidth, yDim).withCentre (getLocalBounds().getCentre()));
boxes[0]->setBounds (juce::Rectangle (compWidth, yDim).withCentre (getLocalBounds().getCentre()));
}

if (buttons.size() > 0)
Expand Down Expand Up @@ -300,14 +300,14 @@ void KnobsComponent::resized()
{
int compIdx = 0;

Rectangle<int> bounds[4];
juce::Rectangle<int> bounds[4];
const int sWidth = proportionOfWidth (0.308f);
const int xOff = proportionOfWidth (0.231f);
const int yOff = proportionOfHeight (0.143f);
bounds[0] = Rectangle<int> { 0, yOff, sWidth, sWidth };
bounds[1] = Rectangle<int> { xOff, 2 * yOff, sWidth, sWidth };
bounds[2] = Rectangle<int> { 2 * xOff, yOff, sWidth, sWidth };
bounds[3] = Rectangle<int> { 3 * xOff, 2 * yOff, sWidth, sWidth };
bounds[0] = juce::Rectangle { 0, yOff, sWidth, sWidth };
bounds[1] = juce::Rectangle { xOff, 2 * yOff, sWidth, sWidth };
bounds[2] = juce::Rectangle { 2 * xOff, yOff, sWidth, sWidth };
bounds[3] = juce::Rectangle { 3 * xOff, 2 * yOff, sWidth, sWidth };

for (auto* s : sliders)
{
Expand All @@ -329,7 +329,7 @@ void KnobsComponent::resized()
{
int compIdx = 0;

Rectangle<int> bounds[5];
juce::Rectangle<int> bounds[5];
const int sWidth = proportionOfWidth (0.215f);
const int y1 = proportionOfHeight (0.25f);
const int y2 = proportionOfHeight (0.60f);
Expand All @@ -340,11 +340,11 @@ void KnobsComponent::resized()
const int x4 = proportionOfWidth (0.75f);
const int x5 = proportionOfWidth (0.39f);

bounds[0] = Rectangle<int> { x1, y1, sWidth, sWidth };
bounds[1] = Rectangle<int> { x2, y2, sWidth, sWidth };
bounds[2] = Rectangle<int> { x3, y2, sWidth, sWidth };
bounds[3] = Rectangle<int> { x4, y1, sWidth, sWidth };
bounds[4] = Rectangle<int> { x5, y3, sWidth, sWidth };
bounds[0] = juce::Rectangle { x1, y1, sWidth, sWidth };
bounds[1] = juce::Rectangle { x2, y2, sWidth, sWidth };
bounds[2] = juce::Rectangle { x3, y2, sWidth, sWidth };
bounds[3] = juce::Rectangle { x4, y1, sWidth, sWidth };
bounds[4] = juce::Rectangle { x5, y3, sWidth, sWidth };

for (auto* s : sliders)
{
Expand All @@ -359,7 +359,7 @@ void KnobsComponent::resized()
{
int compIdx = 0;

Rectangle<int> bounds[5];
juce::Rectangle<int> bounds[5];
const int sWidth = proportionOfWidth (0.288f);
const int y1 = proportionOfHeight (0.464f);
const int y2 = proportionOfHeight (0.107f);
Expand All @@ -372,11 +372,11 @@ void KnobsComponent::resized()
const int xDim = proportionOfWidth (0.346f);
const int yDim = proportionOfHeight (0.214f);

bounds[0] = Rectangle<int> { 0, y1, sWidth, sWidth };
bounds[1] = Rectangle<int> { x1, y2, sWidth, sWidth };
bounds[2] = Rectangle<int> { x2, y1, sWidth, sWidth };
bounds[3] = Rectangle<int> { x3, y1, sWidth, sWidth };
bounds[4] = Rectangle<int> { x4, y3, xDim, yDim };
bounds[0] = juce::Rectangle { 0, y1, sWidth, sWidth };
bounds[1] = juce::Rectangle { x1, y2, sWidth, sWidth };
bounds[2] = juce::Rectangle { x2, y1, sWidth, sWidth };
bounds[3] = juce::Rectangle { x3, y1, sWidth, sWidth };
bounds[4] = juce::Rectangle { x4, y3, xDim, yDim };

for (auto* s : sliders)
{
Expand All @@ -402,7 +402,7 @@ void KnobsComponent::resized()
{
s->setSliderStyle (Slider::SliderStyle::LinearVertical);
s->setTextBoxStyle (Slider::TextBoxBelow, false, width - 2, proportionOfHeight (0.11f));
auto bounds = Rectangle { x + 2, yPad, width - 4, getHeight() - yPad };
auto bounds = juce::Rectangle { x + 2, yPad, width - 4, getHeight() - yPad };
x += width;

s->setBounds (bounds);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/pedalboard/editors/ProcessorEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ void ProcessorEditor::resized()
if (! isIOProcessor)
{
const auto xButtonSize = proportionOfWidth (0.1f);
settingsButton.setBounds (Rectangle { width - 3 * xButtonSize, 0, xButtonSize, xButtonSize }.reduced (proportionOfWidth (0.01f)));
settingsButton.setBounds (juce::Rectangle { width - 3 * xButtonSize, 0, xButtonSize, xButtonSize }.reduced (proportionOfWidth (0.01f)));
powerButton.setBounds (width - 2 * xButtonSize, 0, xButtonSize, xButtonSize);
xButton.setBounds (Rectangle { width - xButtonSize, 0, xButtonSize, xButtonSize }.reduced (proportionOfWidth (0.015f)));
xButton.setBounds (juce::Rectangle { width - xButtonSize, 0, xButtonSize, xButtonSize }.reduced (proportionOfWidth (0.015f)));
}

const int portDim = proportionOfHeight (0.17f);
Expand Down
25 changes: 18 additions & 7 deletions src/gui/toolbar/presets/PresetSearchHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace preset_search
{
static std::string_view to_string_view (const juce::String& str) noexcept
{
return { str.toRawUTF8(), str.getNumBytesAsUTF8() };
}

void initialiseDatabase (const chowdsp::PresetManager& presetManager, Database& database)
{
enum SearchFields
Expand All @@ -14,7 +19,7 @@ void initialiseDatabase (const chowdsp::PresetManager& presetManager, Database&

juce::Logger::writeToLog ("Initializing preset search database...");

database.reset();
database.resetEntries (presetManager.getNumPresets());
database.setWeights ({
1.0f, // Name
0.9f, // Vendor
Expand All @@ -23,28 +28,34 @@ void initialiseDatabase (const chowdsp::PresetManager& presetManager, Database&
database.setThreshold (0.5f);

const auto t1 = std::chrono::steady_clock::now();
std::vector<std::string> fields (magic_enum::enum_count<SearchFields>());
std::array<std::string_view, numPresetSearchFields> fields {};

for (const auto& [presetID, preset] : presetManager.getPresetMap())
{
fields[Name] = preset.getName().toStdString();
fields[Vendor] = preset.getVendor().toStdString();
fields[Category] = preset.getCategory().toStdString();
database.addEntry (presetID, fields); // TODO: it would be cool if we could add entries in a batch?
fields[Name] = to_string_view (preset.getName());
fields[Vendor] = to_string_view (preset.getVendor());
fields[Category] = to_string_view (preset.getCategory());
database.addEntry (presetID, fields);
}

const auto t2 = std::chrono::steady_clock::now();
std::chrono::duration<double, std::milli> fp_ms = t2 - t1;
juce::Logger::writeToLog ("Finished scanning preset database in "
+ juce::String { fp_ms.count() }
+ " milliseconds");

database.prepareForSearch();
}

Results getSearchResults (const chowdsp::PresetManager& presetManager, const Database& database, const juce::String& query)
{
const auto searchResults = database.search (to_string_view (query));

Results resultsVector;
resultsVector.reserve (searchResults.size());

const auto& presetMap = presetManager.getPresetMap();
for (const auto result : database.search (query.toStdString()))
for (const auto& result : searchResults)
{
const auto presetIter = presetMap.find (result.key);
if (presetIter != presetMap.end())
Expand Down
3 changes: 2 additions & 1 deletion src/gui/toolbar/presets/PresetSearchHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace preset_search
{
using Database = fuzzysearch::Database<int>;
static constexpr size_t numPresetSearchFields = 3;
using Database = chowdsp::SearchDatabase<int, numPresetSearchFields>;
using Results = std::vector<const chowdsp::Preset*>;

void initialiseDatabase (const chowdsp::PresetManager& presetManager, Database& database);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/toolbar/presets/PresetSearchWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct PresetSearchWindow::ResultsListModel : public ListBoxModel

void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override
{
auto bounds = Rectangle { width, height };
auto bounds = juce::Rectangle { width, height };
if (rowIsSelected)
{
g.setColour (Colour (0xFF0EDED4));
Expand Down
Loading

0 comments on commit dd6f2f2

Please sign in to comment.