Out-of-process rebuild: Add Helper/HelperPluginHost.h/.cpp — loads plugin, runs processBlock, shows GUI
Browse files
Source/Helper/HelperPluginHost.h
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
#include <juce_audio_processors/juce_audio_processors.h>
|
| 4 |
+
#include <juce_gui_basics/juce_gui_basics.h>
|
| 5 |
+
#include <thread>
|
| 6 |
+
#include <atomic>
|
| 7 |
+
|
| 8 |
+
#include "../Shared/SharedAudioBuffer.h"
|
| 9 |
+
|
| 10 |
+
class HelperPluginHost
|
| 11 |
+
{
|
| 12 |
+
public:
|
| 13 |
+
HelperPluginHost();
|
| 14 |
+
~HelperPluginHost();
|
| 15 |
+
|
| 16 |
+
// Plugin lifecycle
|
| 17 |
+
bool loadPlugin(const juce::String& path, double sampleRate, int blockSize);
|
| 18 |
+
void unloadPlugin();
|
| 19 |
+
bool isLoaded() const { return plugin != nullptr; }
|
| 20 |
+
juce::String getPluginName() const;
|
| 21 |
+
int getParameterCount() const;
|
| 22 |
+
|
| 23 |
+
// Audio processing (shared memory)
|
| 24 |
+
void setSharedAudio(SharedAudioBuffer* shm, SharedSemaphore* inSem, SharedSemaphore* outSem);
|
| 25 |
+
void startProcessing();
|
| 26 |
+
void stopProcessing();
|
| 27 |
+
|
| 28 |
+
// Parameters
|
| 29 |
+
struct ParamInfo {
|
| 30 |
+
int index;
|
| 31 |
+
juce::String id;
|
| 32 |
+
juce::String name;
|
| 33 |
+
float value;
|
| 34 |
+
juce::String displayText;
|
| 35 |
+
};
|
| 36 |
+
std::vector<ParamInfo> searchParams(const juce::String& keyword) const;
|
| 37 |
+
std::vector<std::pair<int, float>> getParams(const std::vector<int>& ids) const;
|
| 38 |
+
bool setParams(const std::map<int, float>& values);
|
| 39 |
+
|
| 40 |
+
// GUI
|
| 41 |
+
void showGui();
|
| 42 |
+
void hideGui();
|
| 43 |
+
|
| 44 |
+
// State
|
| 45 |
+
juce::String getStateBase64() const;
|
| 46 |
+
bool setStateBase64(const juce::String& base64State);
|
| 47 |
+
|
| 48 |
+
// Configure
|
| 49 |
+
void configure(double sampleRate, int blockSize, int channels);
|
| 50 |
+
|
| 51 |
+
// Param change callback (called when user touches GUI)
|
| 52 |
+
std::function<void(int index, float value)> onParamChanged;
|
| 53 |
+
|
| 54 |
+
private:
|
| 55 |
+
void audioProcessingLoop();
|
| 56 |
+
|
| 57 |
+
juce::AudioPluginFormatManager formatManager;
|
| 58 |
+
std::unique_ptr<juce::AudioPluginInstance> plugin;
|
| 59 |
+
|
| 60 |
+
// Audio thread
|
| 61 |
+
std::thread audioThread;
|
| 62 |
+
std::atomic<bool> processing{false};
|
| 63 |
+
|
| 64 |
+
SharedAudioBuffer* sharedAudio = nullptr;
|
| 65 |
+
SharedSemaphore* inputSem = nullptr;
|
| 66 |
+
SharedSemaphore* outputSem = nullptr;
|
| 67 |
+
|
| 68 |
+
double currentSampleRate = 44100.0;
|
| 69 |
+
int currentBlockSize = 512;
|
| 70 |
+
int currentChannels = 2;
|
| 71 |
+
|
| 72 |
+
// GUI window
|
| 73 |
+
std::unique_ptr<juce::DocumentWindow> guiWindow;
|
| 74 |
+
};
|