From 98d9b4e06469389d13251c2d3ec248c7f24c5e68 Mon Sep 17 00:00:00 2001 From: Emlyn Bolton Date: Mon, 13 Apr 2020 14:55:29 -0700 Subject: [PATCH] Add support for multichannel out --- mac/sound.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mac/sound.cpp b/mac/sound.cpp index 81c95683..979b8aa1 100755 --- a/mac/sound.cpp +++ b/mac/sound.cpp @@ -885,6 +885,25 @@ if ( iNumInChan == 4 ) if ( outOutputData->mBuffers[0].mDataByteSize == static_cast ( iCoreAudioBufferSizeMono * iNumOutChan * 4 ) ) { + // Outputs are to individual buffers too, rather than using channels + Float32* pLeftOutData = static_cast ( outOutputData->mBuffers[iSelOutputLeftChannel].mData ); + Float32* pRightOutData = static_cast ( outOutputData->mBuffers[iSelOutputRightChannel].mData ); + + // copy output data + for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ ) + { + // left + pLeftOutData[i] = + (Float32) pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT; + + // right + pRightOutData[i] = + (Float32) pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT; + } + + } else if ( outOutputData->mBuffers[0].mDataByteSize == + static_cast ( iCoreAudioBufferSizeMono * iNumOutChan * 4 ) ) { + // Outputs are 2 channels in one buffer // get a pointer to the input data of the correct type Float32* pOutData = static_cast ( outOutputData->mBuffers[0].mData );