Skip to content

Commit

Permalink
Update to JUCE 7.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
koteq committed Mar 21, 2023
1 parent ee98584 commit 4fd77da
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 90 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Builds/
JuceLibraryCode/
lib/
/.devcontainer/
/.vscode/
/build/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "JUCE"]
path = JUCE
url = https://github.com/juce-framework/JUCE
1 change: 1 addition & 0 deletions JUCE
Submodule JUCE added at 69795d
40 changes: 20 additions & 20 deletions Source/HostStartup.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../JuceLibraryCode/JuceHeader.h"
#include "JuceHeader.h"
#include "IconMenu.hpp"

#if ! (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_VST3 || JUCE_PLUGINHOST_AU)
Expand Down Expand Up @@ -45,42 +45,42 @@ class PluginHostApp : public JUCEApplication

const String getApplicationName() override { return "Light Host"; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override {
StringArray multiInstance = getParameter("-multi-instance");
return multiInstance.size() == 2;
bool moreThanOneInstanceAllowed() override {
StringArray multiInstance = getParameter("-multi-instance");
return multiInstance.size() == 2;
}

ApplicationCommandManager commandManager;
ScopedPointer<ApplicationProperties> appProperties;
LookAndFeel_V3 lookAndFeel;

private:
ScopedPointer<IconMenu> mainWindow;

StringArray getParameter(String lookFor) {
StringArray parameters = getCommandLineParameterArray();
ScopedPointer<IconMenu> mainWindow;

StringArray getParameter(String lookFor) {
StringArray parameters = getCommandLineParameterArray();
StringArray found;
for (int i = 0; i < parameters.size(); ++i)
{
String param = parameters[i];
if (param.contains(lookFor))
{
found.add(lookFor);
String param = parameters[i];
if (param.contains(lookFor))
{
found.add(lookFor);
int delimiter = param.indexOf(0, "=") + 1;
String val = param.substring(delimiter);
found.add(val);
return found;
String val = param.substring(delimiter);
found.add(val);
return found;
}
}
return found;
}
}
return found;
}

void checkArguments(PropertiesFile::Options *options) {
void checkArguments(PropertiesFile::Options *options) {
StringArray multiInstance = getParameter("-multi-instance");
if (multiInstance.size() == 2)
options->filenameSuffix = multiInstance[1] + "." + options->filenameSuffix;
}
};
};

static PluginHostApp& getApp() { return *dynamic_cast<PluginHostApp*>(JUCEApplication::getInstance()); }
ApplicationCommandManager& getCommandManager() { return getApp().commandManager; }
Expand Down
106 changes: 45 additions & 61 deletions Source/IconMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//

#include "../JuceLibraryCode/JuceHeader.h"
#include "JuceHeader.h"
#include "IconMenu.hpp"
#include "PluginWindow.h"
#include <ctime>
Expand Down Expand Up @@ -64,22 +64,19 @@ IconMenu::IconMenu() : INDEX_EDIT(1000000), INDEX_BYPASS(2000000), INDEX_DELETE(
{
// Initiialization
formatManager.addDefaultFormats();
#if JUCE_WINDOWS
x = y = 0;
#endif
// Audio device
ScopedPointer<XmlElement> savedAudioState (getAppProperties().getUserSettings()->getXmlValue("audioDeviceState"));
deviceManager.initialise(256, 256, savedAudioState, true);
std::unique_ptr<XmlElement> savedAudioState (getAppProperties().getUserSettings()->getXmlValue("audioDeviceState"));
deviceManager.initialise(256, 256, savedAudioState.get(), true);
player.setProcessor(&graph);
deviceManager.addAudioCallback(&player);
// Plugins - all
ScopedPointer<XmlElement> savedPluginList(getAppProperties().getUserSettings()->getXmlValue("pluginList"));
std::unique_ptr<XmlElement> savedPluginList(getAppProperties().getUserSettings()->getXmlValue("pluginList"));
if (savedPluginList != nullptr)
knownPluginList.recreateFromXml(*savedPluginList);
pluginSortMethod = KnownPluginList::sortByManufacturer;
knownPluginList.addChangeListener(this);
// Plugins - active
ScopedPointer<XmlElement> savedPluginListActive(getAppProperties().getUserSettings()->getXmlValue("pluginListActive"));
std::unique_ptr<XmlElement> savedPluginListActive(getAppProperties().getUserSettings()->getXmlValue("pluginListActive"));
if (savedPluginListActive != nullptr)
activePluginList.recreateFromXml(*savedPluginListActive);
loadActivePlugins();
Expand All @@ -96,11 +93,13 @@ IconMenu::~IconMenu()
void IconMenu::setIcon()
{
// Set menu icon
Image icon;
#if JUCE_MAC
if (exec("defaults read -g AppleInterfaceStyle").compare("Dark") == 1)
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize));
icon = ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize);
else
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize));
icon = ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize);
setIconImage(icon, icon);
#else
String defaultColor;
#if JUCE_WINDOWS
Expand All @@ -111,12 +110,11 @@ void IconMenu::setIcon()
if (!getAppProperties().getUserSettings()->containsKey("icon"))
getAppProperties().getUserSettings()->setValue("icon", defaultColor);
String color = getAppProperties().getUserSettings()->getValue("icon");
Image icon;
if (color.equalsIgnoreCase("white"))
icon = ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize);
else if (color.equalsIgnoreCase("black"))
icon = ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize);
setIconImage(icon);
setIconImage(icon, icon);
#endif
}

Expand All @@ -128,12 +126,12 @@ void IconMenu::loadActivePlugins()
const int CHANNEL_TWO = 1;
PluginWindow::closeAllCurrentlyOpenWindows();
graph.clear();
inputNode = graph.addNode(new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode), INPUT);
outputNode = graph.addNode(new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode), OUTPUT);
inputNode = graph.addNode(std::make_unique<AudioProcessorGraph::AudioGraphIOProcessor> (AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode), AudioProcessorGraph::NodeID(INPUT));
outputNode = graph.addNode(std::make_unique<AudioProcessorGraph::AudioGraphIOProcessor> (AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode), AudioProcessorGraph::NodeID(OUTPUT));
if (activePluginList.getNumTypes() == 0)
{
graph.addConnection(INPUT, CHANNEL_ONE, OUTPUT, CHANNEL_ONE);
graph.addConnection(INPUT, CHANNEL_TWO, OUTPUT, CHANNEL_TWO);
graph.addConnection ({ { AudioProcessorGraph::NodeID(INPUT), CHANNEL_ONE }, { AudioProcessorGraph::NodeID(OUTPUT), CHANNEL_ONE } });
graph.addConnection ({ { AudioProcessorGraph::NodeID(INPUT), CHANNEL_TWO }, { AudioProcessorGraph::NodeID(OUTPUT), CHANNEL_TWO } });
}
int pluginTime = 0;
int lastId = 0;
Expand All @@ -143,36 +141,36 @@ void IconMenu::loadActivePlugins()
{
PluginDescription plugin = getNextPluginOlderThanTime(pluginTime);
String errorMessage;
AudioPluginInstance* instance = formatManager.createPluginInstance(plugin, graph.getSampleRate(), graph.getBlockSize(), errorMessage);
std::unique_ptr<AudioPluginInstance> instance = formatManager.createPluginInstance(plugin, graph.getSampleRate(), graph.getBlockSize(), errorMessage);
String pluginUid = getKey("state", plugin);
String savedPluginState = getAppProperties().getUserSettings()->getValue(pluginUid);
MemoryBlock savedPluginBinary;
savedPluginBinary.fromBase64Encoding(savedPluginState);
instance->setStateInformation(savedPluginBinary.getData(), savedPluginBinary.getSize());
graph.addNode(instance, i);
graph.addNode(std::move(instance), AudioProcessorGraph::NodeID(i)); // TODO https://stackoverflow.com/a/17473958
String key = getKey("bypass", plugin);
bool bypass = getAppProperties().getUserSettings()->getBoolValue(key, false);
// Input to plugin
if ((!hasInputConnected) && (!bypass))
{
graph.addConnection(INPUT, CHANNEL_ONE, i, CHANNEL_ONE);
graph.addConnection(INPUT, CHANNEL_TWO, i, CHANNEL_TWO);
graph.addConnection({ { AudioProcessorGraph::NodeID(INPUT), CHANNEL_ONE }, { AudioProcessorGraph::NodeID(i), CHANNEL_ONE } });
graph.addConnection({ { AudioProcessorGraph::NodeID(INPUT), CHANNEL_TWO }, { AudioProcessorGraph::NodeID(i), CHANNEL_TWO } });
hasInputConnected = true;
}
// Connect previous plugin to current
else if (!bypass)
else if ((!bypass))
{
graph.addConnection(lastId, CHANNEL_ONE, i, CHANNEL_ONE);
graph.addConnection(lastId, CHANNEL_TWO, i, CHANNEL_TWO);
graph.addConnection({ { AudioProcessorGraph::NodeID(lastId), CHANNEL_ONE }, { AudioProcessorGraph::NodeID(i), CHANNEL_ONE } });
graph.addConnection({ { AudioProcessorGraph::NodeID(lastId), CHANNEL_TWO }, { AudioProcessorGraph::NodeID(i), CHANNEL_TWO } });
}
if (!bypass)
lastId = i;
lastId = i;
}
if (lastId > 0)
{
// Last active plugin to output
graph.addConnection(lastId, CHANNEL_ONE, OUTPUT, CHANNEL_ONE);
graph.addConnection(lastId, CHANNEL_TWO, OUTPUT, CHANNEL_TWO);
graph.addConnection({ { AudioProcessorGraph::NodeID(lastId), CHANNEL_ONE }, { AudioProcessorGraph::NodeID(OUTPUT), CHANNEL_ONE } });
graph.addConnection({ { AudioProcessorGraph::NodeID(lastId), CHANNEL_TWO }, { AudioProcessorGraph::NodeID(OUTPUT), CHANNEL_TWO } });
}
}

