tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_ExternalPlugin.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
14// JUCE Changed the format of PluginDescription::createIdentifierString
15// breaking all our saved files. This reverts to the old format
16juce::String createIdentifierString (const juce::PluginDescription&);
17
18
19class ExternalPlugin : public Plugin
20{
21public:
23 ~ExternalPlugin() override;
24
25 juce::String getIdentifierString() override { return createIdentifierString (desc); }
26
28
29 void selectableAboutToBeDeleted() override;
30
31 static juce::ValueTree create (Engine&, const juce::PluginDescription&);
32
33 void processingChanged() override;
34
35 //==============================================================================
36 void initialiseFully() override;
37 void forceFullReinitialise();
38
39 juce::String getLoadError();
40
41 static const char* xmlTypeName;
42
43 void flushPluginStateToValueTree() override;
44 void flushBusesLayoutToValueTree();
45 void restorePluginStateFromValueTree (const juce::ValueTree&) override;
46 void getPluginStateFromTree (juce::MemoryBlock&);
47
48 void updateFromMirroredPluginIfNeeded (Plugin&) override;
49
50 void initialise (const PluginInitialisationInfo&) override;
51 void deinitialise() override;
52 void reset() override;
53 void setEnabled (bool enabled) override;
54
55 juce::Array<Exportable::ReferencedItem> getReferencedItems() override;
56 void reassignReferencedItem (const ReferencedItem&, ProjectItemID newID, double newStartTime) override;
57
58 void applyToBuffer (const PluginRenderContext&) override;
59
60 bool producesAudioWhenNoAudioInput() override { return isAutomationNeeded() || isSynth() || ! noTail(); }
61 int getNumOutputChannelsGivenInputs (int numInputs) override;
62 void getChannelNames (juce::StringArray* ins, juce::StringArray* outs) override;
63
64 bool isVST() const noexcept { return desc.pluginFormatName == "VST"; }
65 bool isVST3() const noexcept { return desc.pluginFormatName == "VST3"; }
66 bool isAU() const noexcept { return desc.pluginFormatName == "AudioUnit"; }
67 juce::String getName() const override { return desc.name; }
68 juce::String getVendor() override { return desc.manufacturerName; }
69 juce::String getTooltip() override { return getName() + "$vstfilter"; }
70 juce::String getPluginType() override { return xmlTypeName; }
71 bool isSynth() override { return desc.isInstrument; }
72 bool takesMidiInput() override;
73 bool takesAudioInput() override { return (! isSynth()) || (dryGain->getCurrentValue() > 0.0f); }
74 bool isMissing() override;
75 bool isDisabled() override;
76 double getLatencySeconds() override { return latencySeconds; }
77 bool noTail() override;
78 double getTailLength() const override;
79 bool needsConstantBufferSize() override { return false; }
80 void trackPropertiesChanged() override;
81
82 juce::AudioProcessor* getWrappedAudioProcessor() const override { return pluginInstance.get(); }
83 void deleteFromParent() override;
84
85 //==============================================================================
86 // selectable stuff
88
89 //==============================================================================
90 juce::File getFile() const;
91 juce::String getPluginUID() const { return juce::String::toHexString (desc.deprecatedUid); }
92
93 const char* getDebugName() const noexcept { return debugName.toUTF8(); }
94
95 //==============================================================================
96 int getNumInputs() const;
97 int getNumOutputs() const;
98
101
103 bool setBusLayout (juce::AudioChannelSet, bool isInput, int busIndex);
104
105 //==============================================================================
106 int getNumPrograms() const;
107 int getCurrentProgram() const;
108 juce::String getProgramName (int index);
109 juce::String getNumberedProgramName (int i);
110 juce::String getCurrentProgramName();
111 void setCurrentProgram (int index, bool sendChangeMessage);
112 void setCurrentProgramName (const juce::String& name);
113 bool hasNameForMidiProgram (int programNum, int bank, juce::String& name) override;
114 bool hasNameForMidiNoteNumber (int note, int midiChannel, juce::String& name) override;
115
116 //==============================================================================
117 const VSTXML* getVSTXML() const noexcept { return vstXML.get(); }
118
119 juce::AudioPluginInstance* getAudioPluginInstance() const;
120
122
123 juce::CachedValue<float> dryValue, wetValue;
124 AutomatableParameter::Ptr dryGain, wetGain;
125
126 ActiveNoteList getActiveNotes() const { return activeNotes; }
127
128 //==============================================================================
129 std::unique_ptr<EditorComponent> createEditor() override;
130
131private:
132 //==============================================================================
134 juce::String debugName, identiferString, loadError;
135
136 struct ProcessorChangedManager;
138 std::unique_ptr<ProcessorChangedManager> processorChangedManager;
140 int latencySamples = 0;
141 double latencySeconds = 0;
142 bool isInstancePrepared = false;
143
144 double lastSampleRate = 0.0;
145 int lastBlockSizeSamples = 0;
146
147 juce::MidiBuffer midiBuffer;
148 MidiMessageArray::MPESourceID midiSourceID = MidiMessageArray::createUniqueMPESourceID();
149
150 ActiveNoteList activeNotes;
151
152 class PluginPlayHead;
154
155 bool fullyInitialised = false, supportsMPE = false, isFlushingLayoutToState = false;
156
157 struct MPEChannelRemapper;
159
160 void prepareIncomingMidiMessages (MidiMessageArray& incoming, int numSamples, bool isPlaying);
161
162 juce::Array<ExternalAutomatableParameter*> autoParamForParamNumbers;
163
164 //==============================================================================
165 juce::String createPluginInstance (const juce::PluginDescription&);
166 void deletePluginInstance();
167
168 //==============================================================================
169 void buildParameterTree() const override;
170 void buildParameterTree (const VSTXML::Group*, AutomatableParameterTree::TreeNode*, juce::SortedSet<int>&) const;
171
172 //==============================================================================
173 void doFullInitialisation();
174 void buildParameterList();
175 void refreshParameterValues();
176 void updateDebugName();
177 void processPluginBlock (const PluginRenderContext&, bool processedBypass);
178
179 std::unique_ptr<juce::PluginDescription> findMatchingPlugin() const;
180 std::unique_ptr<juce::PluginDescription> findDescForUID (int uid, int deprecatedUid) const;
181 std::unique_ptr<juce::PluginDescription> findDescForFileOrID (const juce::String&) const;
182
183 void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;
184
185 //==============================================================================
187};
188
189//==============================================================================
194{
195 PluginWetDryAutomatableParam (const juce::String& xmlTag, const juce::String& name, Plugin&);
197
198 juce::String valueToString (float value) override;
199 float stringToValue (const juce::String& s) override;
200
203};
204
205}} // namespace tracktion { inline namespace engine
static String toHexString(IntegerType number)
CharPointer_UTF8 toUTF8() const
The Engine is the central class for all tracktion sessions.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
bool setBusLayout(juce::AudioChannelSet, bool isInput, int busIndex)
Attempts to change the layout of the plugin.
void deleteFromParent() override
Attempts to delete this plugin, whether it's a master plugin, track plugin, etc.
bool hasNameForMidiNoteNumber(int note, int midiChannel, juce::String &name) override
If it's a synth that names its notes, this can return the name it uses for this note 0-127.
bool setBusesLayout(juce::AudioProcessor::BusesLayout)
Attempts to change the layout of the plugin.
void reset() override
Should reset synth voices, tails, clear delay buffers, etc.
void setEnabled(bool enabled) override
Enable/disable the plugin.
void trackPropertiesChanged() override
Track name or colour has changed.
void selectableAboutToBeDeleted() override
Called just before the selectable is about to be deleted so any subclasses should still be valid at t...
juce::String getTooltip() override
default returns the name, others can return special stuff if needed
bool isDisabled() override
Plugins can be disabled to avoid them crashing Edits.
void applyToBuffer(const PluginRenderContext &) override
Process the next block of data.
juce::String getName() const override
The name of the type, e.g.
void initialiseFully() override
Gives the plugin a chance to do extra initialisation when it's been added to an edit.
int getNumOutputChannelsGivenInputs(int numInputs) override
This must return the number of output channels that the plugin will produce, given a number of input ...
bool hasNameForMidiProgram(int programNum, int bank, juce::String &name) override
Returns the name for a midi program, if there is one.
void deinitialise() override
Called after play stops to release resources.
juce::String getIdentifierString() override
A unique string to idenitify plugin independant of install location.
bool isMissing() override
for things like VSTs where the DLL is missing.
An ID representing one of the items in a Project.
T get(T... args)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Passed into Plugins when they are being initialised, to give them useful contextual information that ...
The context passed to plugin render methods to provide it with buffers to fill.
specialised AutomatableParameter for wet/dry.