So, I’m working on a pretty simple audio plugin and come across a problem when using a mic plugged in to my soundcard to test it: the output of my plugin rings only on one headphone, when the audio processing happens through a simple loop where i edit every channel evenly.
for(int i=0;i<nchannelsi++{
...
output[i]=... //f(input[i])
}
So, it’s safe to assume that, since I only have a mono input (and the app by default sets 2 input channels), it’s because of that. So my idea was to figure out whether or not a single mono input is being used (and which channel is the active one) by comparing the rms levels like this:
if (rms1 == 0 || rms2 == 0) {*/
active_channel = (rms1 > rms2) ? 0 : 1; //i'll process only that channel and paste it to both output channels
}
else {
active_channel = -1; //in which case i'll use a for loop
}
Somehow, this still doesn’t do the trick. The RMS of a supposedly inactive channel turns out to be non zero. Why? Any smarter way to fix this problem?
Note:the RMS trick works without the external if, but it would create issues with more than one input.