11namespace tracktion {
inline namespace engine
16 sourceChannelIndex.referTo (state, IDs::srcChan, um);
17 destChannelIndex.referTo (state, IDs::dstChan, um);
18 gainDb.referTo (state, IDs::gainDb, um);
35 bool isSuitableType (
const juce::ValueTree& v)
const override {
return v.hasType (IDs::CONNECTION); }
37 void deleteObject (
Wire* w)
override {
delete w; }
39 void newObjectAdded (
Wire*)
override { triggerAsyncUpdate(); }
40 void objectRemoved (
Wire*)
override { triggerAsyncUpdate(); }
41 void objectOrderChanged()
override {}
44 void handleAsyncUpdate()
override
58 for (
int i = 0; i < 2; ++i)
59 makeConnection (i, i, 0.0f,
nullptr);
62PatchBayPlugin::~PatchBayPlugin()
64 notifyListenersOfDeletion();
67const char* PatchBayPlugin::xmlTypeName =
"patchbay";
69int PatchBayPlugin::getNumWires()
const {
return list->objects.size(); }
70PatchBayPlugin::Wire* PatchBayPlugin::getWire (
int index)
const {
return list->objects[index]; }
75 if (baseClassNeedsInitialising())
76 cacheInputAndOutputPlugins();
80 if (inputPlugin !=
nullptr && ! recursionCheck)
83 recursionCheck =
true;
84 inputPlugin->getChannelNames (
nullptr, &out);
85 recursionCheck =
false;
90 getLeftRightChannelNames (ins);
96 if (outputPlugin !=
nullptr && ! recursionCheck)
99 recursionCheck =
true;
100 outputPlugin->getChannelNames (&in,
nullptr);
101 recursionCheck =
false;
106 getLeftRightChannelNames (outs);
113 cacheInputAndOutputPlugins();
124 SCOPED_REALTIME_CHECK
126 int maxOutputChan = 1;
128 auto& outputBuffer = scratch.
buffer;
129 outputBuffer.
clear();
134 for (
auto w : list->objects)
136 maxOutputChan =
std::max (w->destChannelIndex.get(), maxOutputChan);
139 outputBuffer.addFrom (w->destChannelIndex, 0,
142 dbToGain (w->gainDb));
146 maxOutputChan =
std::min (2, maxOutputChan + 1);
149 for (
int i = maxOutputChan; --i >= 0;)
154void PatchBayPlugin::makeConnection (
int inputChannel,
int outputChannel,
157 for (
auto w : list->objects)
158 if (w->sourceChannelIndex == inputChannel && w->destChannelIndex == outputChannel)
161 auto w = createValueTree (IDs::CONNECTION,
162 IDs::srcChan, inputChannel,
163 IDs::dstChan, outputChannel,
164 IDs::gainDb, gainDb);
169void PatchBayPlugin::breakConnection (
int inputChannel,
int outputChannel)
171 for (
auto w : list->objects)
173 if (w->sourceChannelIndex == inputChannel && w->destChannelIndex == outputChannel)
181void PatchBayPlugin::cacheInputAndOutputPlugins()
183 inputPlugin = findPluginThatFeedsIntoThis().
get();
184 outputPlugin = findPluginThatThisFeedsInto().
get();
void setSize(int newNumChannels, int newNumSamples, bool keepExistingContent=false, bool clearExtraSpace=false, bool avoidReallocating=false)
int getNumChannels() const noexcept
int getNumSamples() const noexcept
void copyFrom(int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples) noexcept
ReferencedType * get() const noexcept
void addArray(const StringArray &other, int startIndex=0, int numElementsToAdd=-1)
void removeChild(const ValueTree &child, UndoManager *undoManager)
void addChild(const ValueTree &child, int index, UndoManager *undoManager)
An audio scratch buffer that has pooled storage.
juce::AudioBuffer< float > & buffer
The buffer to use.
void applyToBuffer(const PluginRenderContext &) override
Process the next block of data.
void deinitialise() override
Called after play stops to release resources.
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.
int bufferNumSamples
The number of samples to write into the audio buffer.
juce::AudioBuffer< float > * destBuffer
The target audio buffer which needs to be filled.
int bufferStartSample
The index of the start point in the audio buffer from which data must be written.