So in this demo, it provides the ability to select from multiple input and output ports.
This may be simply my misunderstanding of how this is supposed to work, but I have a MOTU 896 connected to my Mac OS X Mojave computer.
(I’ve enabled “show as stereo pairs”).
If I simply leave two outputs selected (Main 1+2), but I have a keyboard on inputs 1+2, and a microphone on input 7+8, It will process incoming audio only from Inputs 1+2, and ignore anything else because there are only two outputs selected.
You can see that it loops for only the total number of output channels.
void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill) override
{
auto* device = deviceManager.getCurrentAudioDevice();
auto activeInputChannels = device->getActiveInputChannels();
auto activeOutputChannels = device->getActiveOutputChannels();
auto maxInputChannels = activeInputChannels.countNumberOfSetBits();
auto maxOutputChannels = activeOutputChannels.countNumberOfSetBits();
for (auto channel = 0; channel < maxOutputChannels; ++channel)
{
if ((! activeOutputChannels[channel]) || maxInputChannels == 0)
{
bufferToFill.buffer->clear (channel, bufferToFill.startSample, bufferToFill.numSamples);
}
else
{
auto actualInputChannel = channel % maxInputChannels;
if (! activeInputChannels[channel])
{
bufferToFill.buffer->clear (channel, bufferToFill.startSample, bufferToFill.numSamples);
}
else
{
auto* inBuffer = bufferToFill.buffer->getReadPointer (actualInputChannel,
bufferToFill.startSample);
auto* outBuffer = bufferToFill.buffer->getWritePointer (channel, bufferToFill.startSample);
for (auto sample = 0; sample < bufferToFill.numSamples; ++sample)
outBuffer[sample] = inBuffer[sample] * random.nextFloat() * 0.25f;
}
}
}
}
Is this how it is supposed to work, or just poorly written code? I would expect the inputs to be passed to the outputs…