Download Source/PluginBridgeProcessor.cpp from RAM2118/pluginbridge: direct link, hf CLI and curl.
- Browser
- Download file 2.68 kB
-
https://huggingface.co/RAM2118/pluginbridge/resolve/862564ac0b4d29c65faea281bea8d40ae67fbf4b/Source/PluginBridgeProcessor.cpp
- Command line
-
hf download hf://RAM2118/pluginbridge@862564ac0b4d29c65faea281bea8d40ae67fbf4b/Source/PluginBridgeProcessor.cpp
-
curl -L -o PluginBridgeProcessor.cpp https://huggingface.co/RAM2118/pluginbridge/resolve/862564ac0b4d29c65faea281bea8d40ae67fbf4b/Source/PluginBridgeProcessor.cpp
2.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; | |
| // Clear extra output channels | |
| auto totalNumInputChannels = getTotalNumInputChannels(); | |
| auto totalNumOutputChannels = getTotalNumOutputChannels(); | |
| for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) | |
| buffer.clear(i, 0, buffer.getNumSamples()); | |
| // Route audio through hosted plugin | |
| hostManager.processBlock(buffer, midiMessages); | |
| } | |
| juce::AudioProcessorEditor* PluginBridgeProcessor::createEditor() | |
| { | |
| return new PluginBridgeEditor(*this); | |
| } | |
| void PluginBridgeProcessor::getStateInformation(juce::MemoryBlock& destData) | |
| { | |
| // Save the path of the hosted plugin so it reloads on session restore | |
| 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 plugin entry point | |
| juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() | |
| { | |
| return new PluginBridgeProcessor(); | |
| } | |