From 5e79513e5a281333634fa6a1de4ff00a0b9e187c Mon Sep 17 00:00:00 2001 From: Gary Scavone Date: Tue, 3 Nov 2015 16:35:46 -0500 Subject: [PATCH] Update to play.cpp to play mono files out as stereo. --- projects/examples/play.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/examples/play.cpp b/projects/examples/play.cpp index 3706fcf..e87bbb8 100644 --- a/projects/examples/play.cpp +++ b/projects/examples/play.cpp @@ -48,9 +48,11 @@ int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, register StkFloat *samples = (StkFloat *) outputBuffer; input->tick( frames ); - for ( unsigned int i=0; ichannelsOut() == 1 ) *samples++ = frames[i]; // play mono files in stereo + } + if ( input->isFinished() ) { done = true; return 1; @@ -93,7 +95,7 @@ int main(int argc, char *argv[]) // Figure out how many bytes in an StkFloat and setup the RtAudio stream. RtAudio::StreamParameters parameters; parameters.deviceId = dac.getDefaultOutputDevice(); - parameters.nChannels = channels; + parameters.nChannels = ( channels == 1 ) ? 2 : channels; // Play mono files as stereo. RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32; unsigned int bufferFrames = RT_BUFFER_SIZE; try {