diff options
-rw-r--r-- | Alc/bformatdec.cpp | 117 | ||||
-rw-r--r-- | Alc/bformatdec.h | 45 | ||||
-rw-r--r-- | Alc/panning.cpp | 79 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 4 |
4 files changed, 113 insertions, 132 deletions
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp index 60e52b1b..8b12149a 100644 --- a/Alc/bformatdec.cpp +++ b/Alc/bformatdec.cpp @@ -17,49 +17,9 @@ #include "almalloc.h" -/* NOTE: These are scale factors as applied to Ambisonics content. Decoder - * coefficients should be divided by these values to get proper N3D scalings. - */ -const ALfloat N3D2N3DScale[MAX_AMBI_COEFFS] = { - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f -}; -const ALfloat SN3D2N3DScale[MAX_AMBI_COEFFS] = { - 1.000000000f, /* ACN 0 (W), sqrt(1) */ - 1.732050808f, /* ACN 1 (Y), sqrt(3) */ - 1.732050808f, /* ACN 2 (Z), sqrt(3) */ - 1.732050808f, /* ACN 3 (X), sqrt(3) */ - 2.236067978f, /* ACN 4 (V), sqrt(5) */ - 2.236067978f, /* ACN 5 (T), sqrt(5) */ - 2.236067978f, /* ACN 6 (R), sqrt(5) */ - 2.236067978f, /* ACN 7 (S), sqrt(5) */ - 2.236067978f, /* ACN 8 (U), sqrt(5) */ - 2.645751311f, /* ACN 9 (Q), sqrt(7) */ - 2.645751311f, /* ACN 10 (O), sqrt(7) */ - 2.645751311f, /* ACN 11 (M), sqrt(7) */ - 2.645751311f, /* ACN 12 (K), sqrt(7) */ - 2.645751311f, /* ACN 13 (L), sqrt(7) */ - 2.645751311f, /* ACN 14 (N), sqrt(7) */ - 2.645751311f, /* ACN 15 (P), sqrt(7) */ -}; -const ALfloat FuMa2N3DScale[MAX_AMBI_COEFFS] = { - 1.414213562f, /* ACN 0 (W), sqrt(2) */ - 1.732050808f, /* ACN 1 (Y), sqrt(3) */ - 1.732050808f, /* ACN 2 (Z), sqrt(3) */ - 1.732050808f, /* ACN 3 (X), sqrt(3) */ - 1.936491673f, /* ACN 4 (V), sqrt(15)/2 */ - 1.936491673f, /* ACN 5 (T), sqrt(15)/2 */ - 2.236067978f, /* ACN 6 (R), sqrt(5) */ - 1.936491673f, /* ACN 7 (S), sqrt(15)/2 */ - 1.936491673f, /* ACN 8 (U), sqrt(15)/2 */ - 2.091650066f, /* ACN 9 (Q), sqrt(35/8) */ - 1.972026594f, /* ACN 10 (O), sqrt(35)/3 */ - 2.231093404f, /* ACN 11 (M), sqrt(224/45) */ - 2.645751311f, /* ACN 12 (K), sqrt(7) */ - 2.231093404f, /* ACN 13 (L), sqrt(224/45) */ - 1.972026594f, /* ACN 14 (N), sqrt(35)/3 */ - 2.091650066f, /* ACN 15 (P), sqrt(35/8) */ -}; +constexpr float AmbiScale::N3D2N3D[MAX_AMBI_COEFFS]; +constexpr float AmbiScale::SN3D2N3D[MAX_AMBI_COEFFS]; +constexpr float AmbiScale::FuMa2N3D[MAX_AMBI_COEFFS]; namespace { @@ -114,10 +74,7 @@ ALsizei GetACNIndex(const BFChannelConfig *chans, ALsizei numchans, ALsizei acn) void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]) { - static constexpr ALsizei map2DTo3D[MAX_AMBI2D_COEFFS] = { - 0, 1, 3, 4, 8, 9, 15 - }; - const ALfloat *coeff_scale = N3D2N3DScale; + static constexpr ALsizei map2DTo3D[MAX_AMBI2D_COEFFS]{ 0, 1, 3, 4, 8, 9, 15 }; mSamples.clear(); mSamplesHF = nullptr; @@ -133,11 +90,6 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, { return mask | (1 << chan); } ); - if(conf->CoeffScale == AmbDecScale::SN3D) - coeff_scale = SN3D2N3DScale; - else if(conf->CoeffScale == AmbDecScale::FuMa) - coeff_scale = FuMa2N3DScale; - mUpSampler[0].XOver.init(400.0f / (float)srate); std::fill(std::begin(mUpSampler[0].Gains), std::end(mUpSampler[0].Gains), 0.0f); std::fill(std::begin(mUpSampler)+1, std::end(mUpSampler), mUpSampler[0]); @@ -170,23 +122,25 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, mUpSampler[3].Gains[LF_BAND] = 0.0f; } + const ALfloat (&coeff_scale)[MAX_AMBI_COEFFS] = + (conf->CoeffScale == AmbDecScale::FuMa) ? AmbiScale::FuMa2N3D : + (conf->CoeffScale == AmbDecScale::SN3D) ? AmbiScale::SN3D2N3D : + /*(conf->CoeffScale == AmbDecScale::N3D) ?*/ AmbiScale::N3D2N3D; + mMatrix = MatrixU{}; if(conf->FreqBands == 1) { mDualBand = AL_FALSE; for(ALsizei i{0};i < conf->NumSpeakers;i++) { - ALsizei chan = chanmap[i]; - ALfloat gain; - ALsizei j, k; - + const ALsizei chan{chanmap[i]}; if(!periphonic) { - for(j = 0,k = 0;j < MAX_AMBI2D_COEFFS;j++) + ALfloat gain{conf->HFOrderGain[0]}; + for(ALsizei j{0},k{0};j < MAX_AMBI2D_COEFFS;j++) { - ALsizei l = map2DTo3D[j]; - if(j == 0) gain = conf->HFOrderGain[0]; - else if(j == 1) gain = conf->HFOrderGain[1]; + const ALsizei l{map2DTo3D[j]}; + if(j == 1) gain = conf->HFOrderGain[1]; else if(j == 3) gain = conf->HFOrderGain[2]; else if(j == 5) gain = conf->HFOrderGain[3]; if((conf->ChanMask&(1<<l))) @@ -195,10 +149,10 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, } else { - for(j = 0,k = 0;j < MAX_AMBI_COEFFS;j++) + ALfloat gain{conf->HFOrderGain[0]}; + for(ALsizei j{0},k{0};j < MAX_AMBI_COEFFS;j++) { - if(j == 0) gain = conf->HFOrderGain[0]; - else if(j == 1) gain = conf->HFOrderGain[1]; + if(j == 1) gain = conf->HFOrderGain[1]; else if(j == 4) gain = conf->HFOrderGain[2]; else if(j == 9) gain = conf->HFOrderGain[3]; if((conf->ChanMask&(1<<j))) @@ -214,30 +168,28 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, mXOver[0].init(conf->XOverFreq / (float)srate); std::fill(std::begin(mXOver)+1, std::end(mXOver), mXOver[0]); - float ratio{std::pow(10.0f, conf->XOverRatio / 40.0f)}; + const float ratio{std::pow(10.0f, conf->XOverRatio / 40.0f)}; for(ALsizei i{0};i < conf->NumSpeakers;i++) { - ALsizei chan = chanmap[i]; - - ALfloat gain{}; + const ALsizei chan{chanmap[i]}; if(!periphonic) { + ALfloat gain{conf->HFOrderGain[0] * ratio}; for(ALsizei j{0},k{0};j < MAX_AMBI2D_COEFFS;j++) { ALsizei l = map2DTo3D[j]; - if(j == 0) gain = conf->HFOrderGain[0] * ratio; - else if(j == 1) gain = conf->HFOrderGain[1] * ratio; + if(j == 1) gain = conf->HFOrderGain[1] * ratio; else if(j == 3) gain = conf->HFOrderGain[2] * ratio; else if(j == 5) gain = conf->HFOrderGain[3] * ratio; if((conf->ChanMask&(1<<l))) mMatrix.Dual[chan][HF_BAND][j] = conf->HFMatrix[i][k++] / coeff_scale[l] * gain; } + gain = conf->HFOrderGain[0] / ratio; for(ALsizei j{0},k{0};j < MAX_AMBI2D_COEFFS;j++) { ALsizei l = map2DTo3D[j]; - if(j == 0) gain = conf->LFOrderGain[0] / ratio; - else if(j == 1) gain = conf->LFOrderGain[1] / ratio; + if(j == 1) gain = conf->LFOrderGain[1] / ratio; else if(j == 3) gain = conf->LFOrderGain[2] / ratio; else if(j == 5) gain = conf->LFOrderGain[3] / ratio; if((conf->ChanMask&(1<<l))) @@ -247,20 +199,20 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, } else { + ALfloat gain{conf->HFOrderGain[0] * ratio}; for(ALsizei j{0},k{0};j < MAX_AMBI_COEFFS;j++) { - if(j == 0) gain = conf->HFOrderGain[0] * ratio; - else if(j == 1) gain = conf->HFOrderGain[1] * ratio; + if(j == 1) gain = conf->HFOrderGain[1] * ratio; else if(j == 4) gain = conf->HFOrderGain[2] * ratio; else if(j == 9) gain = conf->HFOrderGain[3] * ratio; if((conf->ChanMask&(1<<j))) mMatrix.Dual[chan][HF_BAND][j] = conf->HFMatrix[i][k++] / coeff_scale[j] * gain; } + gain = conf->HFOrderGain[0] / ratio; for(ALsizei j{0},k{0};j < MAX_AMBI_COEFFS;j++) { - if(j == 0) gain = conf->LFOrderGain[0] / ratio; - else if(j == 1) gain = conf->LFOrderGain[1] / ratio; + if(j == 1) gain = conf->LFOrderGain[1] / ratio; else if(j == 4) gain = conf->LFOrderGain[2] / ratio; else if(j == 9) gain = conf->LFOrderGain[3] / ratio; if((conf->ChanMask&(1<<j))) @@ -277,14 +229,13 @@ void BFormatDec::process(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALsize ASSUME(OutChannels > 0); ASSUME(SamplesToDo > 0); - ALsizei chan, i; if(mDualBand) { - for(i = 0;i < mNumChannels;i++) + for(ALsizei i{0};i < mNumChannels;i++) mXOver[i].process(mSamplesHF[i].data(), mSamplesLF[i].data(), InSamples[i], SamplesToDo); - for(chan = 0;chan < OutChannels;chan++) + for(ALsizei chan{0};chan < OutChannels;chan++) { if(UNLIKELY(!(mEnabled&(1<<chan)))) continue; @@ -305,7 +256,7 @@ void BFormatDec::process(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALsize } else { - for(chan = 0;chan < OutChannels;chan++) + for(ALsizei chan{0};chan < OutChannels;chan++) { if(UNLIKELY(!(mEnabled&(1<<chan)))) continue; @@ -364,7 +315,7 @@ void AmbiUpsampler::reset(const ALCdevice *device, const ALfloat w_scale, const ALfloat encgains[8][MAX_OUTPUT_CHANNELS]; for(size_t k{0u};k < COUNTOF(Ambi3DPoints);k++) { - ALfloat coeffs[MAX_AMBI_COEFFS] = { 0.0f }; + ALfloat coeffs[MAX_AMBI_COEFFS]; CalcDirectionCoeffs(Ambi3DPoints[k], 0.0f, coeffs); ComputePanGains(&device->Dry, coeffs, 1.0f, encgains[k]); } @@ -378,7 +329,7 @@ void AmbiUpsampler::reset(const ALCdevice *device, const ALfloat w_scale, const { for(ALsizei j{0};j < device->Dry.NumChannels;j++) { - ALdouble gain = 0.0; + ALdouble gain{0.0}; for(size_t k{0u};k < COUNTOF(Ambi3DDecoder);k++) gain += (ALdouble)Ambi3DDecoder[k][i] * encgains[k][j]; mGains[i][j][HF_BAND] = (ALfloat)(gain * Ambi3DDecoderHFScale[i]); @@ -390,10 +341,10 @@ void AmbiUpsampler::reset(const ALCdevice *device, const ALfloat w_scale, const { for(ALsizei i{0};i < 4;i++) { - ALsizei index = GetChannelForACN(device->Dry, i); + const ALsizei index{GetChannelForACN(device->Dry, i)}; if(index != INVALID_UPSAMPLE_INDEX) { - ALfloat scale = device->Dry.Ambi.Map[index].Scale; + const ALfloat scale{device->Dry.Ambi.Map[index].Scale}; mGains[i][index][HF_BAND] = scale * ((i==0) ? w_scale : xyz_scale); mGains[i][index][LF_BAND] = scale; } diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h index f2cdcdfb..d855041d 100644 --- a/Alc/bformatdec.h +++ b/Alc/bformatdec.h @@ -29,9 +29,48 @@ struct AmbDecConf; /* NOTE: These are scale factors as applied to Ambisonics content. Decoder * coefficients should be divided by these values to get proper N3D scalings. */ -extern const ALfloat N3D2N3DScale[MAX_AMBI_COEFFS]; -extern const ALfloat SN3D2N3DScale[MAX_AMBI_COEFFS]; -extern const ALfloat FuMa2N3DScale[MAX_AMBI_COEFFS]; +struct AmbiScale { + static constexpr float N3D2N3D[MAX_AMBI_COEFFS]{ + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f + }; + static constexpr float SN3D2N3D[MAX_AMBI_COEFFS]{ + 1.000000000f, /* ACN 0 (W), sqrt(1) */ + 1.732050808f, /* ACN 1 (Y), sqrt(3) */ + 1.732050808f, /* ACN 2 (Z), sqrt(3) */ + 1.732050808f, /* ACN 3 (X), sqrt(3) */ + 2.236067978f, /* ACN 4 (V), sqrt(5) */ + 2.236067978f, /* ACN 5 (T), sqrt(5) */ + 2.236067978f, /* ACN 6 (R), sqrt(5) */ + 2.236067978f, /* ACN 7 (S), sqrt(5) */ + 2.236067978f, /* ACN 8 (U), sqrt(5) */ + 2.645751311f, /* ACN 9 (Q), sqrt(7) */ + 2.645751311f, /* ACN 10 (O), sqrt(7) */ + 2.645751311f, /* ACN 11 (M), sqrt(7) */ + 2.645751311f, /* ACN 12 (K), sqrt(7) */ + 2.645751311f, /* ACN 13 (L), sqrt(7) */ + 2.645751311f, /* ACN 14 (N), sqrt(7) */ + 2.645751311f, /* ACN 15 (P), sqrt(7) */ + }; + static constexpr float FuMa2N3D[MAX_AMBI_COEFFS]{ + 1.414213562f, /* ACN 0 (W), sqrt(2) */ + 1.732050808f, /* ACN 1 (Y), sqrt(3) */ + 1.732050808f, /* ACN 2 (Z), sqrt(3) */ + 1.732050808f, /* ACN 3 (X), sqrt(3) */ + 1.936491673f, /* ACN 4 (V), sqrt(15)/2 */ + 1.936491673f, /* ACN 5 (T), sqrt(15)/2 */ + 2.236067978f, /* ACN 6 (R), sqrt(5) */ + 1.936491673f, /* ACN 7 (S), sqrt(15)/2 */ + 1.936491673f, /* ACN 8 (U), sqrt(15)/2 */ + 2.091650066f, /* ACN 9 (Q), sqrt(35/8) */ + 1.972026594f, /* ACN 10 (O), sqrt(35)/3 */ + 2.231093404f, /* ACN 11 (M), sqrt(224/45) */ + 2.645751311f, /* ACN 12 (K), sqrt(7) */ + 2.231093404f, /* ACN 13 (L), sqrt(224/45) */ + 1.972026594f, /* ACN 14 (N), sqrt(35)/3 */ + 2.091650066f, /* ACN 15 (P), sqrt(35/8) */ + }; +}; class BFormatDec { diff --git a/Alc/panning.cpp b/Alc/panning.cpp index c08961ed..2d42106b 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -26,6 +26,7 @@ #include <ctype.h> #include <assert.h> +#include <cmath> #include <numeric> #include <algorithm> #include <functional> @@ -398,12 +399,13 @@ void InitPanning(ALCdevice *device) if(device->FmtChans == DevFmtAmbi3D) { - const char *devname = device->DeviceName.c_str(); - const ALsizei *acnmap = (device->mAmbiLayout == AmbiLayout::FuMa) ? FuMa2ACN : ACN2ACN; - const ALfloat *n3dscale = (device->mAmbiScale == AmbiNorm::FuMa) ? FuMa2N3DScale : - (device->mAmbiScale == AmbiNorm::SN3D) ? SN3D2N3DScale : - /*(device->mAmbiScale == AmbiNorm::N3D) ?*/ N3D2N3DScale; - ALfloat nfc_delay = 0.0f; + const char *devname{device->DeviceName.c_str()}; + const ALsizei (&acnmap)[MAX_AMBI_COEFFS] = + (device->mAmbiLayout == AmbiLayout::FuMa) ? FuMa2ACN : ACN2ACN; + const ALfloat (&n3dscale)[MAX_AMBI_COEFFS] = + (device->mAmbiScale == AmbiNorm::FuMa) ? AmbiScale::FuMa2N3D : + (device->mAmbiScale == AmbiNorm::SN3D) ? AmbiScale::SN3D2N3D : + /*(device->mAmbiScale == AmbiNorm::N3D) ?*/ AmbiScale::N3D2N3D; count = (device->mAmbiOrder == 3) ? 16 : (device->mAmbiOrder == 2) ? 9 : @@ -425,8 +427,6 @@ void InitPanning(ALCdevice *device) } else { - ALfloat w_scale=1.0f, xyz_scale=1.0f; - /* FOA output is always ACN+N3D for higher-order ambisonic output. * The upsampler expects this and will convert it for output. */ @@ -439,6 +439,7 @@ void InitPanning(ALCdevice *device) device->FOAOut.CoeffCount = 0; device->FOAOut.NumChannels = 4; + ALfloat w_scale{1.0f}, xyz_scale{1.0f}; if(device->mAmbiOrder >= 3) { w_scale = W_SCALE_3H3P; @@ -452,11 +453,10 @@ void InitPanning(ALCdevice *device) device->AmbiUp->reset(device, w_scale, xyz_scale); } + ALfloat nfc_delay{0.0f}; if(ConfigValueFloat(devname, "decoder", "nfc-ref-delay", &nfc_delay) && nfc_delay > 0.0f) { - static const ALsizei chans_per_order[MAX_AMBI_ORDER+1] = { - 1, 3, 5, 7 - }; + static constexpr ALsizei chans_per_order[MAX_AMBI_ORDER+1]{ 1, 3, 5, 7 }; nfc_delay = clampf(nfc_delay, 0.001f, 1000.0f); InitNearFieldCtrl(device, nfc_delay * SPEEDOFSOUNDMETRESPERSEC, device->mAmbiOrder, chans_per_order); @@ -464,16 +464,14 @@ void InitPanning(ALCdevice *device) } else { - ALfloat w_scale, xyz_scale; - SetChannelMap(device->RealOut.ChannelName, device->Dry.Ambi.Coeffs, chanmap, count, &device->Dry.NumChannels); device->Dry.CoeffCount = coeffcount; - w_scale = (device->Dry.CoeffCount > 9) ? W_SCALE_3H0P : - (device->Dry.CoeffCount > 4) ? W_SCALE_2H0P : 1.0f; - xyz_scale = (device->Dry.CoeffCount > 9) ? XYZ_SCALE_3H0P : - (device->Dry.CoeffCount > 4) ? XYZ_SCALE_2H0P : 1.0f; + const ALfloat w_scale{(device->Dry.CoeffCount > 9) ? W_SCALE_3H0P : + (device->Dry.CoeffCount > 4) ? W_SCALE_2H0P : 1.0f}; + const ALfloat xyz_scale{(device->Dry.CoeffCount > 9) ? XYZ_SCALE_3H0P : + (device->Dry.CoeffCount > 4) ? XYZ_SCALE_2H0P : 1.0f}; device->FOAOut.Ambi = AmbiConfig{}; for(i = 0;i < device->Dry.NumChannels;i++) @@ -490,16 +488,11 @@ void InitPanning(ALCdevice *device) void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&speakermap)[MAX_OUTPUT_CHANNELS]) { - ChannelMap chanmap[MAX_OUTPUT_CHANNELS]; - const ALfloat *coeff_scale = N3D2N3DScale; - ALfloat w_scale = 1.0f; - ALfloat xyz_scale = 1.0f; - ALsizei i, j; - if(conf->FreqBands != 1) ERR("Basic renderer uses the high-frequency matrix as single-band (xover_freq = %.0fhz)\n", conf->XOverFreq); + ALfloat w_scale{1.0f}, xyz_scale{1.0f}; if((conf->ChanMask&AMBI_PERIPHONIC_MASK)) { if(conf->ChanMask > 0x1ff) @@ -527,25 +520,23 @@ void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei } } - if(conf->CoeffScale == AmbDecScale::SN3D) - coeff_scale = SN3D2N3DScale; - else if(conf->CoeffScale == AmbDecScale::FuMa) - coeff_scale = FuMa2N3DScale; - - for(i = 0;i < conf->NumSpeakers;i++) + const ALfloat (&coeff_scale)[MAX_AMBI_COEFFS] = + (conf->CoeffScale == AmbDecScale::FuMa) ? AmbiScale::FuMa2N3D : + (conf->CoeffScale == AmbDecScale::SN3D) ? AmbiScale::SN3D2N3D : + /*(conf->CoeffScale == AmbDecScale::N3D) ?*/ AmbiScale::N3D2N3D; + ChannelMap chanmap[MAX_OUTPUT_CHANNELS]{}; + for(ALsizei i{0};i < conf->NumSpeakers;i++) { - ALsizei chan = speakermap[i]; - ALfloat gain; - ALsizei k = 0; - - for(j = 0;j < MAX_AMBI_COEFFS;j++) - chanmap[i].Config[j] = 0.0f; + const ALsizei chan{speakermap[i]}; chanmap[i].ChanName = device->RealOut.ChannelName[chan]; - for(j = 0;j < MAX_AMBI_COEFFS;j++) + std::fill(std::begin(chanmap[i].Config), std::end(chanmap[i].Config), 0.0f); + + ALsizei k{0}; + ALfloat gain{conf->HFOrderGain[0]}; + for(ALsizei j{0};j < MAX_AMBI_COEFFS;j++) { - if(j == 0) gain = conf->HFOrderGain[0]; - else if(j == 1) gain = conf->HFOrderGain[1]; + if(j == 1) gain = conf->HFOrderGain[1]; else if(j == 4) gain = conf->HFOrderGain[2]; else if(j == 9) gain = conf->HFOrderGain[3]; if((conf->ChanMask&(1<<j))) @@ -559,10 +550,10 @@ void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (conf->ChanMask > 0xf) ? 9 : 4; device->FOAOut.Ambi = AmbiConfig{}; - for(i = 0;i < device->Dry.NumChannels;i++) + for(ALsizei i{0};i < device->Dry.NumChannels;i++) { device->FOAOut.Ambi.Coeffs[i][0] = device->Dry.Ambi.Coeffs[i][0] * w_scale; - for(j = 1;j < 4;j++) + for(ALsizei j{1};j < 4;j++) device->FOAOut.Ambi.Coeffs[i][j] = device->Dry.Ambi.Coeffs[i][j] * xyz_scale; } device->FOAOut.CoeffCount = 4; @@ -577,8 +568,8 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp { static constexpr ALsizei chans_per_order2d[MAX_AMBI_ORDER+1] = { 1, 2, 2, 2 }; static constexpr ALsizei chans_per_order3d[MAX_AMBI_ORDER+1] = { 1, 3, 5, 7 }; - ALsizei count; + ALsizei count; 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 }; @@ -782,7 +773,7 @@ void InitUhjPanning(ALCdevice *device) std::transform(std::begin(FuMa2ACN), std::begin(FuMa2ACN)+count, std::begin(device->Dry.Ambi.Map), [](const ALsizei &acn) noexcept -> BFChannelConfig - { return BFChannelConfig{1.0f/FuMa2N3DScale[acn], acn}; } + { return BFChannelConfig{1.0f/AmbiScale::FuMa2N3D[acn], acn}; } ); device->Dry.CoeffCount = 0; device->Dry.NumChannels = count; @@ -847,9 +838,9 @@ void CalcAmbiCoeffs(const ALfloat y, const ALfloat z, const ALfloat x, const ALf * ZH4 = 0.125f * (ca+1.0f)*(7.0f*ca*ca - 3.0f)*ca; * ZH5 = 0.0625f * (ca+1.0f)*(21.0f*ca*ca*ca*ca - 14.0f*ca*ca + 1.0f); */ - ALfloat ca = cosf(spread * 0.5f); + ALfloat ca = std::cos(spread * 0.5f); /* Increase the source volume by up to +3dB for a full spread. */ - ALfloat scale = sqrtf(1.0f + spread/F_TAU); + ALfloat scale = std::sqrt(1.0f + spread/F_TAU); ALfloat ZH0_norm = scale; ALfloat ZH1_norm = 0.5f * (ca+1.f) * scale; diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index e011675c..1b5c274d 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -94,8 +94,8 @@ typedef const ALfloat* (*ResamplerFunc)(const InterpState *state, void BsincPrepare(const ALuint increment, BsincState *state, const struct BSincTable *table); -extern const struct BSincTable bsinc12; -extern const struct BSincTable bsinc24; +extern const BSincTable bsinc12; +extern const BSincTable bsinc24; enum { |