Add macros for the ambisonic order masks

This commit is contained in:
Chris Robinson
2018-12-14 23:26:44 -08:00
parent 0882728dec
commit 2d13e0af29
3 changed files with 41 additions and 26 deletions
+12 -8
View File
@@ -103,25 +103,29 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate,
const bool periphonic{(conf->ChanMask&AMBI_PERIPHONIC_MASK) != 0};
if(periphonic)
{
mUpSampler[0].Gains[HF_BAND] = (conf->ChanMask > 0x1ff) ? W_SCALE_3H3P :
(conf->ChanMask > 0xf) ? W_SCALE_2H2P : 1.0f;
mUpSampler[0].Gains[HF_BAND] =
(conf->ChanMask > AMBI_2ORDER_MASK) ? W_SCALE_3H3P :
(conf->ChanMask > AMBI_1ORDER_MASK) ? W_SCALE_2H2P : 1.0f;
mUpSampler[0].Gains[LF_BAND] = 1.0f;
for(ALsizei i{1};i < 4;i++)
{
mUpSampler[i].Gains[HF_BAND] = (conf->ChanMask > 0x1ff) ? XYZ_SCALE_3H3P :
(conf->ChanMask > 0xf) ? XYZ_SCALE_2H2P : 1.0f;
mUpSampler[i].Gains[HF_BAND] =
(conf->ChanMask > AMBI_2ORDER_MASK) ? XYZ_SCALE_3H3P :
(conf->ChanMask > AMBI_1ORDER_MASK) ? XYZ_SCALE_2H2P : 1.0f;
mUpSampler[i].Gains[LF_BAND] = 1.0f;
}
}
else
{
mUpSampler[0].Gains[HF_BAND] = (conf->ChanMask > 0x1ff) ? W_SCALE_3H0P :
(conf->ChanMask > 0xf) ? W_SCALE_2H0P : 1.0f;
mUpSampler[0].Gains[HF_BAND] =
(conf->ChanMask > AMBI_2ORDER_MASK) ? W_SCALE_3H0P :
(conf->ChanMask > AMBI_1ORDER_MASK) ? W_SCALE_2H0P : 1.0f;
mUpSampler[0].Gains[LF_BAND] = 1.0f;
for(ALsizei i{1};i < 3;i++)
{
mUpSampler[i].Gains[HF_BAND] = (conf->ChanMask > 0x1ff) ? XYZ_SCALE_3H0P :
(conf->ChanMask > 0xf) ? XYZ_SCALE_2H0P : 1.0f;
mUpSampler[i].Gains[HF_BAND] =
(conf->ChanMask > AMBI_2ORDER_MASK) ? XYZ_SCALE_3H0P :
(conf->ChanMask > AMBI_1ORDER_MASK) ? XYZ_SCALE_2H0P : 1.0f;
mUpSampler[i].Gains[LF_BAND] = 1.0f;
}
mUpSampler[3].Gains[HF_BAND] = 0.0f;
+18 -15
View File
@@ -512,12 +512,12 @@ void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei
ALfloat w_scale{1.0f}, xyz_scale{1.0f};
if((conf->ChanMask&AMBI_PERIPHONIC_MASK))
{
if(conf->ChanMask > 0x1ff)
if(conf->ChanMask > AMBI_2ORDER_MASK)
{
w_scale = W_SCALE_3H3P;
xyz_scale = XYZ_SCALE_3H3P;
}
else if(conf->ChanMask > 0xf)
else if(conf->ChanMask > AMBI_1ORDER_MASK)
{
w_scale = W_SCALE_2H2P;
xyz_scale = XYZ_SCALE_2H2P;
@@ -525,12 +525,12 @@ void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei
}
else
{
if(conf->ChanMask > 0x1ff)
if(conf->ChanMask > AMBI_2ORDER_MASK)
{
w_scale = W_SCALE_3H0P;
xyz_scale = XYZ_SCALE_3H0P;
}
else if(conf->ChanMask > 0xf)
else if(conf->ChanMask > AMBI_1ORDER_MASK)
{
w_scale = W_SCALE_2H0P;
xyz_scale = XYZ_SCALE_2H0P;
@@ -560,8 +560,8 @@ void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei
SetChannelMap(device->RealOut.ChannelName, device->Dry.Ambi.Coeffs, chanmap,
conf->NumSpeakers, &device->Dry.NumChannels);
device->Dry.CoeffCount = (conf->ChanMask > 0x1ff) ? 16 :
(conf->ChanMask > 0xf) ? 9 : 4;
device->Dry.CoeffCount = (conf->ChanMask > AMBI_2ORDER_MASK) ? 16 :
(conf->ChanMask > AMBI_1ORDER_MASK) ? 9 : 4;
device->FOAOut.Ambi = AmbiConfig{};
for(ALsizei i{0};i < device->Dry.NumChannels;i++)
@@ -587,8 +587,8 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp
if((conf->ChanMask&AMBI_PERIPHONIC_MASK))
{
static constexpr int map[MAX_AMBI_COEFFS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
count = (conf->ChanMask > 0x1ff) ? 16 :
(conf->ChanMask > 0xf) ? 9 : 4;
count = (conf->ChanMask > AMBI_2ORDER_MASK) ? 16 :
(conf->ChanMask > AMBI_1ORDER_MASK) ? 9 : 4;
std::transform(std::begin(map), std::begin(map)+count, std::begin(device->Dry.Ambi.Map),
[](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; }
);
@@ -596,8 +596,8 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp
else
{
static constexpr int map[MAX_AMBI2D_COEFFS] = { 0, 1, 3, 4, 8, 9, 15 };
count = (conf->ChanMask > 0x1ff) ? 7 :
(conf->ChanMask > 0xf) ? 5 : 3;
count = (conf->ChanMask > AMBI_2ORDER_MASK) ? 7 :
(conf->ChanMask > AMBI_1ORDER_MASK) ? 5 : 3;
std::transform(std::begin(map), std::begin(map)+count, std::begin(device->Dry.Ambi.Map),
[](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; }
);
@@ -607,12 +607,13 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp
TRACE("Enabling %s-band %s-order%s ambisonic decoder\n",
(conf->FreqBands == 1) ? "single" : "dual",
(conf->ChanMask > 0xf) ? (conf->ChanMask > 0x1ff) ? "third" : "second" : "first",
(conf->ChanMask > AMBI_2ORDER_MASK) ? "third" :
(conf->ChanMask > AMBI_1ORDER_MASK) ? "second" : "first",
(conf->ChanMask&AMBI_PERIPHONIC_MASK) ? " periphonic" : ""
);
device->AmbiDecoder->reset(conf, count, device->Frequency, speakermap);
if(conf->ChanMask <= 0xf)
if(conf->ChanMask <= AMBI_1ORDER_MASK)
{
device->FOAOut.Ambi = device->Dry.Ambi;
device->FOAOut.CoeffCount = device->Dry.CoeffCount;
@@ -652,7 +653,8 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp
float{0.0f}, accum_spkr_dist) / (ALfloat)conf->NumSpeakers
};
InitNearFieldCtrl(device, avg_dist,
(conf->ChanMask > 0x1ff) ? 3 : (conf->ChanMask > 0xf) ? 2 : 1,
(conf->ChanMask > AMBI_2ORDER_MASK) ? 3 :
(conf->ChanMask > AMBI_1ORDER_MASK) ? 2 : 1,
(conf->ChanMask&AMBI_PERIPHONIC_MASK) ? chans_per_order3d : chans_per_order2d
);
@@ -969,8 +971,9 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf
ERR("Failed to load layout file %s\n", fname);
else
{
if(conf.ChanMask > 0xffff)
ERR("Unsupported channel mask 0x%04x (max 0xffff)\n", conf.ChanMask);
if(conf.ChanMask > AMBI_3ORDER_MASK)
ERR("Unsupported channel mask 0x%04x (max 0x%x)\n", conf.ChanMask,
AMBI_3ORDER_MASK);
else
{
if(MakeSpeakerMap(device, &conf, speakermap))
+11 -3
View File
@@ -550,11 +550,19 @@ enum RenderMode {
#define MAX_AMBI_ORDER 3
#define MAX_AMBI_COEFFS ((MAX_AMBI_ORDER+1) * (MAX_AMBI_ORDER+1))
/* A bitmask of ambisonic channels for 0 to 4th order. This only specifies up
* to 4th order, which is the highest order a 32-bit mask value can specify (a
* 64-bit mask could handle up to 7th order).
*/
#define AMBI_0ORDER_MASK 0x00000001
#define AMBI_1ORDER_MASK 0x0000000f
#define AMBI_2ORDER_MASK 0x000001ff
#define AMBI_3ORDER_MASK 0x0000ffff
#define AMBI_4ORDER_MASK 0x01ffffff
/* A bitmask of ambisonic channels with height information. If none of these
* channels are used/needed, there's no height (e.g. with most surround sound
* speaker setups). This only specifies up to 4th order, which is the highest
* order a 32-bit mask value can specify (a 64-bit mask could handle up to 7th
* order). This is ACN ordering, with bit 0 being ACN 0, etc.
* speaker setups). This is ACN ordering, with bit 0 being ACN 0, etc.
*/
#define AMBI_PERIPHONIC_MASK (0xfe7ce4)