aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
Diffstat (limited to 'alc')
-rw-r--r--alc/alu.cpp7
-rw-r--r--alc/buffer_storage.cpp1
-rw-r--r--alc/buffer_storage.h1
-rw-r--r--alc/effects/convolution.cpp21
-rw-r--r--alc/inprogext.h7
5 files changed, 36 insertions, 1 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 2c0093ed..67bb8ebc 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -791,6 +791,13 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
case FmtBFormat3D:
DirectChannels = DirectMode::Off;
break;
+
+ /* TODO: UHJ2 should be treated as BFormat2D for panning. */
+ case FmtUHJ2:
+ DirectChannels = DirectMode::Off;
+ chans = StereoMap;
+ downmix_gain = 1.0f / 2.0f;
+ break;
}
voice->mFlags &= ~(VoiceHasHrtf | VoiceHasNfc);
diff --git a/alc/buffer_storage.cpp b/alc/buffer_storage.cpp
index 7d3adddd..58752341 100644
--- a/alc/buffer_storage.cpp
+++ b/alc/buffer_storage.cpp
@@ -33,6 +33,7 @@ uint ChannelsFromFmt(FmtChannels chans, uint ambiorder) noexcept
case FmtX71: return 8;
case FmtBFormat2D: return (ambiorder*2) + 1;
case FmtBFormat3D: return (ambiorder+1) * (ambiorder+1);
+ case FmtUHJ2: return 2;
}
return 0;
}
diff --git a/alc/buffer_storage.h b/alc/buffer_storage.h
index b08dd1e0..2f8da5e2 100644
--- a/alc/buffer_storage.h
+++ b/alc/buffer_storage.h
@@ -27,6 +27,7 @@ enum FmtChannels : unsigned char {
FmtX71, /* (WFX order) */
FmtBFormat2D,
FmtBFormat3D,
+ FmtUHJ2, /* 2-channel UHJ, aka "BHJ", stereo-compatible */
};
enum class AmbiLayout : unsigned char {
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 22311bbb..d03d661f 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -374,7 +374,25 @@ void ConvolutionState::update(const ALCcontext *context, const EffectSlot *slot,
for(auto &chan : *mChans)
std::fill(std::begin(chan.Target), std::end(chan.Target), 0.0f);
const float gain{slot->Gain};
- if(mChannels == FmtBFormat3D || mChannels == FmtBFormat2D)
+ /* TODO: UHJ should be decoded to B-Format and processed that way, since
+ * there's no telling if it can ever do a direct-out mix (even if the
+ * device is outputing UHJ, the effect slot can feed another effect that's
+ * not UHJ).
+ *
+ * Not that UHJ should really ever be used for convolution, but it's a
+ * valid format regardless.
+ */
+ if(mChannels == FmtUHJ2 && target.RealOut
+ && target.RealOut->ChannelIndex[FrontLeft] != INVALID_CHANNEL_INDEX
+ && target.RealOut->ChannelIndex[FrontRight] != INVALID_CHANNEL_INDEX)
+ {
+ mOutTarget = target.RealOut->Buffer;
+ const uint lidx = target.RealOut->ChannelIndex[FrontLeft];
+ const uint ridx = target.RealOut->ChannelIndex[FrontRight];
+ (*mChans)[0].Target[lidx] = gain;
+ (*mChans)[1].Target[ridx] = gain;
+ }
+ else if(mChannels == FmtBFormat3D || mChannels == FmtBFormat2D)
{
ALCdevice *device{context->mDevice.get()};
if(device->mAmbiOrder > mAmbiOrder)
@@ -416,6 +434,7 @@ void ConvolutionState::update(const ALCcontext *context, const EffectSlot *slot,
case FmtX71: chanmap = X71Map; break;
case FmtBFormat2D:
case FmtBFormat3D:
+ case FmtUHJ2:
break;
}
diff --git a/alc/inprogext.h b/alc/inprogext.h
index bb16531a..a3319ff7 100644
--- a/alc/inprogext.h
+++ b/alc/inprogext.h
@@ -76,6 +76,13 @@ ALCboolean ALC_APIENTRY alcReopenDeviceSOFT(ALCdevice *device, const ALCchar *de
#endif
#endif
+#ifndef AL_SOFT_UHJ
+#define AL_SOFT_UHJ
+#define AL_FORMAT_UHJ2CHN8 0x19A2
+#define AL_FORMAT_UHJ2CHN16 0x19A3
+#define AL_FORMAT_UHJ2CHN_FLOAT32 0x19A4
+#endif
+
#ifdef __cplusplus
} /* extern "C" */
#endif