Sprint 2: HostedPluginManager.h \u2014 full plugin hosting interface with param surface
Browse files- Source/HostedPluginManager.h +47 -5
Source/HostedPluginManager.h
CHANGED
|
@@ -1,13 +1,55 @@
|
|
| 1 |
#pragma once
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
class HostedPluginManager
|
| 7 |
{
|
| 8 |
public:
|
| 9 |
-
HostedPluginManager()
|
| 10 |
-
~HostedPluginManager()
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
};
|
|
|
|
| 1 |
#pragma once
|
| 2 |
|
| 3 |
+
#include <juce_audio_processors/juce_audio_processors.h>
|
| 4 |
+
#include <vector>
|
| 5 |
+
#include <map>
|
| 6 |
|
| 7 |
class HostedPluginManager
|
| 8 |
{
|
| 9 |
public:
|
| 10 |
+
HostedPluginManager();
|
| 11 |
+
~HostedPluginManager();
|
| 12 |
|
| 13 |
+
// Plugin lifecycle
|
| 14 |
+
void loadPlugin(const juce::File& pluginFile, double sampleRate, int blockSize);
|
| 15 |
+
void unloadPlugin();
|
| 16 |
+
bool isLoaded() const;
|
| 17 |
+
juce::String getPluginName() const;
|
| 18 |
+
|
| 19 |
+
// Audio processing — called from audio thread
|
| 20 |
+
void prepareToPlay(double sampleRate, int blockSize);
|
| 21 |
+
void processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midi);
|
| 22 |
+
void releaseResources();
|
| 23 |
+
|
| 24 |
+
// Parameter surface — called from HTTP thread (thread-safe)
|
| 25 |
+
struct ParamInfo {
|
| 26 |
+
int index;
|
| 27 |
+
juce::String id;
|
| 28 |
+
juce::String name;
|
| 29 |
+
float value; // 0.0–1.0 normalized
|
| 30 |
+
juce::String displayText;
|
| 31 |
+
bool automatable;
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
std::vector<ParamInfo> searchParams(const juce::String& keyword) const;
|
| 35 |
+
std::vector<std::pair<int, float>> getParams(const std::vector<int>& indices) const;
|
| 36 |
+
bool setParams(const std::map<int, float>& values);
|
| 37 |
+
int getParameterCount() const;
|
| 38 |
+
|
| 39 |
+
// Thread safety
|
| 40 |
+
juce::CriticalSection& getPluginLock() { return pluginLock; }
|
| 41 |
+
|
| 42 |
+
// File path of currently loaded plugin (for state save/restore)
|
| 43 |
+
juce::String getLoadedPluginPath() const;
|
| 44 |
+
|
| 45 |
+
private:
|
| 46 |
+
juce::AudioPluginFormatManager formatManager;
|
| 47 |
+
std::unique_ptr<juce::AudioPluginInstance> hostedPlugin;
|
| 48 |
+
juce::CriticalSection pluginLock;
|
| 49 |
+
|
| 50 |
+
double currentSampleRate = 44100.0;
|
| 51 |
+
int currentBlockSize = 512;
|
| 52 |
+
juce::String loadedPluginPath;
|
| 53 |
+
|
| 54 |
+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(HostedPluginManager)
|
| 55 |
};
|