Hi,
I’ve been following some tutorials and decided to try a very simple thing to get a bit firmer grasp on JUCE. I load a stereo WAV file and employ basic Play and Stop functionality via AudioTransportSource class. While playing the file, the only processing I’d like to do is switching the channels. I do that in the getNextAudioBlock() method below … only to get both output channels playing the right channel of the incoming file. I know there must be something very basic I’m missing, but I don’t see it.
</
void MainComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
transport.getNextAudioBlock(bufferToFill);
auto* leftIn = bufferToFill.buffer->getReadPointer(0, bufferToFill.startSample);
auto* rightIn = bufferToFill.buffer->getReadPointer(1, bufferToFill.startSample);
auto* leftOut = bufferToFill.buffer->getWritePointer(0, bufferToFill.startSample);
auto* rightOut = bufferToFill.buffer->getWritePointer(1, bufferToFill.startSample);
for (auto sample = 0; sample < bufferToFill.numSamples; ++sample)
{
leftOut[sample] = rightIn[sample];
rightOut[sample] = leftIn[sample];
}
}>