Download Source/PluginBridgeProcessor.cpp from RAM2118/pluginbridge: direct link, hf CLI and curl.
- Browser
- Download file 3.68 kB
-
https://huggingface.co/RAM2118/pluginbridge/resolve/48e03fde25d643015f24f9a73cef16c8d762e6c7/Source/PluginBridgeProcessor.cpp
- Command line
-
hf download hf://RAM2118/pluginbridge@48e03fde25d643015f24f9a73cef16c8d762e6c7/Source/PluginBridgeProcessor.cpp
-
curl -L -o PluginBridgeProcessor.cpp https://huggingface.co/RAM2118/pluginbridge/resolve/48e03fde25d643015f24f9a73cef16c8d762e6c7/Source/PluginBridgeProcessor.cpp
3.68 kB
| PluginBridgeProcessor::PluginBridgeProcessor() | |
| : AudioProcessor(BusesProperties() | |
| .withInput("Input", juce::AudioChannelSet::stereo(), true) | |
| .withOutput("Output", juce::AudioChannelSet::stereo(), true)), | |
| mcpServer(kDefaultMcpPort, hostManager) | |
| { | |
| mcpServer.start(); | |
| } | |
| PluginBridgeProcessor::~PluginBridgeProcessor() | |
| { | |
| mcpServer.stop(); | |
| } | |
| void PluginBridgeProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) | |
| { | |
| hostManager.prepareToPlay(sampleRate, samplesPerBlock); | |
| } | |
| void PluginBridgeProcessor::releaseResources() | |
| { | |
| hostManager.releaseResources(); | |
| } | |
| void PluginBridgeProcessor::processBlock(juce::AudioBuffer<float>& buffer, | |
| juce::MidiBuffer& midiMessages) | |
| { | |
| juce::ScopedNoDenormals noDenormals; | |
| auto totalNumInputChannels = getTotalNumInputChannels(); | |
| auto totalNumOutputChannels = getTotalNumOutputChannels(); | |
| for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) | |
| buffer.clear(i, 0, buffer.getNumSamples()); | |
| hostManager.processBlock(buffer, midiMessages); | |
| } | |
| juce::AudioProcessorEditor* PluginBridgeProcessor::createEditor() | |
| { | |
| return new PluginBridgeEditor(*this); | |
| } | |
| void PluginBridgeProcessor::getStateInformation(juce::MemoryBlock& destData) | |
| { | |
| juce::ValueTree state("PluginBridgeState"); | |
| state.setProperty("hostedPluginPath", hostManager.getLoadedPluginPath(), nullptr); | |
| juce::MemoryOutputStream stream(destData, false); | |
| state.writeToStream(stream); | |
| } | |
| void PluginBridgeProcessor::setStateInformation(const void* data, int sizeInBytes) | |
| { | |
| auto state = juce::ValueTree::readFromData(data, (size_t)sizeInBytes); | |
| if (state.isValid()) | |
| { | |
| auto path = state.getProperty("hostedPluginPath").toString(); | |
| if (path.isNotEmpty()) | |
| { | |
| juce::File pluginFile(path); | |
| if (pluginFile.exists()) | |
| loadPluginFromFile(pluginFile); | |
| } | |
| } | |
| } | |
| bool PluginBridgeProcessor::isMcpServerRunning() const | |
| { | |
| return mcpServer.isRunning(); | |
| } | |
| int PluginBridgeProcessor::getMcpServerPort() const | |
| { | |
| return mcpServer.getPort(); | |
| } | |
| void PluginBridgeProcessor::loadPluginFromFile(const juce::File& file) | |
| { | |
| hostManager.loadPlugin(file, getSampleRate(), getBlockSize()); | |
| } | |
| juce::Array<juce::File> PluginBridgeProcessor::getInstalledPluginFiles() const | |
| { | |
| juce::Array<juce::File> results; | |
| // VST3 directories | |
| juce::Array<juce::File> vst3Dirs = { | |
| juce::File("/Library/Audio/Plug-Ins/VST3"), | |
| juce::File::getSpecialLocation(juce::File::userHomeDirectory) | |
| .getChildFile("Library/Audio/Plug-Ins/VST3") | |
| }; | |
| for (auto& dir : vst3Dirs) | |
| { | |
| if (dir.isDirectory()) | |
| { | |
| auto files = dir.findChildFiles(juce::File::findDirectories, false, "*.vst3"); | |
| results.addArray(files); | |
| } | |
| } | |
| // AU directories | |
| juce::Array<juce::File> auDirs = { | |
| juce::File("/Library/Audio/Plug-Ins/Components"), | |
| juce::File::getSpecialLocation(juce::File::userHomeDirectory) | |
| .getChildFile("Library/Audio/Plug-Ins/Components") | |
| }; | |
| for (auto& dir : auDirs) | |
| { | |
| if (dir.isDirectory()) | |
| { | |
| auto files = dir.findChildFiles(juce::File::findDirectories, false, "*.component"); | |
| results.addArray(files); | |
| } | |
| } | |
| // Sort alphabetically | |
| results.sort(); | |
| return results; | |
| } | |
| // JUCE plugin entry point | |
| juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() | |
| { | |
| return new PluginBridgeProcessor(); | |
| } | |