diff --git a/Source/Engine/Audio/AudioBackendTools.h b/Source/Engine/Audio/AudioBackendTools.h index 8ef709144..ea3b7c10b 100644 --- a/Source/Engine/Audio/AudioBackendTools.h +++ b/Source/Engine/Audio/AudioBackendTools.h @@ -160,18 +160,8 @@ public: break; case 2: default: // TODO: implement multi-channel support (eg. 5.1, 7.1) - if (sourceChannels == 1) - { - outputMatrix[0] = channels[FrontLeft]; - outputMatrix[1] = channels[FrontRight]; - } - else if (sourceChannels == 2) - { - outputMatrix[0] = channels[FrontLeft]; - outputMatrix[1] = 0.0f; - outputMatrix[2] = 0.0f; - outputMatrix[3] = channels[FrontRight]; - } + outputMatrix[0] = channels[FrontLeft]; + outputMatrix[sourceChannels + 1] = channels[FrontRight]; break; } } diff --git a/Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp b/Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp index d29e3a31b..879061d61 100644 --- a/Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp +++ b/Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp @@ -498,7 +498,7 @@ void AudioBackendOAL::Buffer_Write(uint32 bufferID, byte* samples, const AudioDa } else { - LOG(Warning, "OpenAL doesn't support bit depth larger than 16. Your audio data will be truncated."); + LOG(Warning, "OpenAL doesn't support bit depth larger than 16. Audio data will be truncated."); const uint32 bufferSize = info.NumSamples * 2; byte* sampleBuffer16 = (byte*)Allocator::Allocate(bufferSize); AudioTool::ConvertBitDepth(samples, info.BitDepth, sampleBuffer16, 16, info.NumSamples); diff --git a/Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp b/Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp index 4c6f93947..b692da8f4 100644 --- a/Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp +++ b/Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp @@ -19,11 +19,9 @@ // Include XAudio library // Documentation: https://docs.microsoft.com/en-us/windows/desktop/xaudio2/xaudio2-apis-portal #include -//#include -//#include // TODO: implement multi-channel support (eg. 5.1, 7.1) -#define MAX_INPUT_CHANNELS 2 +#define MAX_INPUT_CHANNELS 6 #define MAX_OUTPUT_CHANNELS 2 #define MAX_CHANNELS_MATRIX_SIZE (MAX_INPUT_CHANNELS*MAX_OUTPUT_CHANNELS) #if ENABLE_ASSERTION @@ -151,6 +149,7 @@ namespace XAudio2 IXAudio2* Instance = nullptr; IXAudio2MasteringVoice* MasteringVoice = nullptr; int32 Channels; + DWORD ChannelMask; bool ForceDirty = true; AudioBackendTools::Settings Settings; Listener Listener; @@ -683,7 +682,7 @@ bool AudioBackendXAudio2::Base_Init() } XAUDIO2_VOICE_DETAILS details; XAudio2::MasteringVoice->GetVoiceDetails(&details); -#if 0 +#if MAX_OUTPUT_CHANNELS > 2 // TODO: implement multi-channel support (eg. 5.1, 7.1) XAudio2::Channels = details.InputChannels; hr = XAudio2::MasteringVoice->GetChannelMask(&XAudio2::ChannelMask); @@ -694,6 +693,7 @@ bool AudioBackendXAudio2::Base_Init() } #else XAudio2::Channels = 2; + XAudio2::ChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; #endif LOG(Info, "XAudio2: {0} channels at {1} kHz", XAudio2::Channels, details.InputSampleRate / 1000.0f);