Store the ambisonic order as unsigned
This commit is contained in:
+7
-7
@@ -1286,7 +1286,7 @@ ALuint BytesFromDevFmt(DevFmtType type) noexcept
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept
|
||||
ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALuint ambiorder) noexcept
|
||||
{
|
||||
switch(chans)
|
||||
{
|
||||
@@ -1297,7 +1297,7 @@ ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept
|
||||
case DevFmtX51Rear: return 6;
|
||||
case DevFmtX61: return 7;
|
||||
case DevFmtX71: return 8;
|
||||
case DevFmtAmbi3D: return static_cast<ALuint>((ambiorder+1) * (ambiorder+1));
|
||||
case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1639,7 +1639,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
ALCenum schans{AL_NONE};
|
||||
ALCenum stype{AL_NONE};
|
||||
ALCsizei attrIdx{0};
|
||||
ALCsizei aorder{0};
|
||||
ALCuint aorder{0};
|
||||
ALCuint freq{0u};
|
||||
|
||||
ALuint numMono{device->NumMonoSources};
|
||||
@@ -1677,7 +1677,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
break;
|
||||
|
||||
case ALC_AMBISONIC_ORDER_SOFT:
|
||||
aorder = attrList[attrIdx + 1];
|
||||
aorder = static_cast<ALuint>(attrList[attrIdx + 1]);
|
||||
TRACE_ATTR(ALC_AMBISONIC_ORDER_SOFT, aorder);
|
||||
break;
|
||||
|
||||
@@ -2855,7 +2855,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<ALCin
|
||||
values[i++] = static_cast<ALCint>(device->mAmbiScale);
|
||||
|
||||
values[i++] = ALC_AMBISONIC_ORDER_SOFT;
|
||||
values[i++] = device->mAmbiOrder;
|
||||
values[i++] = static_cast<ALCint>(device->mAmbiOrder);
|
||||
}
|
||||
|
||||
values[i++] = ALC_FORMAT_CHANNELS_SOFT;
|
||||
@@ -2973,7 +2973,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<ALCin
|
||||
alcSetError(device, ALC_INVALID_DEVICE);
|
||||
return 0;
|
||||
}
|
||||
values[0] = device->mAmbiOrder;
|
||||
values[0] = static_cast<int>(device->mAmbiOrder);
|
||||
return 1;
|
||||
|
||||
case ALC_MONO_SOURCES:
|
||||
@@ -3558,7 +3558,7 @@ START_API_FUNC
|
||||
static constexpr struct ChannelMap {
|
||||
const char name[16];
|
||||
DevFmtChannels chans;
|
||||
ALsizei order;
|
||||
ALuint order;
|
||||
} chanlist[] = {
|
||||
{ "mono", DevFmtMono, 0 },
|
||||
{ "stereo", DevFmtStereo, 0 },
|
||||
|
||||
+2
-2
@@ -213,9 +213,9 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
|
||||
ALuint BufferSize{};
|
||||
|
||||
DevFmtChannels FmtChans{};
|
||||
DevFmtType FmtType{};
|
||||
DevFmtType FmtType{};
|
||||
ALboolean IsHeadphones{AL_FALSE};
|
||||
ALsizei mAmbiOrder{0};
|
||||
ALuint mAmbiOrder{0};
|
||||
/* For DevFmtAmbi* output only, specifies the channel order and
|
||||
* normalization.
|
||||
*/
|
||||
|
||||
@@ -274,7 +274,7 @@ ALCboolean WaveBackend::reset()
|
||||
case DevFmtX71: chanmask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x200 | 0x400; break;
|
||||
case DevFmtAmbi3D:
|
||||
/* .amb output requires FuMa */
|
||||
mDevice->mAmbiOrder = mini(mDevice->mAmbiOrder, 3);
|
||||
mDevice->mAmbiOrder = minu(mDevice->mAmbiOrder, 3);
|
||||
mDevice->mAmbiLayout = AmbiLayout::FuMa;
|
||||
mDevice->mAmbiScale = AmbiNorm::FuMa;
|
||||
isbformat = 1;
|
||||
|
||||
+3
-4
@@ -31,7 +31,7 @@ constexpr ALfloat Ambi3DDecoderHFScale3O[MAX_AMBI_ORDER+1] = {
|
||||
5.89792205e-01f, 8.79693856e-01f
|
||||
};
|
||||
|
||||
inline auto GetDecoderHFScales(ALsizei order) noexcept -> const ALfloat(&)[MAX_AMBI_ORDER+1]
|
||||
inline auto GetDecoderHFScales(ALuint order) noexcept -> const ALfloat(&)[MAX_AMBI_ORDER+1]
|
||||
{
|
||||
if(order >= 3) return Ambi3DDecoderHFScale3O;
|
||||
if(order == 2) return Ambi3DDecoderHFScale2O;
|
||||
@@ -187,17 +187,16 @@ void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer,
|
||||
}
|
||||
|
||||
|
||||
std::array<ALfloat,MAX_AMBI_ORDER+1> BFormatDec::GetHFOrderScales(const ALsizei in_order, const ALsizei out_order) noexcept
|
||||
std::array<ALfloat,MAX_AMBI_ORDER+1> BFormatDec::GetHFOrderScales(const ALuint in_order, const ALuint out_order) noexcept
|
||||
{
|
||||
std::array<ALfloat,MAX_AMBI_ORDER+1> ret{};
|
||||
|
||||
assert(out_order >= in_order);
|
||||
ASSUME(out_order >= in_order);
|
||||
|
||||
const ALfloat (&target)[MAX_AMBI_ORDER+1] = GetDecoderHFScales(out_order);
|
||||
const ALfloat (&input)[MAX_AMBI_ORDER+1] = GetDecoderHFScales(in_order);
|
||||
|
||||
for(ALsizei i{0};i < in_order+1;++i)
|
||||
for(ALuint i{0};i < in_order+1;++i)
|
||||
ret[i] = input[i] / target[i];
|
||||
|
||||
return ret;
|
||||
|
||||
+2
-2
@@ -53,8 +53,8 @@ public:
|
||||
const size_t SamplesToDo);
|
||||
|
||||
/* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
|
||||
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order,
|
||||
const ALsizei out_order) noexcept;
|
||||
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALuint in_order,
|
||||
const ALuint out_order) noexcept;
|
||||
|
||||
DEF_NEWDEL(BFormatDec)
|
||||
};
|
||||
|
||||
+2
-2
@@ -98,8 +98,8 @@ struct DevFmtTypeTraits<DevFmtFloat> { using Type = ALfloat; };
|
||||
|
||||
|
||||
ALuint BytesFromDevFmt(DevFmtType type) noexcept;
|
||||
ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept;
|
||||
inline ALuint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, ALsizei ambiorder) noexcept
|
||||
ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALuint ambiorder) noexcept;
|
||||
inline ALuint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, ALuint ambiorder) noexcept
|
||||
{ return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
|
||||
|
||||
enum class AmbiLayout {
|
||||
|
||||
+4
-4
@@ -269,7 +269,7 @@ constexpr ChannelMap MonoCfg[1] = {
|
||||
{ BackRight, { 2.04124145e-1f, -1.08880247e-1f, -1.88586120e-1f, 1.29099444e-1f, 7.45355993e-2f, -3.73460789e-2f, 0.00000000e+0f } },
|
||||
};
|
||||
|
||||
void InitNearFieldCtrl(ALCdevice *device, ALfloat ctrl_dist, ALsizei order,
|
||||
void InitNearFieldCtrl(ALCdevice *device, ALfloat ctrl_dist, ALuint order,
|
||||
const al::span<const ALuint,MAX_AMBI_ORDER+1> chans_per_order)
|
||||
{
|
||||
/* NFC is only used when AvgSpeakerDist is greater than 0. */
|
||||
@@ -448,7 +448,7 @@ void InitPanning(ALCdevice *device)
|
||||
* channel count. Built-in speaker decoders are always 2D, so just
|
||||
* reverse that calculation.
|
||||
*/
|
||||
device->mAmbiOrder = static_cast<ALsizei>((coeffcount-1) / 2);
|
||||
device->mAmbiOrder = (coeffcount-1) / 2;
|
||||
|
||||
std::transform(AmbiIndex::From2D.begin(), AmbiIndex::From2D.begin()+coeffcount,
|
||||
std::begin(device->Dry.AmbiMap),
|
||||
@@ -478,7 +478,7 @@ void InitCustomPanning(ALCdevice *device, bool hqdec, const AmbDecConf *conf,
|
||||
|
||||
const ALuint order{(conf->ChanMask > AMBI_2ORDER_MASK) ? 3u :
|
||||
(conf->ChanMask > AMBI_1ORDER_MASK) ? 2u : 1u};
|
||||
device->mAmbiOrder = static_cast<ALsizei>(order);
|
||||
device->mAmbiOrder = order;
|
||||
|
||||
ALuint count;
|
||||
if((conf->ChanMask&AMBI_PERIPHONIC_MASK))
|
||||
@@ -582,7 +582,7 @@ void InitHrtfPanning(ALCdevice *device)
|
||||
* and it eases the CPU/memory load.
|
||||
*/
|
||||
device->mRenderMode = HrtfRender;
|
||||
ALsizei ambi_order{1};
|
||||
ALuint ambi_order{1};
|
||||
if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf-mode"))
|
||||
{
|
||||
const char *mode{modeopt->c_str()};
|
||||
|
||||
Reference in New Issue
Block a user