I lent a P4 laptop to do some tests on it. It has a SIS7012 soundchip and something very weird happens on it:
Although it has only 1 Stereo Output and 1 Stereo Input, audioDeviceIOCallback receives as parameters 4 output channels and 4 inputs channels. Strange is that the AudioDeviceSelectorComponent only lets me select one stereo output or stereo input, which both are called “Left/Right” (so the selector works as it should, but the audioDeviceIOCallback does not).
I noticed that the 2 first output buffer pointers of audioDeviceIOCallback are always 0 and the 2 following are the “real pointers” to “Left/Right”.
Also, in 50% of the cases, the CPU usage goes up to 100% directly at the start of my app, even if there is no code in audioDeviceIOCallback. When I select << no audio device >> in the AudioDeviceSelectorComponent, the CPU usage goes back to 1%.
This is with Juce 1.45.
Edit: I just tried out with my ESI U46DJ (which has 3 Stereo Outputs and 2 Stereo Inputs) on the same laptop, and there’s also a strange behaviour when using non-ASIO drivers: numInputBuffers AND numOutputBuffers equals 10 (so it is the sum of the output plus the input buffers). This also explains the number 4 (2 outs + 2 ins) for the SiS7012.
Oh maybe I mis-read your post. I don’t think there’s actually anything wrong here - I guess some of those channels that are passed in are null pointers? That’s actually how it works - just ignore the null ones.
The array you get has one pointer per channel, and some of them might be null if you didn’t enable that channel when you called AudioIODevice::open(). If you want to see what all the channels are called, you can call AudioIODevice::getInputChannelNames, and that should be a big clue about what’s going on.
Ok, I understand that, if not activated some inputs may be NULL. But my soundcard has 4 Cinch Inputs (is that clear now?). So is it normal or even possible that audioIODeviceCallback tells me that there are 10 input channels?
Ok, but for the third time, please tell me what names is it reporting for these 10 channels! Are they channels from another device? Duplicates of other channels? Blank strings? Special internal channels for that device?
Sure, there might be a bug, but unless we can work out where these extra channels are coming from, there’s not much I can suggest.
Well, for the SiS7012, when I call AudioIODevice::getInputChannelNames(), it returns a StringArray containing only 2 Strings, which are: “Left” and “Right” (which is correct), but totalNumInputChannels is now 10.
inputChannelDate[2] and inputChannelData[3] are non-0, all others are 0.
But that’s fine! Ignore the other 8 pointers, which will be null. If it tells you there are 2 channels, and you open it with 2 channels, and you get your 2 pointers back, it doesn’t matter if there are some extra null pointers in the array.
No, it doesn’t! totalNumInputChannels only tells you how many elements are in the array. A better name would probably be “numChannelsInArray” or something. Doesn’t matter whether it’s 2, 10 or a million. It might even change from one callback to the next. But if you’ve asked for 2 channels, only 2 of them will be non-zero.
getNumInputChannels() is the thing that you how many channels there are, and it says 2, which is correct!
ok. my SiS7012 only has 2 outputs, which are both active.
Why do they appear in the outputChannelData array at positions 2&3 instead of 0&1 (0&1 are null) ? The index is just wrong!?