Juce::AudioProcessor: i/o channelcount change notification


In juce::AudioProcessor::setPlayConfigDetails, is it possible to add a virtual callback so that the plug-in can be informed that the i/o channel count has changed? (it is possible to check that inside of juce::AudioProcessor::processBlock, but we can’t assume that every DAW continuously calls the process callback). Here is an example diff:

[code]Index: modules/juce_audio_processors/processors/juce_AudioProcessor.cpp

— modules/juce_audio_processors/processors/juce_AudioProcessor.cpp (revision XXXXX)
+++ modules/juce_audio_processors/processors/juce_AudioProcessor.cpp (working copy)
@@ -70,10 +70,15 @@
const double sampleRate_,
const int blockSize_) noexcept

  • bool	lIOHasChanged = (numInputChannels != numIns || numOutputChannels != numOuts);
    numInputChannels = numIns;
    numOutputChannels = numOuts;
    sampleRate = sampleRate_;
    blockSize = blockSize_;
  • if (lIOHasChanged)
  • {
  •      IOChanged();
  • }


void AudioProcessor::setSpeakerArrangement (const String& inputs, const String& outputs)
Index: modules/juce_audio_processors/processors/juce_AudioProcessor.h

— modules/juce_audio_processors/processors/juce_AudioProcessor.h (revision XXXXX)
+++ modules/juce_audio_processors/processors/juce_AudioProcessor.h (working copy)
@@ -589,6 +589,8 @@
/** @internal */
void sendParamChangeMessageToListeners (int parameterIndex, float newValue);

  • virtual void IOChanged() {}

Array <AudioProcessorListener*> listeners;
Component::SafePointer activeEditor;

All the best

Thanks! That does seem like a pretty sensible idea! I’ll see what I can do…

wouldn’t it be cool, if all parameters-changes of in/outs/sample-rate/blocksize would be committed through the prepareToPlay and releaseResources() callbacks, just an idea

instead of calling ioChanged(), just call releaseResources() and prepareToPlay(sampleRate, estimatedSamplesPerBlock, numChannelsIn, numChannelsOut) is just an better approach , because in/out-channels are only valid during or after the prepareToPlay(), and it makes easier to reserve buffers etc.

I’ve just seen the added AudioProcessor::numChannelsChanged() callback in commit b562bba, thanks Jules.