Download Source/PluginBridgeEditor.cpp from RAM2118/pluginbridge: direct link, hf CLI and curl.
- Browser
- Download file 4.78 kB
-
https://huggingface.co/RAM2118/pluginbridge/resolve/adbb96ae3e314faf8d615e79e689a764e6739111/Source/PluginBridgeEditor.cpp
- Command line
-
hf download hf://RAM2118/pluginbridge@adbb96ae3e314faf8d615e79e689a764e6739111/Source/PluginBridgeEditor.cpp
-
curl -L -o PluginBridgeEditor.cpp https://huggingface.co/RAM2118/pluginbridge/resolve/adbb96ae3e314faf8d615e79e689a764e6739111/Source/PluginBridgeEditor.cpp
4.78 kB
| PluginBridgeEditor::PluginBridgeEditor(PluginBridgeProcessor& p) | |
| : AudioProcessorEditor(&p), processorRef(p) | |
| { | |
| setSize(360, 220); | |
| titleLabel.setText("PluginBridge", juce::dontSendNotification); | |
| titleLabel.setFont(juce::FontOptions(22.0f)); | |
| titleLabel.setJustificationType(juce::Justification::centred); | |
| titleLabel.setColour(juce::Label::textColourId, juce::Colours::white); | |
| addAndMakeVisible(titleLabel); | |
| statusLabel.setText("MCP: starting...", juce::dontSendNotification); | |
| statusLabel.setFont(juce::FontOptions(12.0f)); | |
| statusLabel.setJustificationType(juce::Justification::centred); | |
| addAndMakeVisible(statusLabel); | |
| portLabel.setText("", juce::dontSendNotification); | |
| portLabel.setFont(juce::FontOptions(10.0f)); | |
| portLabel.setJustificationType(juce::Justification::centred); | |
| portLabel.setColour(juce::Label::textColourId, juce::Colour(0xff888888)); | |
| addAndMakeVisible(portLabel); | |
| pluginLabel.setText("No plugin loaded", juce::dontSendNotification); | |
| pluginLabel.setFont(juce::FontOptions(13.0f)); | |
| pluginLabel.setJustificationType(juce::Justification::centred); | |
| pluginLabel.setColour(juce::Label::textColourId, juce::Colour(0xffaaaaaa)); | |
| addAndMakeVisible(pluginLabel); | |
| pluginButton.onClick = [this]() { showPluginMenu(); }; | |
| pluginButton.setColour(juce::TextButton::buttonColourId, juce::Colour(0xff2d2d44)); | |
| pluginButton.setColour(juce::TextButton::textColourOffId, juce::Colours::white); | |
| addAndMakeVisible(pluginButton); | |
| startTimerHz(4); | |
| } | |
| PluginBridgeEditor::~PluginBridgeEditor() | |
| { | |
| stopTimer(); | |
| } | |
| void PluginBridgeEditor::paint(juce::Graphics& g) | |
| { | |
| g.fillAll(juce::Colour(0xff12121f)); | |
| g.setColour(juce::Colour(0xff1e1e35)); | |
| g.fillRoundedRectangle(getLocalBounds().toFloat().reduced(4), 6.0f); | |
| } | |
| void PluginBridgeEditor::resized() | |
| { | |
| auto area = getLocalBounds().reduced(14); | |
| titleLabel.setBounds(area.removeFromTop(30)); | |
| area.removeFromTop(4); | |
| statusLabel.setBounds(area.removeFromTop(18)); | |
| portLabel.setBounds(area.removeFromTop(16)); | |
| area.removeFromTop(10); | |
| pluginButton.setBounds(area.removeFromTop(30).reduced(20, 0)); | |
| area.removeFromTop(8); | |
| pluginLabel.setBounds(area.removeFromTop(20)); | |
| } | |
| void PluginBridgeEditor::timerCallback() | |
| { | |
| if (processorRef.isMcpServerRunning()) | |
| { | |
| statusLabel.setText("MCP: running", juce::dontSendNotification); | |
| statusLabel.setColour(juce::Label::textColourId, juce::Colour(0xff4cef50)); | |
| portLabel.setText("127.0.0.1:" + juce::String(processorRef.getMcpServerPort()), | |
| juce::dontSendNotification); | |
| } | |
| else | |
| { | |
| statusLabel.setText("MCP: offline", juce::dontSendNotification); | |
| statusLabel.setColour(juce::Label::textColourId, juce::Colour(0xffef5350)); | |
| portLabel.setText("", juce::dontSendNotification); | |
| } | |
| auto& mgr = processorRef.getHostedPluginManager(); | |
| if (mgr.isLoaded()) | |
| { | |
| pluginLabel.setText(mgr.getPluginName() + " | " + juce::String(mgr.getParameterCount()) + " params", | |
| juce::dontSendNotification); | |
| pluginLabel.setColour(juce::Label::textColourId, juce::Colour(0xffffeb3b)); | |
| pluginButton.setButtonText(mgr.getPluginName()); | |
| } | |
| else | |
| { | |
| pluginLabel.setText("No plugin loaded", juce::dontSendNotification); | |
| pluginLabel.setColour(juce::Label::textColourId, juce::Colour(0xff888888)); | |
| pluginButton.setButtonText("Select Plugin..."); | |
| } | |
| } | |
| void PluginBridgeEditor::showPluginMenu() | |
| { | |
| auto files = processorRef.getInstalledPluginFiles(); | |
| juce::PopupMenu menu; | |
| if (files.isEmpty()) | |
| { | |
| menu.addItem(-1, "(No plugins found)", false); | |
| menu.showMenuAsync(juce::PopupMenu::Options().withTargetComponent(&pluginButton), | |
| [](int) {}); | |
| return; | |
| } | |
| juce::PopupMenu vst3Menu; | |
| juce::PopupMenu auMenu; | |
| int itemId = 1; | |
| for (int i = 0; i < files.size(); ++i) | |
| { | |
| const auto& file = files[i]; | |
| auto name = file.getFileNameWithoutExtension(); | |
| if (file.getFileExtension() == ".vst3") | |
| vst3Menu.addItem(itemId, name); | |
| else | |
| auMenu.addItem(itemId, name); | |
| itemId++; | |
| } | |
| if (vst3Menu.getNumItems() > 0) | |
| menu.addSubMenu("VST3", vst3Menu); | |
| if (auMenu.getNumItems() > 0) | |
| menu.addSubMenu("Audio Units", auMenu); | |
| menu.showMenuAsync(juce::PopupMenu::Options().withTargetComponent(&pluginButton), | |
| [this, files](int result) | |
| { | |
| if (result > 0 && result <= files.size()) | |
| { | |
| processorRef.loadPluginFromFile(files[result - 1]); | |
| } | |
| }); | |
| } | |