mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
Added a handleVstHostCallbackAvailable method to the VSTCallbackHandler interface
This commit is contained in:
parent
2f5cd8811d
commit
1d56cfe04a
2 changed files with 71 additions and 45 deletions
|
|
@ -27,7 +27,7 @@
|
|||
namespace juce
|
||||
{
|
||||
|
||||
/** An interface to allow an AudioProcessor to receive VST specific calls from
|
||||
/** An interface to allow an AudioProcessor to send and receive VST specific calls from
|
||||
the host.
|
||||
|
||||
@tags{Audio}
|
||||
|
|
@ -55,6 +55,21 @@ struct VSTCallbackHandler
|
|||
pointer_sized_int value,
|
||||
void* ptr,
|
||||
float opt) = 0;
|
||||
|
||||
/** The host callback function type. */
|
||||
using VstHostCallbackType = pointer_sized_int (int32 opcode,
|
||||
int32 index,
|
||||
pointer_sized_int value,
|
||||
void* ptr,
|
||||
float opt);
|
||||
|
||||
/** This is called once by the VST plug-in wrapper after its constructor.
|
||||
You can use the supplied function to query the VST host.
|
||||
*/
|
||||
virtual void handleVstHostCallbackAvailable (std::function<VstHostCallbackType>&& callback)
|
||||
{
|
||||
ignoreUnused (callback);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -647,10 +647,10 @@ public:
|
|||
|
||||
if (hostCallback != nullptr)
|
||||
{
|
||||
int32 flags = Vst2::kVstPpqPosValid | Vst2::kVstTempoValid
|
||||
| Vst2::kVstBarsValid | Vst2::kVstCyclePosValid
|
||||
| Vst2::kVstTimeSigValid | Vst2::kVstSmpteValid
|
||||
| Vst2::kVstClockValid;
|
||||
int32 flags = Vst2::kVstPpqPosValid | Vst2::kVstTempoValid
|
||||
| Vst2::kVstBarsValid | Vst2::kVstCyclePosValid
|
||||
| Vst2::kVstTimeSigValid | Vst2::kVstSmpteValid
|
||||
| Vst2::kVstClockValid;
|
||||
|
||||
auto result = hostCallback (&vstEffect, Vst2::audioMasterGetTime, 0, flags, 0, 0);
|
||||
ti = reinterpret_cast<Vst2::VstTimeInfo*> (result);
|
||||
|
|
@ -1493,38 +1493,6 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
private:
|
||||
Vst2::audioMasterCallback hostCallback;
|
||||
AudioProcessor* processor = {};
|
||||
double sampleRate = 44100.0;
|
||||
int32 blockSize = 1024;
|
||||
Vst2::AEffect vstEffect;
|
||||
juce::MemoryBlock chunkMemory;
|
||||
juce::uint32 chunkMemoryTime = 0;
|
||||
std::unique_ptr<EditorCompWrapper> editorComp;
|
||||
Vst2::ERect editorBounds;
|
||||
MidiBuffer midiEvents;
|
||||
VSTMidiEventList outgoingEvents;
|
||||
float editorScaleFactor = 1.0f;
|
||||
|
||||
LegacyAudioParametersWrapper juceParameters;
|
||||
|
||||
bool isProcessing = false, isBypassed = false, hasShutdown = false;
|
||||
bool firstProcessCallback = true, shouldDeleteEditor = false;
|
||||
|
||||
#if JUCE_64BIT
|
||||
bool useNSView = true;
|
||||
#else
|
||||
bool useNSView = false;
|
||||
#endif
|
||||
|
||||
VstTempBuffers<float> floatTempBuffers;
|
||||
VstTempBuffers<double> doubleTempBuffers;
|
||||
int maxNumInChannels = 0, maxNumOutChannels = 0;
|
||||
|
||||
HeapBlock<Vst2::VstSpeakerArrangement> cachedInArrangement, cachedOutArrangement;
|
||||
|
||||
ThreadLocalValue<bool> inParameterChangedCallback;
|
||||
|
||||
static JuceVSTWrapper* getWrapper (Vst2::AEffect* v) noexcept { return static_cast<JuceVSTWrapper*> (v->object); }
|
||||
|
||||
bool isProcessLevelOffline()
|
||||
|
|
@ -2009,8 +1977,8 @@ private:
|
|||
auto matches = [=](const char* s) { return strcmp (text, s) == 0; };
|
||||
|
||||
if (matches ("receiveVstEvents")
|
||||
|| matches ("receiveVstMidiEvent")
|
||||
|| matches ("receiveVstMidiEvents"))
|
||||
|| matches ("receiveVstMidiEvent")
|
||||
|| matches ("receiveVstMidiEvents"))
|
||||
{
|
||||
#if JucePlugin_WantsMidiInput || JucePlugin_IsMidiEffect
|
||||
return 1;
|
||||
|
|
@ -2020,8 +1988,8 @@ private:
|
|||
}
|
||||
|
||||
if (matches ("sendVstEvents")
|
||||
|| matches ("sendVstMidiEvent")
|
||||
|| matches ("sendVstMidiEvents"))
|
||||
|| matches ("sendVstMidiEvent")
|
||||
|| matches ("sendVstMidiEvents"))
|
||||
{
|
||||
#if JucePlugin_ProducesMidiOutput || JucePlugin_IsMidiEffect
|
||||
return 1;
|
||||
|
|
@ -2031,9 +1999,9 @@ private:
|
|||
}
|
||||
|
||||
if (matches ("receiveVstTimeInfo")
|
||||
|| matches ("conformsToWindowRules")
|
||||
|| matches ("supportsViewDpiScaling")
|
||||
|| matches ("bypass"))
|
||||
|| matches ("conformsToWindowRules")
|
||||
|| matches ("supportsViewDpiScaling")
|
||||
|| matches ("bypass"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -2205,6 +2173,39 @@ private:
|
|||
#endif
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Vst2::audioMasterCallback hostCallback;
|
||||
AudioProcessor* processor = {};
|
||||
double sampleRate = 44100.0;
|
||||
int32 blockSize = 1024;
|
||||
Vst2::AEffect vstEffect;
|
||||
juce::MemoryBlock chunkMemory;
|
||||
juce::uint32 chunkMemoryTime = 0;
|
||||
std::unique_ptr<EditorCompWrapper> editorComp;
|
||||
Vst2::ERect editorBounds;
|
||||
MidiBuffer midiEvents;
|
||||
VSTMidiEventList outgoingEvents;
|
||||
float editorScaleFactor = 1.0f;
|
||||
|
||||
LegacyAudioParametersWrapper juceParameters;
|
||||
|
||||
bool isProcessing = false, isBypassed = false, hasShutdown = false;
|
||||
bool firstProcessCallback = true, shouldDeleteEditor = false;
|
||||
|
||||
#if JUCE_64BIT
|
||||
bool useNSView = true;
|
||||
#else
|
||||
bool useNSView = false;
|
||||
#endif
|
||||
|
||||
VstTempBuffers<float> floatTempBuffers;
|
||||
VstTempBuffers<double> doubleTempBuffers;
|
||||
int maxNumInChannels = 0, maxNumOutChannels = 0;
|
||||
|
||||
HeapBlock<Vst2::VstSpeakerArrangement> cachedInArrangement, cachedOutArrangement;
|
||||
|
||||
ThreadLocalValue<bool> inParameterChangedCallback;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceVSTWrapper)
|
||||
};
|
||||
|
|
@ -2229,7 +2230,17 @@ namespace
|
|||
|
||||
auto* processor = createPluginFilterOfType (AudioProcessor::wrapperType_VST);
|
||||
auto* wrapper = new JuceVSTWrapper (audioMaster, processor);
|
||||
return wrapper->getAEffect();
|
||||
auto* aEffect = wrapper->getAEffect();
|
||||
|
||||
if (auto* callbackHandler = dynamic_cast<VSTCallbackHandler*> (processor))
|
||||
{
|
||||
callbackHandler->handleVstHostCallbackAvailable ([audioMaster, aEffect](int32 opcode, int32 index, pointer_sized_int value, void* ptr, float opt)
|
||||
{
|
||||
return audioMaster (aEffect, opcode, index, value, ptr, opt);
|
||||
});
|
||||
}
|
||||
|
||||
return aEffect;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue