I have been trying to work this out myself for many days and have read lots of posts that get close to what I’m trying to do but still haven’t managed to crack it. I am new to C++ and to Juce (thanks to Jules by the way for a great framework that is really helping me get into C++ in an ‘easy’ way). Apologies if I’m asking something very obvious, I’m also new to audio processing.
I’m reading from a wav file on disk, it may be mono or it may be stereo. Then I want to play it through multiple channels (4 at the moment but expandable in the future). Then I want to be able to individually control the gain of each channel.
I made a ChannelGainAudioSourcePlayer with a setChannelGain() method which just uses the same idea as the existing setGain() but with arrays of lastGain and gain (to match the number of output channels) instead of individual values.
I think my main problem is not having been able to successfully copy data from the input channel/s into multiple output channels. It seemed that I needed to do something like:
buffer.copyFrom(1, 0,buffer, 0, 0, numSamples);
buffer.copyFrom(2, 0,buffer, 0, 0, numSamples);
buffer.copyFrom(3, 0,buffer, 0, 0, numSamples);
But this still always ends up only sending sound to the first two output channels.
As far as I can tell I am opening the device with the correct number of channels and BigIntegers to specify which output channels I want to send to.
I have seen that AudioFormatReader.read() has a parameter ‘fillLeftoverChannelsWithCopies’ which sounds perfect, but I can’t ‘get at it’. My reader is being provided by WavAudioFormat->createReaderFor()
Could anyone maybe point me in the rough direction of how I might approach this?