| #pragma once |
|
|
| #include <juce_audio_processors/juce_audio_processors.h> |
| #include <juce_gui_basics/juce_gui_basics.h> |
| #include <thread> |
| #include <atomic> |
|
|
| #include "SharedAudioBuffer.h" |
|
|
| class HelperPluginHost |
| { |
| public: |
| HelperPluginHost(); |
| ~HelperPluginHost(); |
|
|
| |
| bool loadPlugin(const juce::String& path, double sampleRate, int blockSize); |
| void unloadPlugin(); |
| bool isLoaded() const { return plugin != nullptr; } |
| juce::String getPluginName() const; |
| int getParameterCount() const; |
|
|
| |
| void setSharedAudio(SharedAudioBuffer* shm, SharedSemaphore* inSem, SharedSemaphore* outSem); |
| void startProcessing(); |
| void stopProcessing(); |
|
|
| |
| struct ParamInfo { |
| int index; |
| juce::String id; |
| juce::String name; |
| float value; |
| juce::String displayText; |
| }; |
| std::vector<ParamInfo> searchParams(const juce::String& keyword) const; |
| std::vector<std::pair<int, float>> getParams(const std::vector<int>& ids) const; |
| bool setParams(const std::map<int, float>& values); |
|
|
| |
| void showGui(); |
| void hideGui(); |
| int getGuiWidth() const { return guiWidth; } |
| int getGuiHeight() const { return guiHeight; } |
| void setLayerPortName(const juce::String& name) { layerPortName = name; } |
| juce::String getLayerPortName() const { return layerPortName; } |
|
|
| |
| void injectMouseDown(float x, float y, int button); |
| void injectMouseUp(float x, float y, int button); |
| void injectMouseMove(float x, float y); |
| void injectMouseDrag(float x, float y, int button); |
| void injectMouseScroll(float x, float y, float dx, float dy); |
| void injectKeyDown(int keyCode, const juce::String& chars, int modifiers); |
| void injectKeyUp(int keyCode, const juce::String& chars, int modifiers); |
|
|
| |
| juce::String getStateBase64() const; |
| bool setStateBase64(const juce::String& base64State); |
| void configure(double sampleRate, int blockSize, int channels); |
|
|
| |
| std::function<void(const juce::String& portName, int width, int height)> onGuiCreated; |
| std::function<void(int w, int h)> onGuiResized; |
|
|
| private: |
| void audioProcessingLoop(); |
|
|
| juce::AudioPluginFormatManager formatManager; |
| std::unique_ptr<juce::AudioPluginInstance> plugin; |
| std::unique_ptr<juce::AudioProcessorEditor> editor; |
|
|
| std::thread audioThread; |
| std::atomic<bool> processing{false}; |
|
|
| SharedAudioBuffer* sharedAudio = nullptr; |
| SharedSemaphore* inputSem = nullptr; |
| SharedSemaphore* outputSem = nullptr; |
|
|
| double currentSampleRate = 44100.0; |
| int currentBlockSize = 512; |
| int currentChannels = 2; |
|
|
| |
| int guiWidth = 0; |
| int guiHeight = 0; |
| juce::String layerPortName; |
|
|
| |
| void* caContext = nullptr; |
| void* guiWindow = nullptr; |
| }; |
|
|