From 0af1b5f7218cf60e3a51f43903f3c5461cdcbdf8 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 21 Dec 2021 08:18:07 -0800 Subject: Don't do direct channels with UHJ output Directly mixing a non-UHJ stereo signal into a UHJ stereo signal results in a non-UHJ stereo signal. Such a mix can't be properly decoded anymore. An option can probably be added for users that intend to listen to UHJ output undecoded and let a stereo sound come through as-is on their speakers, but it probably shouldn't be the default for cases where the output may be decoded back. --- alc/alc.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'alc/alc.cpp') diff --git a/alc/alc.cpp b/alc/alc.cpp index b63f0f82..bbcd6d01 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1430,15 +1430,6 @@ ALCenum EnumFromDevAmbi(DevAmbiScaling scaling) * existing ones. Based on Wine's DSound downmix values, which are based on * PulseAudio's. */ -const std::array MonoDownmix{{ - { FrontLeft, {{{FrontCenter, 0.5f}, {LFE, 0.0f}}} }, - { FrontRight, {{{FrontCenter, 0.5f}, {LFE, 0.0f}}} }, - { SideLeft, {{{FrontCenter, 0.5f/9.0f}, {LFE, 0.0f}}} }, - { SideRight, {{{FrontCenter, 0.5f/9.0f}, {LFE, 0.0f}}} }, - { BackLeft, {{{FrontCenter, 0.5f/9.0f}, {LFE, 0.0f}}} }, - { BackRight, {{{FrontCenter, 0.5f/9.0f}, {LFE, 0.0f}}} }, - { BackCenter, {{{FrontCenter, 1.0f/9.0f}, {LFE, 0.0f}}} }, -}}; const std::array StereoDownmix{{ { FrontCenter, {{{FrontLeft, 0.5f}, {FrontRight, 0.5f}}} }, { SideLeft, {{{FrontLeft, 1.0f/9.0f}, {FrontRight, 0.0f}}} }, @@ -1855,17 +1846,6 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) DevFmtChannelsString(device->FmtChans), DevFmtTypeString(device->FmtType), device->Frequency, device->UpdateSize, device->BufferSize); - switch(device->FmtChans) - { - case DevFmtMono: device->RealOut.RemixMap = MonoDownmix; break; - case DevFmtStereo: device->RealOut.RemixMap = StereoDownmix; break; - case DevFmtQuad: device->RealOut.RemixMap = QuadDownmix; break; - case DevFmtX51: device->RealOut.RemixMap = X51Downmix; break; - case DevFmtX61: device->RealOut.RemixMap = X61Downmix; break; - case DevFmtX71: device->RealOut.RemixMap = X71Downmix; break; - case DevFmtAmbi3D: break; - } - if(device->Type != DeviceType::Loopback) { if(auto modeopt = device->configValue(nullptr, "stereo-mode")) @@ -1899,6 +1879,20 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) device->SourcesMax, device->NumMonoSources, device->NumStereoSources, device->AuxiliaryEffectSlotMax, device->NumAuxSends); + switch(device->FmtChans) + { + case DevFmtMono: break; + case DevFmtStereo: + if(!device->mUhjEncoder) + device->RealOut.RemixMap = StereoDownmix; + break; + case DevFmtQuad: device->RealOut.RemixMap = QuadDownmix; break; + case DevFmtX51: device->RealOut.RemixMap = X51Downmix; break; + case DevFmtX61: device->RealOut.RemixMap = X61Downmix; break; + case DevFmtX71: device->RealOut.RemixMap = X71Downmix; break; + case DevFmtAmbi3D: break; + } + nanoseconds::rep sample_delay{0}; if(device->mUhjEncoder) sample_delay += UhjEncoder::sFilterDelay; -- cgit v1.2.3