Playing sound in individual channel


#1

Hi everyone. I've a problem - I need to play sound in exactly one channel of 7.1 system without it bleeding to other channels (though sometimes I need to play different sounds on different channels simultaneously). Is there any way to do it with a JUCE?


#2

just write to the buffer assigned to that channel in your process() method. 


#3

Yes, you can write to different channels.

For instance you can write a loop to loop through the channels

for (int channel = 0; channel < getNumInputChannels(); ++channel)

Or you can select one channel's data like this :

float* channelData = buffer.getWritePointer(numChannelYouWantToSelect); // first channel

So basically you can do something like :

for (int channel = 0; channel < getNumInputChannels(); ++channel)
{
        float* channelData = buffer.getWritePointer(channel);
        doMyProcessing(channelData);
}

 


#4

Please be aware that if you only write to one of several channels in your process method, then you are leaving the audio buffer contents for the other channels undefined. This might leave them filled with some random garbage values. You should at least write zeros to the other channels to make sure they don't produce any horrible noise.