RAM2118 commited on
Commit
915497a
·
verified ·
1 Parent(s): f3db0f3

Upload Source/Helper/HelperPluginHost.h

Browse files
Files changed (1) hide show
  1. Source/Helper/HelperPluginHost.h +55 -60
Source/Helper/HelperPluginHost.h CHANGED
@@ -1,72 +1,67 @@
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 "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
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
- std::thread audioThread;
61
- std::atomic<bool> processing{false};
62
-
63
- SharedAudioBuffer* sharedAudio = nullptr;
64
- SharedSemaphore* inputSem = nullptr;
65
- SharedSemaphore* outputSem = nullptr;
66
-
67
- double currentSampleRate = 44100.0;
68
- int currentBlockSize = 512;
69
- int currentChannels = 2;
70
-
71
- std::unique_ptr<juce::DocumentWindow> guiWindow;
72
  };
 
1
  #pragma once
2
 
3
  #include <juce_audio_processors/juce_audio_processors.h>
 
 
 
4
 
5
+ // Simplified HelperPluginHost — ONLY tests if a plugin can load.
6
+ // No audio processing, no GUI, no IPC. Just load and report.
7
 
8
  class HelperPluginHost
9
  {
10
  public:
11
+ HelperPluginHost()
12
+ {
13
+ #if JUCE_PLUGINHOST_VST3
14
+ formatManager.addFormat(new juce::VST3PluginFormat());
15
+ #endif
16
+ #if JUCE_PLUGINHOST_AU
17
+ formatManager.addFormat(new juce::AudioUnitPluginFormat());
18
+ #endif
19
+ }
20
+
21
+ // Try to load a plugin. Returns true if successful.
22
+ // If the plugin crashes (abort(), NSAlert, etc.), this process dies
23
+ // and the parent sees exit code != 0.
24
+ bool testLoad(const juce::String& path)
25
+ {
26
+ juce::File pluginFile(path);
27
+ if (!pluginFile.exists())
28
+ return false;
29
+
30
+ juce::OwnedArray<juce::PluginDescription> typesFound;
31
+
32
+ for (int i = 0; i < formatManager.getNumFormats(); ++i)
33
+ {
34
+ auto* format = formatManager.getFormat(i);
35
+ bool isVST3 = pluginFile.getFileExtension() == ".vst3";
36
+ bool isAU = pluginFile.getFileExtension() == ".component";
37
+
38
+ if (isVST3 && format->getName() != "VST3") continue;
39
+ if (isAU && format->getName() != "AudioUnit") continue;
40
+
41
+ format->findAllTypesForFile(typesFound, pluginFile.getFullPathName());
42
+ if (typesFound.size() > 0)
43
+ break;
44
+ }
45
+
46
+ if (typesFound.isEmpty())
47
+ return false;
48
+
49
+ juce::String errorMessage;
50
+ auto instance = formatManager.createPluginInstance(
51
+ *typesFound[0], 44100.0, 512, errorMessage);
52
+
53
+ if (instance == nullptr)
54
+ {
55
+ DBG("HelperPluginHost: Load failed: " + errorMessage);
56
+ return false;
57
+ }
58
+
59
+ // Successfully loaded — release and report safe
60
+ instance->releaseResources();
61
+ instance.reset();
62
+ return true;
63
+ }
64
 
65
  private:
 
 
66
  juce::AudioPluginFormatManager formatManager;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  };