Expand Down Expand Up @@ -201,19 +199,19 @@ void IconMenu::changeListenerCallback(ChangeBroadcaster* changed)
{
if (changed == &knownPluginList)
{
ScopedPointer<XmlElement> savedPluginList (knownPluginList.createXml());
std::unique_ptr<XmlElement> savedPluginList (knownPluginList.createXml());
if (savedPluginList != nullptr)
{
getAppProperties().getUserSettings()->setValue ("pluginList", savedPluginList);
getAppProperties().getUserSettings()->setValue ("pluginList", savedPluginList.get());
getAppProperties().saveIfNeeded();
}
}
else if (changed == &activePluginList)
{
ScopedPointer<XmlElement> savedPluginList (activePluginList.createXml());
std::unique_ptr<XmlElement> savedPluginList (activePluginList.createXml());
if (savedPluginList != nullptr)
{
getAppProperties().getUserSettings()->setValue ("pluginListActive", savedPluginList);
getAppProperties().getUserSettings()->setValue ("pluginListActive", savedPluginList.get());
getAppProperties().saveIfNeeded();
}
}
Expand Down Expand Up @@ -280,17 +278,7 @@ void IconMenu::timerCallback()
#if JUCE_MAC || JUCE_LINUX
menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this), ModalCallbackFunction::forComponent(menuInvocationCallback, this));
#else
if (x == 0 || y == 0)
{
POINT iconLocation;
iconLocation.x = 0;
iconLocation.y = 0;
GetCursorPos(&iconLocation);
x = iconLocation.x;
y = iconLocation.y;
}
juce::Rectangle<int> rect(x, y, 1, 1);
menu.showMenuAsync(PopupMenu::Options().withTargetScreenArea(rect), ModalCallbackFunction::forComponent(menuInvocationCallback, this));
menu.showMenuAsync(PopupMenu::Options().withMousePosition(), ModalCallbackFunction::forComponent(menuInvocationCallback, this));
#endif
}

Expand Down Expand Up @@ -348,13 +336,12 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im)
int index = id - im->INDEX_DELETE;
std::vector<PluginDescription> timeSorted = im->getTimeSortedList();
String key = getKey("order", timeSorted[index]);
int unsortedIndex = 0;
PluginDescription typeToRemove;
for (int i = 0; im->activePluginList.getNumTypes(); i++)
{
PluginDescription current = *im->activePluginList.getType(i);
if (key.equalsIgnoreCase(getKey("order", current)))
typeToRemove = *im->activePluginList.getType(i);
if (key.equalsIgnoreCase(getKey("order", typeToRemove)))
{
unsortedIndex = i;
break;
}
}
Expand All @@ -366,7 +353,7 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im)
getAppProperties().saveIfNeeded();

// Remove plugin from list
im->activePluginList.removeType(unsortedIndex);
im->activePluginList.removeType(typeToRemove);

