mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
AudioProcessorGraph: Fix MIDI channel bug and graph execution modification
MIDI only plugins are no longer provided valid audio buffers Graph nodes are only executed when they have active connections
This commit is contained in:
parent
15bdae16b2
commit
b918fd3159
3 changed files with 21 additions and 2 deletions
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midi) override
|
void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midi) override
|
||||||
{
|
{
|
||||||
// the audio buffer in a midi effect will have zero channels!
|
// A pure MIDI plugin shouldn't be provided any audio data
|
||||||
jassert (buffer.getNumChannels() == 0);
|
jassert (buffer.getNumChannels() == 0);
|
||||||
|
|
||||||
// however we use the buffer to get timing information
|
// however we use the buffer to get timing information
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,16 @@ private:
|
||||||
for (int i = 0; i < totalChans; ++i)
|
for (int i = 0; i < totalChans; ++i)
|
||||||
audioChannels[i] = c.audioBuffers[audioChannelsToUse.getUnchecked (i)];
|
audioChannels[i] = c.audioBuffers[audioChannelsToUse.getUnchecked (i)];
|
||||||
|
|
||||||
AudioBuffer<FloatType> buffer (audioChannels, totalChans, c.numSamples);
|
auto numAudioChannels = [this]
|
||||||
|
{
|
||||||
|
if (const auto* proc = node->getProcessor())
|
||||||
|
if (proc->getTotalNumInputChannels() == 0 && proc->getTotalNumOutputChannels() == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return totalChans;
|
||||||
|
}();
|
||||||
|
|
||||||
|
AudioBuffer<FloatType> buffer (audioChannels, numAudioChannels, c.numSamples);
|
||||||
|
|
||||||
const ScopedLock lock (processor.getCallbackLock());
|
const ScopedLock lock (processor.getCallbackLock());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,17 +155,27 @@ public:
|
||||||
void prepare (double newSampleRate, int newBlockSize, AudioProcessorGraph*, ProcessingPrecision);
|
void prepare (double newSampleRate, int newBlockSize, AudioProcessorGraph*, ProcessingPrecision);
|
||||||
void unprepare();
|
void unprepare();
|
||||||
|
|
||||||
|
bool hasNoConnections() const noexcept { return inputs.isEmpty() && outputs.isEmpty(); }
|
||||||
|
|
||||||
template <typename Sample>
|
template <typename Sample>
|
||||||
void processBlock (AudioBuffer<Sample>& audio, MidiBuffer& midi)
|
void processBlock (AudioBuffer<Sample>& audio, MidiBuffer& midi)
|
||||||
{
|
{
|
||||||
|
if (hasNoConnections())
|
||||||
|
return;
|
||||||
|
|
||||||
const ScopedLock lock (processorLock);
|
const ScopedLock lock (processorLock);
|
||||||
|
|
||||||
processor->processBlock (audio, midi);
|
processor->processBlock (audio, midi);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Sample>
|
template <typename Sample>
|
||||||
void processBlockBypassed (AudioBuffer<Sample>& audio, MidiBuffer& midi)
|
void processBlockBypassed (AudioBuffer<Sample>& audio, MidiBuffer& midi)
|
||||||
{
|
{
|
||||||
|
if (hasNoConnections())
|
||||||
|
return;
|
||||||
|
|
||||||
const ScopedLock lock (processorLock);
|
const ScopedLock lock (processorLock);
|
||||||
|
|
||||||
processor->processBlockBypassed (audio, midi);
|
processor->processBlockBypassed (audio, midi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue