JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_AudioPluginFormat.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29AudioPluginFormat::AudioPluginFormat() {}
31
39
41 double initialSampleRate,
43 String& errorMessage)
44{
45 if (MessageManager::getInstance()->isThisTheMessageThread()
47 {
48 errorMessage = NEEDS_TRANS ("This plug-in cannot be instantiated synchronously");
49 return {};
50 }
51
54
55 auto callback = [&] (std::unique_ptr<AudioPluginInstance> p, const String& error)
56 {
57 errorMessage = error;
58 instance = std::move (p);
59 finishedSignal.signal();
60 };
61
62 if (! MessageManager::getInstance()->isThisTheMessageThread())
64 else
65 createPluginInstance (desc, initialSampleRate, initialBufferSize, std::move (callback));
66
67 finishedSignal.wait();
68 return instance;
69}
70
72{
73 AsyncCreateMessage (const PluginDescription& d, double sr, int size, PluginCreationCallback call)
74 : desc (d), sampleRate (sr), bufferSize (size), callbackToUse (std::move (call))
75 {
76 }
77
79 double sampleRate;
80 int bufferSize;
81 PluginCreationCallback callbackToUse;
82};
83
87{
88 jassert (callback != nullptr);
89 postMessage (new AsyncCreateMessage (description, initialSampleRate, initialBufferSize, std::move (callback)));
90}
91
92void AudioPluginFormat::handleMessage (const Message& message)
93{
94 if (auto m = dynamic_cast<const AsyncCreateMessage*> (&message))
95 createPluginInstance (m->desc, m->sampleRate, m->bufferSize, std::move (m->callbackToUse));
96}
97
98} // namespace juce
~AudioPluginFormat() override
Destructor.
virtual bool requiresUnblockedMessageThreadDuringCreation(const PluginDescription &) const =0
Returns true if instantiation of this plugin type must be done from a non-message thread.
virtual void createPluginInstance(const PluginDescription &, double initialSampleRate, int initialBufferSize, PluginCreationCallback)=0
Implementors must override this function.
std::unique_ptr< AudioPluginInstance > createInstanceFromDescription(const PluginDescription &, double initialSampleRate, int initialBufferSize)
Tries to recreate a type from a previously generated PluginDescription.
void createPluginInstanceAsync(const PluginDescription &description, double initialSampleRate, int initialBufferSize, PluginCreationCallback)
Tries to recreate a type from a previously generated PluginDescription.
void postMessage(Message *message) const
Sends a message to the message queue, for asynchronous delivery to this listener later on.
static MessageManager * getInstance()
Returns the global instance of the MessageManager.
The base class for objects that can be sent to a MessageListener.
A small class to represent some facts about a particular type of plug-in.
The JUCE String class!
Definition juce_String.h:53
Allows threads to wait for events triggered by other threads.
#define NEEDS_TRANS(stringLiteral)
A dummy version of the TRANS macro, used to indicate a string literal that should be added to the tra...
#define jassert(expression)
Platform-independent assertion macro.
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88