// Save current states
im->savePluginStates();
Expand Down Expand Up @@ -403,7 +390,7 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im)
// Show active plugin GUI
else if (id >= im->INDEX_EDIT && id < im->INDEX_EDIT + 1000000)
{
if (const AudioProcessorGraph::Node::Ptr f = im->graph.getNodeForId(id - im->INDEX_EDIT + 1))
if (const AudioProcessorGraph::Node::Ptr f = im->graph.getNodeForId(AudioProcessorGraph::NodeID(id - im->INDEX_EDIT + 1)))
if (PluginWindow* const w = PluginWindow::getWindowFor(f, PluginWindow::Normal))
w->toFront(true);
}
Expand Down Expand Up @@ -477,7 +464,7 @@ void IconMenu::savePluginStates()
std::vector<PluginDescription> list = getTimeSortedList();
for (int i = 0; i < activePluginList.getNumTypes(); i++)
{
AudioProcessorGraph::Node* node = graph.getNodeForId(i + 1);
AudioProcessorGraph::Node* node = graph.getNodeForId(AudioProcessorGraph::NodeID(i + 1));
if (node == nullptr)
break;
AudioProcessor& processor = *node->getProcessor();
Expand All @@ -491,8 +478,8 @@ void IconMenu::savePluginStates()

void IconMenu::showAudioSettings()
{
AudioDeviceSelectorComponent audioSettingsComp (deviceManager, 0, 256, 0, 256, false, false, true, true);
audioSettingsComp.setSize(500, 450);
AudioDeviceSelectorComponent audioSettingsComp (deviceManager, 0, 256, 0, 256, false, false, true, false);
audioSettingsComp.setSize(500, 600);

DialogWindow::LaunchOptions o;
o.content.setNonOwned(&audioSettingsComp);
Expand All @@ -505,9 +492,9 @@ void IconMenu::showAudioSettings()

o.runModal();

ScopedPointer<XmlElement> audioState(deviceManager.createStateXml());
std::unique_ptr<XmlElement> audioState(deviceManager.createStateXml());

getAppProperties().getUserSettings()->setValue("audioDeviceState", audioState);
getAppProperties().getUserSettings()->setValue("audioDeviceState", audioState.get());
getAppProperties().getUserSettings()->saveIfNeeded();
}

Expand All @@ -520,13 +507,10 @@ void IconMenu::reloadPlugins()

void IconMenu::removePluginsLackingInputOutput()
{
std::vector<int> removeIndex;
for (int i = 0; i < knownPluginList.getNumTypes(); i++)
{
PluginDescription* plugin = knownPluginList.getType(i);
if (plugin->numInputChannels < 2 || plugin->numOutputChannels < 2)
removeIndex.push_back(i);
}
for (int i = 0; i < removeIndex.size(); i++)
knownPluginList.removeType(removeIndex[i] - i);
// TODO needs sanity check
for (const auto& plugin : knownPluginList.getTypes())
{
if (plugin.numInputChannels < 2 || plugin.numOutputChannels < 2)
knownPluginList.removeType(plugin);
}
}
10 changes: 5 additions & 5 deletions Source/PluginWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../JuceLibraryCode/JuceHeader.h"
#include "JuceHeader.h"
#include "PluginWindow.h"

class PluginWindow;
Expand Down Expand Up @@ -27,10 +27,10 @@ PluginWindow::PluginWindow (Component* const pluginEditor,

}

void PluginWindow::closeCurrentlyOpenWindowsFor (const uint32 nodeId)
void PluginWindow::closeCurrentlyOpenWindowsFor (const uint32 nodeUid)
{
for (int i = activePluginWindows.size(); --i >= 0;)
if (activePluginWindows.getUnchecked(i)->owner->nodeId == nodeId)
if (activePluginWindows.getUnchecked(i)->owner->nodeID.uid == nodeUid)
delete activePluginWindows.getUnchecked (i);
}

Expand Down Expand Up @@ -71,8 +71,8 @@ class ProcessorProgramPropertyComp : public PropertyComponent,
}

void refresh() { }
virtual void audioProcessorChanged (AudioProcessor*) { }
virtual void audioProcessorParameterChanged(AudioProcessor* processor, int, float) { }
virtual void audioProcessorChanged (AudioProcessor*, const ChangeDetails&) override { }
virtual void audioProcessorParameterChanged(AudioProcessor*, int, float) override { }

private:
AudioProcessor& owner;
Expand Down
2 changes: 1 addition & 1 deletion Source/PluginWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PluginWindow : public DocumentWindow

static PluginWindow* getWindowFor (AudioProcessorGraph::Node*, WindowFormatType);

static void closeCurrentlyOpenWindowsFor (const uint32 nodeId);
static void closeCurrentlyOpenWindowsFor (const uint32 nodeUid);
static void closeAllCurrentlyOpenWindows();
static bool containsActiveWindows();

Expand Down

0 comments on commit 4fd77da

Please sign in to comment.