mirror of
https://github.com/thestk/stk
synced 2026-04-19 14:06:55 +00:00
Update to play.cpp to play mono files out as stereo.
This commit is contained in:
@@ -48,8 +48,10 @@ int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
|
|||||||
register StkFloat *samples = (StkFloat *) outputBuffer;
|
register StkFloat *samples = (StkFloat *) outputBuffer;
|
||||||
|
|
||||||
input->tick( frames );
|
input->tick( frames );
|
||||||
for ( unsigned int i=0; i<frames.size(); i++ )
|
for ( unsigned int i=0; i<frames.size(); i++ ) {
|
||||||
*samples++ = frames[i];
|
*samples++ = frames[i];
|
||||||
|
if ( input->channelsOut() == 1 ) *samples++ = frames[i]; // play mono files in stereo
|
||||||
|
}
|
||||||
|
|
||||||
if ( input->isFinished() ) {
|
if ( input->isFinished() ) {
|
||||||
done = true;
|
done = true;
|
||||||
@@ -93,7 +95,7 @@ int main(int argc, char *argv[])
|
|||||||
// Figure out how many bytes in an StkFloat and setup the RtAudio stream.
|
// Figure out how many bytes in an StkFloat and setup the RtAudio stream.
|
||||||
RtAudio::StreamParameters parameters;
|
RtAudio::StreamParameters parameters;
|
||||||
parameters.deviceId = dac.getDefaultOutputDevice();
|
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;
|
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
|
||||||
unsigned int bufferFrames = RT_BUFFER_SIZE;
|
unsigned int bufferFrames = RT_BUFFER_SIZE;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user