6r0m
(6r0m)
9
bool FSoundConverter::ConvertPcmToMono(const TArray<uint8>& InPcmData, const FCustomSoundInfo& InSoundInfo, TArray<uint8>& OutMonoPcmData)
{
if ( !InSoundInfo.IsValid() )
{
UE_LOG(LogSoundCL, Error, TEXT("%s -- InSoundInfo isn't Valid!"), *FString(__FUNCTION__));
return false;
}
const SIZE_T SampleSize = InSoundInfo.NumChannels * (InSoundInfo.BitsPerSample / 8) ;
const SIZE_T MonoSampleSize = SampleSize / InSoundInfo.NumChannels;
for (SIZE_T i = 0; i < InSoundInfo.SamplesDataSize; i += SampleSize)
{
OutMonoPcmData.Append( TArray( &(InPcmData[i + SampleSize - MonoSampleSize] ), MonoSampleSize ));
}
return (OutMonoPcmData.Num() > 0);