Update to play.cpp to play mono files out as stereo.

This commit is contained in:
Gary Scavone
2015-11-03 16:35:46 -05:00
parent f13866e696
commit 5e79513e5a

View File

@@ -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; i<frames.size(); i++ )
for ( unsigned int i=0; i<frames.size(); i++ ) {
*samples++ = frames[i];
if ( input->channelsOut() == 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 {