| #pragma once |
|
|
| #include <juce_audio_processors/juce_audio_processors.h> |
| #include <juce_dsp/juce_dsp.h> |
| #include "HelperConnection.h" |
| #include "McpServer.h" |
| #include "Blocklist.h" |
| #include "PluginSafetyDB.h" |
| #include "AudioAnalyser.h" |
| #include "InstanceRegistry.h" |
| #include "Constants.h" |
| #include <map> |
| #include <mutex> |
| #include <set> |
|
|
| class PluginBridgeProcessor : public juce::AudioProcessor, |
| private juce::AudioProcessorListener |
| { |
| public: |
| PluginBridgeProcessor(); |
| ~PluginBridgeProcessor() override; |
|
|
| void prepareToPlay(double sampleRate, int samplesPerBlock) override; |
| void releaseResources() override; |
| void processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) override; |
|
|
| juce::AudioProcessorEditor* createEditor() override; |
| bool hasEditor() const override { return true; } |
|
|
| const juce::String getName() const override { return "PluginBridge"; } |
| bool acceptsMidi() const override { return true; } |
| bool producesMidi() const override { return true; } |
| double getTailLengthSeconds() const override { return 0.0; } |
|
|
| int getNumPrograms() override { return 1; } |
| int getCurrentProgram() override { return 0; } |
| void setCurrentProgram(int) override {} |
| const juce::String getProgramName(int) override { return {}; } |
| void changeProgramName(int, const juce::String&) override {} |
|
|
| void getStateInformation(juce::MemoryBlock& destData) override; |
| void setStateInformation(const void* data, int sizeInBytes) override; |
|
|
| |
| bool isMcpServerRunning() const; |
| int getMcpServerPort() const; |
| HelperConnection& getHelperConnection() { return helper; } |
|
|
| |
| void setChannelName(const juce::String& name); |
| juce::String getChannelName() const { return channelName; } |
|
|
| |
| void loadPlugin(const juce::String& pluginPath); |
| void unloadPlugin(); |
|
|
| bool isPluginLoaded() const { return pluginLoaded; } |
| juce::String getLoadedPluginName() const { return pluginName; } |
| int getLoadedPluginParamCount() const { return pluginParamCount; } |
| HelperConnection::State getConnectionState() const { return helper.getState(); } |
| juce::String getLastPluginPath() const { return pluginPath; } |
|
|
| |
| juce::AudioPluginInstance* getInProcessPlugin() const { return inProcessPlugin.get(); } |
|
|
| |
| juce::Array<juce::File> getInstalledPluginFiles() const; |
|
|
| |
| juce::String getPluginManufacturer(const juce::File& pluginFile) const; |
|
|
| |
| bool isBlocked(const juce::String& path) const; |
| Blocklist& getBlocklist() { return blocklist; } |
|
|
| |
| PluginSafetyDB& getSafetyDB() { return safetyDB; } |
| void startBackgroundScan(); |
| void stopBackgroundScan(); |
|
|
| |
| std::string getAnalysis() const { return analyser.getCompactAnalysis(); } |
|
|
| |
| std::function<void()> onPluginWillLoad; |
| std::function<void()> onPluginLoaded; |
| std::function<void()> onPluginUnloaded; |
| std::function<void(const juce::String&)> onLoadFailed; |
| std::function<void(const juce::String&, bool)> onScanProgress; |
|
|
| private: |
| void loadInProcessPlugin(const juce::String& path); |
| void unloadInProcessPlugin(); |
| bool runPluginScan(const juce::String& path); |
|
|
| void audioProcessorParameterChanged(juce::AudioProcessor*, int paramIdx, float value) override; |
| void audioProcessorChanged(juce::AudioProcessor*, const ChangeDetails&) override {} |
|
|
| HelperConnection helper; |
| std::unique_ptr<McpServer> mcpServer; |
| Blocklist blocklist; |
| PluginSafetyDB safetyDB; |
| AudioAnalyser analyser; |
|
|
| |
| juce::AudioPluginFormatManager inProcessFormatManager; |
| std::unique_ptr<juce::AudioPluginInstance> inProcessPlugin; |
| std::atomic<bool> suppressParamSync{false}; |
|
|
| bool pluginLoaded = false; |
| juce::String pluginName; |
| juce::String pluginPath; |
| int pluginParamCount = 0; |
|
|
| |
| juce::String channelName { "Unnamed" }; |
|
|
| double currentSampleRate = 44100.0; |
| int currentBlockSize = 512; |
|
|
| std::thread scanThread; |
| std::atomic<bool> scanRunning{false}; |
|
|
| mutable std::map<std::string, std::string> manufacturerCache; |
| mutable std::mutex manufacturerCacheMutex; |
|
|
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginBridgeProcessor) |
| }; |
|
|