Why only hear audio on left speaker if set 1 input channel and 2 output channels?


#1

Hi everyone,
I want to record data from microphone then do some calculation for output data base on input data and pass them to left-right speaker.
Base on a tutorial on: https://www.juce.com/doc/tutorial_processing_audio_input
I used AudioAppComponent class to do that. I set 1 input channel for my microphone, 2 output channel for left-right speaker:
// Set 1 input channel and 2 output channel
setAudioChannels(1, 2);
Then in the function void getNextAudioBlock(const AudioSourceChannelInfo& bufferToFill) I get input buffer then do my calculation and write output to output buffer.
const float* inBuffer = bufferToFill.buffer->getReadPointer(0, bufferToFill.startSample);
float* leftOutData = bufferToFill.buffer->getWritePointer(0, bufferToFill.startSample);
float* rightOutData = bufferToFill.buffer->getWritePointer(1, bufferToFill.startSample);
// do something with inBuffer and update leftOutData, rightOutData
But when opening my application, I just hear audio on the left speaker.
Can you please explain me why this issue happened and how to fix it?


#2

Should that be

float* rightOutData = bufferToFill.buffer->getWritePointer(1, bufferToFill.startSample);

?


#3

It is a typing mistake, I updated description.


#4

You’re going to need to post more code than that - how about sharing the whole of a simplified version of your getNextAudioBlock method?

Have you tried using the AudioAppExample as a starting point? That definitely has stereo output, so it your modify that instead that might help us narrow down the problem.