aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects/reverb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alc/effects/reverb.cpp')
-rw-r--r--alc/effects/reverb.cpp320
1 files changed, 160 insertions, 160 deletions
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp
index ae092b55..c97818f2 100644
--- a/alc/effects/reverb.cpp
+++ b/alc/effects/reverb.cpp
@@ -42,7 +42,7 @@
/* This is a user config option for modifying the overall output of the reverb
* effect.
*/
-ALfloat ReverbBoost = 1.0f;
+float ReverbBoost = 1.0f;
namespace {
@@ -82,7 +82,7 @@ constexpr float MODULATION_DEPTH_COEFF{0.05f};
* tetrahedron, but it's close enough. Should the model be extended to 8-lines
* in the future, true opposites can be used.
*/
-alignas(16) constexpr ALfloat B2A[NUM_LINES][MAX_AMBI_CHANNELS]{
+alignas(16) constexpr float B2A[NUM_LINES][MAX_AMBI_CHANNELS]{
{ 0.288675134595f, 0.288675134595f, 0.288675134595f, 0.288675134595f },
{ 0.288675134595f, -0.288675134595f, -0.288675134595f, 0.288675134595f },
{ 0.288675134595f, 0.288675134595f, -0.288675134595f, -0.288675134595f },
@@ -90,7 +90,7 @@ alignas(16) constexpr ALfloat B2A[NUM_LINES][MAX_AMBI_CHANNELS]{
};
/* Converts A-Format to B-Format. */
-alignas(16) constexpr ALfloat A2B[NUM_LINES][NUM_LINES]{
+alignas(16) constexpr float A2B[NUM_LINES][NUM_LINES]{
{ 0.866025403785f, 0.866025403785f, 0.866025403785f, 0.866025403785f },
{ 0.866025403785f, -0.866025403785f, 0.866025403785f, -0.866025403785f },
{ 0.866025403785f, -0.866025403785f, -0.866025403785f, 0.866025403785f },
@@ -113,7 +113,7 @@ alignas(16) constexpr ALfloat A2B[NUM_LINES][NUM_LINES]{
* The density scale below will result in a max line multiplier of 50, for an
* effective size range of 5m to 50m.
*/
-constexpr ALfloat DENSITY_SCALE{125000.0f};
+constexpr float DENSITY_SCALE{125000.0f};
/* All delay line lengths are specified in seconds.
*
@@ -159,7 +159,7 @@ constexpr ALfloat DENSITY_SCALE{125000.0f};
*
* Assuming an average of 1m, we get the following taps:
*/
-constexpr std::array<ALfloat,NUM_LINES> EARLY_TAP_LENGTHS{{
+constexpr std::array<float,NUM_LINES> EARLY_TAP_LENGTHS{{
0.0000000e+0f, 2.0213520e-4f, 4.2531060e-4f, 6.7171600e-4f
}};
@@ -169,7 +169,7 @@ constexpr std::array<ALfloat,NUM_LINES> EARLY_TAP_LENGTHS{{
*
* Where a is the approximate maximum all-pass cycle limit (20).
*/
-constexpr std::array<ALfloat,NUM_LINES> EARLY_ALLPASS_LENGTHS{{
+constexpr std::array<float,NUM_LINES> EARLY_ALLPASS_LENGTHS{{
9.7096800e-5f, 1.0720356e-4f, 1.1836234e-4f, 1.3068260e-4f
}};
@@ -195,7 +195,7 @@ constexpr std::array<ALfloat,NUM_LINES> EARLY_ALLPASS_LENGTHS{{
*
* Using an average dimension of 1m, we get:
*/
-constexpr std::array<ALfloat,NUM_LINES> EARLY_LINE_LENGTHS{{
+constexpr std::array<float,NUM_LINES> EARLY_LINE_LENGTHS{{
5.9850400e-4f, 1.0913150e-3f, 1.5376658e-3f, 1.9419362e-3f
}};
@@ -203,7 +203,7 @@ constexpr std::array<ALfloat,NUM_LINES> EARLY_LINE_LENGTHS{{
*
* A_i = (5 / 3) L_i / r_1
*/
-constexpr std::array<ALfloat,NUM_LINES> LATE_ALLPASS_LENGTHS{{
+constexpr std::array<float,NUM_LINES> LATE_ALLPASS_LENGTHS{{
1.6182800e-4f, 2.0389060e-4f, 2.8159360e-4f, 3.2365600e-4f
}};
@@ -222,7 +222,7 @@ constexpr std::array<ALfloat,NUM_LINES> LATE_ALLPASS_LENGTHS{{
*
* For our 1m average room, we get:
*/
-constexpr std::array<ALfloat,NUM_LINES> LATE_LINE_LENGTHS{{
+constexpr std::array<float,NUM_LINES> LATE_LINE_LENGTHS{{
1.9419362e-3f, 2.4466860e-3f, 3.3791220e-3f, 3.8838720e-3f
}};
@@ -246,7 +246,7 @@ struct DelayLineI {
{ Line = sampleBuffer + LineOffset; }
/* Calculate the length of a delay line and store its mask and offset. */
- ALuint calcLineLength(const ALfloat length, const uintptr_t offset, const ALfloat frequency,
+ ALuint calcLineLength(const float length, const uintptr_t offset, const float frequency,
const ALuint extra)
{
/* All line lengths are powers of 2, calculated from their lengths in
@@ -263,7 +263,7 @@ struct DelayLineI {
return samples;
}
- void write(size_t offset, const size_t c, const ALfloat *RESTRICT in, const size_t count) const noexcept
+ void write(size_t offset, const size_t c, const float *RESTRICT in, const size_t count) const noexcept
{
ASSUME(count > 0);
for(size_t i{0u};i < count;)
@@ -279,25 +279,25 @@ struct DelayLineI {
struct VecAllpass {
DelayLineI Delay;
- ALfloat Coeff{0.0f};
- size_t Offset[NUM_LINES][2]{};
+ float Coeff{0.0f};
+ size_t Offset[NUM_LINES][2]{};
void processFaded(const al::span<ReverbUpdateLine,NUM_LINES> samples, size_t offset,
- const ALfloat xCoeff, const ALfloat yCoeff, ALfloat fadeCount, const ALfloat fadeStep,
+ const float xCoeff, const float yCoeff, float fadeCount, const float fadeStep,
const size_t todo);
void processUnfaded(const al::span<ReverbUpdateLine,NUM_LINES> samples, size_t offset,
- const ALfloat xCoeff, const ALfloat yCoeff, const size_t todo);
+ const float xCoeff, const float yCoeff, const size_t todo);
};
struct T60Filter {
/* Two filters are used to adjust the signal. One to control the low
* frequencies, and one to control the high frequencies.
*/
- ALfloat MidGain[2]{0.0f, 0.0f};
+ float MidGain[2]{0.0f, 0.0f};
BiquadFilter HFFilter, LFFilter;
- void calcCoeffs(const ALfloat length, const ALfloat lfDecayTime, const ALfloat mfDecayTime,
- const ALfloat hfDecayTime, const ALfloat lf0norm, const ALfloat hf0norm);
+ void calcCoeffs(const float length, const float lfDecayTime, const float mfDecayTime,
+ const float hfDecayTime, const float lf0norm, const float hf0norm);
/* Applies the two T60 damping filter sections. */
void process(const al::span<float> samples)
@@ -317,15 +317,15 @@ struct EarlyReflections {
* reflections.
*/
DelayLineI Delay;
- size_t Offset[NUM_LINES][2]{};
- ALfloat Coeff[NUM_LINES][2]{};
+ size_t Offset[NUM_LINES][2]{};
+ float Coeff[NUM_LINES][2]{};
/* The gain for each output channel based on 3D panning. */
- ALfloat CurrentGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
- ALfloat PanGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
+ float CurrentGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
+ float PanGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
- void updateLines(const ALfloat density, const ALfloat diffusion, const ALfloat decayTime,
- const ALfloat frequency);
+ void updateLines(const float density, const float diffusion, const float decayTime,
+ const float frequency);
};
@@ -354,7 +354,7 @@ struct LateReverb {
/* Attenuation to compensate for the modal density and decay rate of the
* late lines.
*/
- ALfloat DensityGain[2]{0.0f, 0.0f};
+ float DensityGain[2]{0.0f, 0.0f};
/* T60 decay filters are used to simulate absorption. */
T60Filter T60[NUM_LINES];
@@ -365,12 +365,12 @@ struct LateReverb {
VecAllpass VecAp;
/* The gain for each output channel based on 3D panning. */
- ALfloat CurrentGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
- ALfloat PanGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
+ float CurrentGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
+ float PanGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
- void updateLines(const ALfloat density, const ALfloat diffusion, const ALfloat lfDecayTime,
- const ALfloat mfDecayTime, const ALfloat hfDecayTime, const ALfloat lf0norm,
- const ALfloat hf0norm, const ALfloat frequency);
+ void updateLines(const float density, const float diffusion, const float lfDecayTime,
+ const float mfDecayTime, const float hfDecayTime, const float lf0norm,
+ const float hf0norm, const float frequency);
};
struct ReverbState final : public EffectState {
@@ -404,16 +404,16 @@ struct ReverbState final : public EffectState {
DelayLineI mDelay;
/* Tap points for early reflection delay. */
- size_t mEarlyDelayTap[NUM_LINES][2]{};
- ALfloat mEarlyDelayCoeff[NUM_LINES][2]{};
+ size_t mEarlyDelayTap[NUM_LINES][2]{};
+ float mEarlyDelayCoeff[NUM_LINES][2]{};
/* Tap points for late reverb feed and delay. */
size_t mLateFeedTap{};
size_t mLateDelayTap[NUM_LINES][2]{};
/* Coefficients for the all-pass and line scattering matrices. */
- ALfloat mMixX{0.0f};
- ALfloat mMixY{0.0f};
+ float mMixX{0.0f};
+ float mMixY{0.0f};
EarlyReflections mEarly;
@@ -439,7 +439,7 @@ struct ReverbState final : public EffectState {
const size_t counter, const size_t offset, const size_t todo);
MixOutT mMixOut{&ReverbState::MixOutPlain};
- std::array<ALfloat,MAX_AMBI_ORDER+1> mOrderScales{};
+ std::array<float,MAX_AMBI_ORDER+1> mOrderScales{};
std::array<std::array<BandSplitter,NUM_LINES>,2> mAmbiSplitter;
@@ -483,7 +483,7 @@ struct ReverbState final : public EffectState {
/* Apply scaling to the B-Format's HF response to "upsample" it to
* higher-order output.
*/
- const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
+ const float hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
mAmbiSplitter[0][c].applyHfScale(tmpspan, hfscale);
MixSamples(tmpspan, samplesOut, mEarly.CurrentGain[c], mEarly.PanGain[c], counter,
@@ -495,7 +495,7 @@ struct ReverbState final : public EffectState {
MixRowSamples(tmpspan, {A2B[c], NUM_LINES}, mLateSamples[0].data(),
mLateSamples[0].size());
- const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
+ const float hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
mAmbiSplitter[1][c].applyHfScale(tmpspan, hfscale);
MixSamples(tmpspan, samplesOut, mLate.CurrentGain[c], mLate.PanGain[c], counter,
@@ -503,20 +503,20 @@ struct ReverbState final : public EffectState {
}
}
- bool allocLines(const ALfloat frequency);
+ bool allocLines(const float frequency);
- void updateDelayLine(const ALfloat earlyDelay, const ALfloat lateDelay, const ALfloat density,
- const ALfloat decayTime, const ALfloat frequency);
- void update3DPanning(const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan,
- const ALfloat earlyGain, const ALfloat lateGain, const EffectTarget &target);
+ void updateDelayLine(const float earlyDelay, const float lateDelay, const float density,
+ const float decayTime, const float frequency);
+ void update3DPanning(const float *ReflectionsPan, const float *LateReverbPan,
+ const float earlyGain, const float lateGain, const EffectTarget &target);
void earlyUnfaded(const size_t offset, const size_t todo);
- void earlyFaded(const size_t offset, const size_t todo, const ALfloat fade,
- const ALfloat fadeStep);
+ void earlyFaded(const size_t offset, const size_t todo, const float fade,
+ const float fadeStep);
void lateUnfaded(const size_t offset, const size_t todo);
- void lateFaded(const size_t offset, const size_t todo, const ALfloat fade,
- const ALfloat fadeStep);
+ void lateFaded(const size_t offset, const size_t todo, const float fade,
+ const float fadeStep);
bool deviceUpdate(const ALCdevice *device) override;
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
@@ -529,14 +529,14 @@ struct ReverbState final : public EffectState {
* Device Update *
**************************************/
-inline ALfloat CalcDelayLengthMult(ALfloat density)
+inline float CalcDelayLengthMult(float density)
{ return maxf(5.0f, std::cbrt(density*DENSITY_SCALE)); }
/* Calculates the delay line metrics and allocates the shared sample buffer
* for all lines given the sample rate (frequency). If an allocation failure
* occurs, it returns AL_FALSE.
*/
-bool ReverbState::allocLines(const ALfloat frequency)
+bool ReverbState::allocLines(const float frequency)
{
/* All delay line lengths are calculated to accomodate the full range of
* lengths given their respective paramters.
@@ -546,14 +546,14 @@ bool ReverbState::allocLines(const ALfloat frequency)
/* Multiplier for the maximum density value, i.e. density=1, which is
* actually the least density...
*/
- ALfloat multiplier{CalcDelayLengthMult(AL_EAXREVERB_MAX_DENSITY)};
+ float multiplier{CalcDelayLengthMult(AL_EAXREVERB_MAX_DENSITY)};
/* The main delay length includes the maximum early reflection delay, the
* largest early tap width, the maximum late reverb delay, and the
* largest late tap width. Finally, it must also be extended by the
* update size (BUFFERSIZE) for block processing.
*/
- ALfloat length{AL_EAXREVERB_MAX_REFLECTIONS_DELAY + EARLY_TAP_LENGTHS.back()*multiplier +
+ float length{AL_EAXREVERB_MAX_REFLECTIONS_DELAY + EARLY_TAP_LENGTHS.back()*multiplier +
AL_EAXREVERB_MAX_LATE_REVERB_DELAY +
(LATE_LINE_LENGTHS.back() - LATE_LINE_LENGTHS.front())/float{NUM_LINES}*multiplier};
totalSamples += mDelay.calcLineLength(length, totalSamples, frequency, BUFFERSIZE);
@@ -601,13 +601,13 @@ bool ReverbState::allocLines(const ALfloat frequency)
bool ReverbState::deviceUpdate(const ALCdevice *device)
{
- const auto frequency = static_cast<ALfloat>(device->Frequency);
+ const auto frequency = static_cast<float>(device->Frequency);
/* Allocate the delay lines. */
if(!allocLines(frequency))
return false;
- const ALfloat multiplier{CalcDelayLengthMult(AL_EAXREVERB_MAX_DENSITY)};
+ const float multiplier{CalcDelayLengthMult(AL_EAXREVERB_MAX_DENSITY)};
/* The late feed taps are set a fixed position past the latest delay tap. */
mLateFeedTap = float2uint(
@@ -679,19 +679,19 @@ bool ReverbState::deviceUpdate(const ALCdevice *device)
/* Calculate a decay coefficient given the length of each cycle and the time
* until the decay reaches -60 dB.
*/
-inline ALfloat CalcDecayCoeff(const ALfloat length, const ALfloat decayTime)
+inline float CalcDecayCoeff(const float length, const float decayTime)
{ return std::pow(REVERB_DECAY_GAIN, length/decayTime); }
/* Calculate a decay length from a coefficient and the time until the decay
* reaches -60 dB.
*/
-inline ALfloat CalcDecayLength(const ALfloat coeff, const ALfloat decayTime)
+inline float CalcDecayLength(const float coeff, const float decayTime)
{ return std::log10(coeff) * decayTime / std::log10(REVERB_DECAY_GAIN); }
/* Calculate an attenuation to be applied to the input of any echo models to
* compensate for modal density and decay time.
*/
-inline ALfloat CalcDensityGain(const ALfloat a)
+inline float CalcDensityGain(const float a)
{
/* The energy of a signal can be obtained by finding the area under the
* squared signal. This takes the form of Sum(x_n^2), where x is the
@@ -710,11 +710,11 @@ inline ALfloat CalcDensityGain(const ALfloat a)
}
/* Calculate the scattering matrix coefficients given a diffusion factor. */
-inline ALvoid CalcMatrixCoeffs(const ALfloat diffusion, ALfloat *x, ALfloat *y)
+inline ALvoid CalcMatrixCoeffs(const float diffusion, float *x, float *y)
{
/* The matrix is of order 4, so n is sqrt(4 - 1). */
- ALfloat n{std::sqrt(3.0f)};
- ALfloat t{diffusion * std::atan(n)};
+ float n{std::sqrt(3.0f)};
+ float t{diffusion * std::atan(n)};
/* Calculate the first mixing matrix coefficient. */
*x = std::cos(t);
@@ -725,16 +725,16 @@ inline ALvoid CalcMatrixCoeffs(const ALfloat diffusion, ALfloat *x, ALfloat *y)
/* Calculate the limited HF ratio for use with the late reverb low-pass
* filters.
*/
-ALfloat CalcLimitedHfRatio(const ALfloat hfRatio, const ALfloat airAbsorptionGainHF,
- const ALfloat decayTime)
+float CalcLimitedHfRatio(const float hfRatio, const float airAbsorptionGainHF,
+ const float decayTime)
{
/* Find the attenuation due to air absorption in dB (converting delay
* time to meters using the speed of sound). Then reversing the decay
* equation, solve for HF ratio. The delay length is cancelled out of
* the equation, so it can be calculated once for all lines.
*/
- ALfloat limitRatio{1.0f /
- (CalcDecayLength(airAbsorptionGainHF, decayTime) * SPEEDOFSOUNDMETRESPERSEC)};
+ float limitRatio{1.0f / CalcDecayLength(airAbsorptionGainHF, decayTime) /
+ SPEEDOFSOUNDMETRESPERSEC};
/* Using the limit calculated above, apply the upper bound to the HF ratio.
*/
@@ -746,9 +746,9 @@ ALfloat CalcLimitedHfRatio(const ALfloat hfRatio, const ALfloat airAbsorptionGai
* of specified length, using a combination of two shelf filter sections given
* decay times for each band split at two reference frequencies.
*/
-void T60Filter::calcCoeffs(const ALfloat length, const ALfloat lfDecayTime,
- const ALfloat mfDecayTime, const ALfloat hfDecayTime, const ALfloat lf0norm,
- const ALfloat hf0norm)
+void T60Filter::calcCoeffs(const float length, const float lfDecayTime,
+ const float mfDecayTime, const float hfDecayTime, const float lf0norm,
+ const float hf0norm)
{
const float mfGain{CalcDecayCoeff(length, mfDecayTime)};
const float lfGain{CalcDecayCoeff(length, lfDecayTime) / mfGain};
@@ -760,10 +760,10 @@ void T60Filter::calcCoeffs(const ALfloat length, const ALfloat lfDecayTime,
}
/* Update the early reflection line lengths and gain coefficients. */
-void EarlyReflections::updateLines(const ALfloat density, const ALfloat diffusion,
- const ALfloat decayTime, const ALfloat frequency)
+void EarlyReflections::updateLines(const float density, const float diffusion,
+ const float decayTime, const float frequency)
{
- const ALfloat multiplier{CalcDelayLengthMult(density)};
+ const float multiplier{CalcDelayLengthMult(density)};
/* Calculate the all-pass feed-back/forward coefficient. */
VecAp.Coeff = std::sqrt(0.5f) * std::pow(diffusion, 2.0f);
@@ -771,7 +771,7 @@ void EarlyReflections::updateLines(const ALfloat density, const ALfloat diffusio
for(size_t i{0u};i < NUM_LINES;i++)
{
/* Calculate the length (in seconds) of each all-pass line. */
- ALfloat length{EARLY_ALLPASS_LENGTHS[i] * multiplier};
+ float length{EARLY_ALLPASS_LENGTHS[i] * multiplier};
/* Calculate the delay offset for each all-pass line. */
VecAp.Offset[i][1] = float2uint(length * frequency);
@@ -821,16 +821,16 @@ void Modulation::updateModulator(float modTime, float modDepth, float frequency)
}
/* Update the late reverb line lengths and T60 coefficients. */
-void LateReverb::updateLines(const ALfloat density, const ALfloat diffusion,
- const ALfloat lfDecayTime, const ALfloat mfDecayTime, const ALfloat hfDecayTime,
- const ALfloat lf0norm, const ALfloat hf0norm, const ALfloat frequency)
+void LateReverb::updateLines(const float density, const float diffusion,
+ const float lfDecayTime, const float mfDecayTime, const float hfDecayTime,
+ const float lf0norm, const float hf0norm, const float frequency)
{
/* Scaling factor to convert the normalized reference frequencies from
* representing 0...freq to 0...max_reference.
*/
- const ALfloat norm_weight_factor{frequency / AL_EAXREVERB_MAX_HFREFERENCE};
+ const float norm_weight_factor{frequency / AL_EAXREVERB_MAX_HFREFERENCE};
- const ALfloat late_allpass_avg{
+ const float late_allpass_avg{
std::accumulate(LATE_ALLPASS_LENGTHS.begin(), LATE_ALLPASS_LENGTHS.end(), 0.0f) /
float{NUM_LINES}};
@@ -842,15 +842,15 @@ void LateReverb::updateLines(const ALfloat density, const ALfloat diffusion,
* The average length of the delay lines is used to calculate the
* attenuation coefficient.
*/
- const ALfloat multiplier{CalcDelayLengthMult(density)};
- ALfloat length{std::accumulate(LATE_LINE_LENGTHS.begin(), LATE_LINE_LENGTHS.end(), 0.0f) /
+ const float multiplier{CalcDelayLengthMult(density)};
+ float length{std::accumulate(LATE_LINE_LENGTHS.begin(), LATE_LINE_LENGTHS.end(), 0.0f) /
float{NUM_LINES} * multiplier};
length += late_allpass_avg * multiplier;
/* The density gain calculation uses an average decay time weighted by
* approximate bandwidth. This attempts to compensate for losses of energy
* that reduce decay time due to scattering into highly attenuated bands.
*/
- const ALfloat decayTimeWeighted{
+ const float decayTimeWeighted{
(lf0norm*norm_weight_factor)*lfDecayTime +
(hf0norm*norm_weight_factor - lf0norm*norm_weight_factor)*mfDecayTime +
(1.0f - hf0norm*norm_weight_factor)*hfDecayTime};
@@ -888,10 +888,10 @@ void LateReverb::updateLines(const ALfloat density, const ALfloat diffusion,
/* Update the offsets for the main effect delay line. */
-void ReverbState::updateDelayLine(const ALfloat earlyDelay, const ALfloat lateDelay,
- const ALfloat density, const ALfloat decayTime, const ALfloat frequency)
+void ReverbState::updateDelayLine(const float earlyDelay, const float lateDelay,
+ const float density, const float decayTime, const float frequency)
{
- const ALfloat multiplier{CalcDelayLengthMult(density)};
+ const float multiplier{CalcDelayLengthMult(density)};
/* Early reflection taps are decorrelated by means of an average room
* reflection approximation described above the definition of the taps.
@@ -905,7 +905,7 @@ void ReverbState::updateDelayLine(const ALfloat earlyDelay, const ALfloat lateDe
*/
for(size_t i{0u};i < NUM_LINES;i++)
{
- ALfloat length{earlyDelay + EARLY_TAP_LENGTHS[i]*multiplier};
+ float length{earlyDelay + EARLY_TAP_LENGTHS[i]*multiplier};
mEarlyDelayTap[i][1] = float2uint(length * frequency);
length = EARLY_TAP_LENGTHS[i]*multiplier;
@@ -922,7 +922,7 @@ void ReverbState::updateDelayLine(const ALfloat earlyDelay, const ALfloat lateDe
* focal strength. This function results in a B-Format transformation matrix
* that spatially focuses the signal in the desired direction.
*/
-alu::Matrix GetTransformFromVector(const ALfloat *vec)
+alu::Matrix GetTransformFromVector(const float *vec)
{
constexpr float sqrt_3{1.73205080756887719318f};
@@ -933,8 +933,8 @@ alu::Matrix GetTransformFromVector(const ALfloat *vec)
* rest of OpenAL which use right-handed. This is fixed by negating Z,
* which cancels out with the B-Format Z negation.
*/
- ALfloat norm[3];
- ALfloat mag{std::sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])};
+ float norm[3];
+ float mag{std::sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])};
if(mag > 1.0f)
{
norm[0] = vec[0] / mag * -sqrt_3;
@@ -962,8 +962,8 @@ alu::Matrix GetTransformFromVector(const ALfloat *vec)
}
/* Update the early and late 3D panning gains. */
-void ReverbState::update3DPanning(const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan,
- const ALfloat earlyGain, const ALfloat lateGain, const EffectTarget &target)
+void ReverbState::update3DPanning(const float *ReflectionsPan, const float *LateReverbPan,
+ const float earlyGain, const float lateGain, const EffectTarget &target)
{
/* Create matrices that transform a B-Format signal according to the
* panning vectors.
@@ -974,13 +974,13 @@ void ReverbState::update3DPanning(const ALfloat *ReflectionsPan, const ALfloat *
mOutTarget = target.Main->Buffer;
for(size_t i{0u};i < NUM_LINES;i++)
{
- const ALfloat coeffs[MAX_AMBI_CHANNELS]{earlymat[0][i], earlymat[1][i], earlymat[2][i],
+ const float coeffs[MAX_AMBI_CHANNELS]{earlymat[0][i], earlymat[1][i], earlymat[2][i],
earlymat[3][i]};
ComputePanGains(target.Main, coeffs, earlyGain, mEarly.PanGain[i]);
}
for(size_t i{0u};i < NUM_LINES;i++)
{
- const ALfloat coeffs[MAX_AMBI_CHANNELS]{latemat[0][i], latemat[1][i], latemat[2][i],
+ const float coeffs[MAX_AMBI_CHANNELS]{latemat[0][i], latemat[1][i], latemat[2][i],
latemat[3][i]};
ComputePanGains(target.Main, coeffs, lateGain, mLate.PanGain[i]);
}
@@ -989,7 +989,7 @@ void ReverbState::update3DPanning(const ALfloat *ReflectionsPan, const ALfloat *
void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, const EffectProps *props, const EffectTarget target)
{
const ALCdevice *Device{Context->mDevice.get()};
- const auto frequency = static_cast<ALfloat>(Device->Frequency);
+ const auto frequency = static_cast<float>(Device->Frequency);
/* Calculate the master filters */
float hf0norm{minf(props->Reverb.HFReference/frequency, 0.49f)};
@@ -1016,15 +1016,15 @@ void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
/* If the HF limit parameter is flagged, calculate an appropriate limit
* based on the air absorption parameter.
*/
- ALfloat hfRatio{props->Reverb.DecayHFRatio};
+ float hfRatio{props->Reverb.DecayHFRatio};
if(props->Reverb.DecayHFLimit && props->Reverb.AirAbsorptionGainHF < 1.0f)
hfRatio = CalcLimitedHfRatio(hfRatio, props->Reverb.AirAbsorptionGainHF,
props->Reverb.DecayTime);
/* Calculate the LF/HF decay times. */
- const ALfloat lfDecayTime{clampf(props->Reverb.DecayTime * props->Reverb.DecayLFRatio,
+ const float lfDecayTime{clampf(props->Reverb.DecayTime * props->Reverb.DecayLFRatio,
AL_EAXREVERB_MIN_DECAY_TIME, AL_EAXREVERB_MAX_DECAY_TIME)};
- const ALfloat hfDecayTime{clampf(props->Reverb.DecayTime * hfRatio,
+ const float hfDecayTime{clampf(props->Reverb.DecayTime * hfRatio,
AL_EAXREVERB_MIN_DECAY_TIME, AL_EAXREVERB_MAX_DECAY_TIME)};
/* Update the modulator rate and depth. */
@@ -1036,7 +1036,7 @@ void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
props->Reverb.DecayTime, hfDecayTime, lf0norm, hf0norm, frequency);
/* Update early and late 3D panning. */
- const ALfloat gain{props->Reverb.Gain * Slot->Params.Gain * ReverbBoost};
+ const float gain{props->Reverb.Gain * Slot->Params.Gain * ReverbBoost};
update3DPanning(props->Reverb.ReflectionsPan, props->Reverb.LateReverbPan,
props->Reverb.ReflectionsGain*gain, props->Reverb.LateReverbGain*gain, target);
@@ -1121,7 +1121,7 @@ void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
* whose combination of signs are being iterated.
*/
inline auto VectorPartialScatter(const std::array<float,NUM_LINES> &RESTRICT in,
- const ALfloat xCoeff, const ALfloat yCoeff) -> std::array<float,NUM_LINES>
+ const float xCoeff, const float yCoeff) -> std::array<float,NUM_LINES>
{
std::array<float,NUM_LINES> out;
out[0] = xCoeff*in[0] + yCoeff*( in[1] + -in[2] + in[3]);
@@ -1132,8 +1132,8 @@ inline auto VectorPartialScatter(const std::array<float,NUM_LINES> &RESTRICT in,
}
/* Utilizes the above, but reverses the input channels. */
-void VectorScatterRevDelayIn(const DelayLineI delay, size_t offset, const ALfloat xCoeff,
- const ALfloat yCoeff, const al::span<const ReverbUpdateLine,NUM_LINES> in, const size_t count)
+void VectorScatterRevDelayIn(const DelayLineI delay, size_t offset, const float xCoeff,
+ const float yCoeff, const al::span<const ReverbUpdateLine,NUM_LINES> in, const size_t count)
{
ASSUME(count > 0);
@@ -1163,10 +1163,10 @@ void VectorScatterRevDelayIn(const DelayLineI delay, size_t offset, const ALfloa
* line processing and non-transitional processing.
*/
void VecAllpass::processUnfaded(const al::span<ReverbUpdateLine,NUM_LINES> samples, size_t offset,
- const ALfloat xCoeff, const ALfloat yCoeff, const size_t todo)
+ const float xCoeff, const float yCoeff, const size_t todo)
{
const DelayLineI delay{Delay};
- const ALfloat feedCoeff{Coeff};
+ const float feedCoeff{Coeff};
ASSUME(todo > 0);
@@ -1188,8 +1188,8 @@ void VecAllpass::processUnfaded(const al::span<ReverbUpdateLine,NUM_LINES> sampl
std::array<float,NUM_LINES> f;
for(size_t j{0u};j < NUM_LINES;j++)
{
- const ALfloat input{samples[j][i]};
- const ALfloat out{delay.Line[vap_offset[j]++][j] - feedCoeff*input};
+ const float input{samples[j][i]};
+ const float out{delay.Line[vap_offset[j]++][j] - feedCoeff*input};
f[j] = input + feedCoeff*out;
samples[j][i] = out;
@@ -1201,11 +1201,11 @@ void VecAllpass::processUnfaded(const al::span<ReverbUpdateLine,NUM_LINES> sampl
}
}
void VecAllpass::processFaded(const al::span<ReverbUpdateLine,NUM_LINES> samples, size_t offset,
- const ALfloat xCoeff, const ALfloat yCoeff, ALfloat fadeCount, const ALfloat fadeStep,
+ const float xCoeff, const float yCoeff, float fadeCount, const float fadeStep,
const size_t todo)
{
const DelayLineI delay{Delay};
- const ALfloat feedCoeff{Coeff};
+ const float feedCoeff{Coeff};
ASSUME(todo > 0);
@@ -1240,8 +1240,8 @@ void VecAllpass::processFaded(const al::span<ReverbUpdateLine,NUM_LINES> samples
for(size_t j{0u};j < NUM_LINES;j++)
{
- const ALfloat input{samples[j][i]};
- const ALfloat out{f[j] - feedCoeff*input};
+ const float input{samples[j][i]};
+ const float out{f[j] - feedCoeff*input};
f[j] = input + feedCoeff*out;
samples[j][i] = out;
@@ -1276,8 +1276,8 @@ void ReverbState::earlyUnfaded(const size_t offset, const size_t todo)
{
const DelayLineI early_delay{mEarly.Delay};
const DelayLineI main_delay{mDelay};
- const ALfloat mixX{mMixX};
- const ALfloat mixY{mMixY};
+ const float mixX{mMixX};
+ const float mixY{mMixY};
ASSUME(todo > 0);
@@ -1287,7 +1287,7 @@ void ReverbState::earlyUnfaded(const size_t offset, const size_t todo)
for(size_t j{0u};j < NUM_LINES;j++)
{
size_t early_delay_tap{offset - mEarlyDelayTap[j][0]};
- const ALfloat coeff{mEarlyDelayCoeff[j][0]};
+ const float coeff{mEarlyDelayCoeff[j][0]};
for(size_t i{0u};i < todo;)
{
early_delay_tap &= main_delay.Mask;
@@ -1309,8 +1309,8 @@ void ReverbState::earlyUnfaded(const size_t offset, const size_t todo)
for(size_t j{0u};j < NUM_LINES;j++)
{
size_t feedb_tap{offset - mEarly.Offset[j][0]};
- const ALfloat feedb_coeff{mEarly.Coeff[j][0]};
- float *out = mEarlySamples[j].data();
+ const float feedb_coeff{mEarly.Coeff[j][0]};
+ float *out{mEarlySamples[j].data()};
for(size_t i{0u};i < todo;)
{
@@ -1332,13 +1332,13 @@ void ReverbState::earlyUnfaded(const size_t offset, const size_t todo)
const size_t late_feed_tap{offset - mLateFeedTap};
VectorScatterRevDelayIn(main_delay, late_feed_tap, mixX, mixY, mEarlySamples, todo);
}
-void ReverbState::earlyFaded(const size_t offset, const size_t todo, const ALfloat fade,
- const ALfloat fadeStep)
+void ReverbState::earlyFaded(const size_t offset, const size_t todo, const float fade,
+ const float fadeStep)
{
const DelayLineI early_delay{mEarly.Delay};
const DelayLineI main_delay{mDelay};
- const ALfloat mixX{mMixX};
- const ALfloat mixY{mMixY};
+ const float mixX{mMixX};
+ const float mixY{mMixY};
ASSUME(todo > 0);
@@ -1346,10 +1346,10 @@ void ReverbState::earlyFaded(const size_t offset, const size_t todo, const ALflo
{
size_t early_delay_tap0{offset - mEarlyDelayTap[j][0]};
size_t early_delay_tap1{offset - mEarlyDelayTap[j][1]};
- const ALfloat oldCoeff{mEarlyDelayCoeff[j][0]};
- const ALfloat oldCoeffStep{-oldCoeff * fadeStep};
- const ALfloat newCoeffStep{mEarlyDelayCoeff[j][1] * fadeStep};
- ALfloat fadeCount{fade};
+ const float oldCoeff{mEarlyDelayCoeff[j][0]};
+ const float oldCoeffStep{-oldCoeff * fadeStep};
+ const float newCoeffStep{mEarlyDelayCoeff[j][1] * fadeStep};
+ float fadeCount{fade};
for(size_t i{0u};i < todo;)
{
@@ -1358,8 +1358,8 @@ void ReverbState::earlyFaded(const size_t offset, const size_t todo, const ALflo
size_t td{minz(main_delay.Mask+1 - maxz(early_delay_tap0, early_delay_tap1), todo-i)};
do {
fadeCount += 1.0f;
- const ALfloat fade0{oldCoeff + oldCoeffStep*fadeCount};
- const ALfloat fade1{newCoeffStep*fadeCount};
+ const float fade0{oldCoeff + oldCoeffStep*fadeCount};
+ const float fade1{newCoeffStep*fadeCount};
mTempSamples[j][i++] =
main_delay.Line[early_delay_tap0++][j]*fade0 +
main_delay.Line[early_delay_tap1++][j]*fade1;
@@ -1373,11 +1373,11 @@ void ReverbState::earlyFaded(const size_t offset, const size_t todo, const ALflo
{
size_t feedb_tap0{offset - mEarly.Offset[j][0]};
size_t feedb_tap1{offset - mEarly.Offset[j][1]};
- const ALfloat feedb_oldCoeff{mEarly.Coeff[j][0]};
- const ALfloat feedb_oldCoeffStep{-feedb_oldCoeff * fadeStep};
- const ALfloat feedb_newCoeffStep{mEarly.Coeff[j][1] * fadeStep};
- float *out = mEarlySamples[j].data();
- ALfloat fadeCount{fade};
+ const float feedb_oldCoeff{mEarly.Coeff[j][0]};
+ const float feedb_oldCoeffStep{-feedb_oldCoeff * fadeStep};
+ const float feedb_newCoeffStep{mEarly.Coeff[j][1] * fadeStep};
+ float *out{mEarlySamples[j].data()};
+ float fadeCount{fade};
for(size_t i{0u};i < todo;)
{
@@ -1387,8 +1387,8 @@ void ReverbState::earlyFaded(const size_t offset, const size_t todo, const ALflo
do {
fadeCount += 1.0f;
- const ALfloat fade0{feedb_oldCoeff + feedb_oldCoeffStep*fadeCount};
- const ALfloat fade1{feedb_newCoeffStep*fadeCount};
+ const float fade0{feedb_oldCoeff + feedb_oldCoeffStep*fadeCount};
+ const float fade1{feedb_newCoeffStep*fadeCount};
out[i] = mTempSamples[j][i] +
early_delay.Line[feedb_tap0++][j]*fade0 +
early_delay.Line[feedb_tap1++][j]*fade1;
@@ -1455,8 +1455,8 @@ void ReverbState::lateUnfaded(const size_t offset, const size_t todo)
{
const DelayLineI late_delay{mLate.Delay};
const DelayLineI main_delay{mDelay};
- const ALfloat mixX{mMixX};
- const ALfloat mixY{mMixY};
+ const float mixX{mMixX};
+ const float mixY{mMixY};
ASSUME(todo > 0);
@@ -1470,8 +1470,8 @@ void ReverbState::lateUnfaded(const size_t offset, const size_t todo)
{
size_t late_delay_tap{offset - mLateDelayTap[j][0]};
size_t late_feedb_tap{offset - mLate.Offset[j][0]};
- const ALfloat midGain{mLate.T60[j].MidGain[0]};
- const ALfloat densityGain{mLate.DensityGain[0] * midGain};
+ const float midGain{mLate.T60[j].MidGain[0]};
+ const float densityGain{mLate.DensityGain[0] * midGain};
for(size_t i{0u};i < todo;)
{
@@ -1514,13 +1514,13 @@ void ReverbState::lateUnfaded(const size_t offset, const size_t todo)
/* Finally, scatter and bounce the results to refeed the feedback buffer. */
VectorScatterRevDelayIn(late_delay, offset, mixX, mixY, mTempSamples, todo);
}
-void ReverbState::lateFaded(const size_t offset, const size_t todo, const ALfloat fade,
- const ALfloat fadeStep)
+void ReverbState::lateFaded(const size_t offset, const size_t todo, const float fade,
+ const float fadeStep)
{
const DelayLineI late_delay{mLate.Delay};
const DelayLineI main_delay{mDelay};
- const ALfloat mixX{mMixX};
- const ALfloat mixY{mMixY};
+ const float mixX{mMixX};
+ const float mixY{mMixY};
ASSUME(todo > 0);
@@ -1528,19 +1528,19 @@ void ReverbState::lateFaded(const size_t offset, const size_t todo, const ALfloa
for(size_t j{0u};j < NUM_LINES;j++)
{
- const ALfloat oldMidGain{mLate.T60[j].MidGain[0]};
- const ALfloat midGain{mLate.T60[j].MidGain[1]};
- const ALfloat oldMidStep{-oldMidGain * fadeStep};
- const ALfloat midStep{midGain * fadeStep};
- const ALfloat oldDensityGain{mLate.DensityGain[0] * oldMidGain};
- const ALfloat densityGain{mLate.DensityGain[1] * midGain};
- const ALfloat oldDensityStep{-oldDensityGain * fadeStep};
- const ALfloat densityStep{densityGain * fadeStep};
+ const float oldMidGain{mLate.T60[j].MidGain[0]};
+ const float midGain{mLate.T60[j].MidGain[1]};
+ const float oldMidStep{-oldMidGain * fadeStep};
+ const float midStep{midGain * fadeStep};
+ const float oldDensityGain{mLate.DensityGain[0] * oldMidGain};
+ const float densityGain{mLate.DensityGain[1] * midGain};
+ const float oldDensityStep{-oldDensityGain * fadeStep};
+ const float densityStep{densityGain * fadeStep};
size_t late_delay_tap0{offset - mLateDelayTap[j][0]};
size_t late_delay_tap1{offset - mLateDelayTap[j][1]};
size_t late_feedb_tap0{offset - mLate.Offset[j][0]};
size_t late_feedb_tap1{offset - mLate.Offset[j][1]};
- ALfloat fadeCount{fade};
+ float fadeCount{fade};
for(size_t i{0u};i < todo;)
{
@@ -1636,7 +1636,7 @@ void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBu
ASSUME(todo > 0);
/* Generate cross-faded early reflections and late reverb. */
- auto fadeCount = static_cast<ALfloat>(base);
+ auto fadeCount = static_cast<float>(base);
earlyFaded(offset, todo, fadeCount, fadeStep);
lateFaded(offset, todo, fadeCount, fadeStep);
@@ -1668,7 +1668,7 @@ void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBu
}
-void EAXReverb_setParami(EffectProps *props, ALCcontext *context, ALenum param, ALint val)
+void EAXReverb_setParami(EffectProps *props, ALCcontext *context, ALenum param, int val)
{
switch(param)
{
@@ -1683,9 +1683,9 @@ void EAXReverb_setParami(EffectProps *props, ALCcontext *context, ALenum param,
param);
}
}
-void EAXReverb_setParamiv(EffectProps *props, ALCcontext *context, ALenum param, const ALint *vals)
+void EAXReverb_setParamiv(EffectProps *props, ALCcontext *context, ALenum param, const int *vals)
{ EAXReverb_setParami(props, context, param, vals[0]); }
-void EAXReverb_setParamf(EffectProps *props, ALCcontext *context, ALenum param, ALfloat val)
+void EAXReverb_setParamf(EffectProps *props, ALCcontext *context, ALenum param, float val)
{
switch(param)
{
@@ -1813,7 +1813,7 @@ void EAXReverb_setParamf(EffectProps *props, ALCcontext *context, ALenum param,
context->setError(AL_INVALID_ENUM, "Invalid EAX reverb float property 0x%04x", param);
}
}
-void EAXReverb_setParamfv(EffectProps *props, ALCcontext *context, ALenum param, const ALfloat *vals)
+void EAXReverb_setParamfv(EffectProps *props, ALCcontext *context, ALenum param, const float *vals)
{
switch(param)
{
@@ -1838,7 +1838,7 @@ void EAXReverb_setParamfv(EffectProps *props, ALCcontext *context, ALenum param,
}
}
-void EAXReverb_getParami(const EffectProps *props, ALCcontext *context, ALenum param, ALint *val)
+void EAXReverb_getParami(const EffectProps *props, ALCcontext *context, ALenum param, int *val)
{
switch(param)
{
@@ -1851,9 +1851,9 @@ void EAXReverb_getParami(const EffectProps *props, ALCcontext *context, ALenum p
param);
}
}
-void EAXReverb_getParamiv(const EffectProps *props, ALCcontext *context, ALenum param, ALint *vals)
+void EAXReverb_getParamiv(const EffectProps *props, ALCcontext *context, ALenum param, int *vals)
{ EAXReverb_getParami(props, context, param, vals); }
-void EAXReverb_getParamf(const EffectProps *props, ALCcontext *context, ALenum param, ALfloat *val)
+void EAXReverb_getParamf(const EffectProps *props, ALCcontext *context, ALenum param, float *val)
{
switch(param)
{
@@ -1941,7 +1941,7 @@ void EAXReverb_getParamf(const EffectProps *props, ALCcontext *context, ALenum p
context->setError(AL_INVALID_ENUM, "Invalid EAX reverb float property 0x%04x", param);
}
}
-void EAXReverb_getParamfv(const EffectProps *props, ALCcontext *context, ALenum param, ALfloat *vals)
+void EAXReverb_getParamfv(const EffectProps *props, ALCcontext *context, ALenum param, float *vals)
{
switch(param)
{
@@ -2005,7 +2005,7 @@ EffectProps ReverbStateFactory::getDefaultProps() const noexcept
}
-void StdReverb_setParami(EffectProps *props, ALCcontext *context, ALenum param, ALint val)
+void StdReverb_setParami(EffectProps *props, ALCcontext *context, ALenum param, int val)
{
switch(param)
{
@@ -2019,9 +2019,9 @@ void StdReverb_setParami(EffectProps *props, ALCcontext *context, ALenum param,
context->setError(AL_INVALID_ENUM, "Invalid reverb integer property 0x%04x", param);
}
}
-void StdReverb_setParamiv(EffectProps *props, ALCcontext *context, ALenum param, const ALint *vals)
+void StdReverb_setParamiv(EffectProps *props, ALCcontext *context, ALenum param, const int *vals)
{ StdReverb_setParami(props, context, param, vals[0]); }
-void StdReverb_setParamf(EffectProps *props, ALCcontext *context, ALenum param, ALfloat val)
+void StdReverb_setParamf(EffectProps *props, ALCcontext *context, ALenum param, float val)
{
switch(param)
{
@@ -2101,10 +2101,10 @@ void StdReverb_setParamf(EffectProps *props, ALCcontext *context, ALenum param,
context->setError(AL_INVALID_ENUM, "Invalid reverb float property 0x%04x", param);
}
}
-void StdReverb_setParamfv(EffectProps *props, ALCcontext *context, ALenum param, const ALfloat *vals)
+void StdReverb_setParamfv(EffectProps *props, ALCcontext *context, ALenum param, const float *vals)
{ StdReverb_setParamf(props, context, param, vals[0]); }
-void StdReverb_getParami(const EffectProps *props, ALCcontext *context, ALenum param, ALint *val)
+void StdReverb_getParami(const EffectProps *props, ALCcontext *context, ALenum param, int *val)
{
switch(param)
{
@@ -2116,9 +2116,9 @@ void StdReverb_getParami(const EffectProps *props, ALCcontext *context, ALenum p
context->setError(AL_INVALID_ENUM, "Invalid reverb integer property 0x%04x", param);
}
}
-void StdReverb_getParamiv(const EffectProps *props, ALCcontext *context, ALenum param, ALint *vals)
+void StdReverb_getParamiv(const EffectProps *props, ALCcontext *context, ALenum param, int *vals)
{ StdReverb_getParami(props, context, param, vals); }
-void StdReverb_getParamf(const EffectProps *props, ALCcontext *context, ALenum param, ALfloat *val)
+void StdReverb_getParamf(const EffectProps *props, ALCcontext *context, ALenum param, float *val)
{
switch(param)
{
@@ -2174,7 +2174,7 @@ void StdReverb_getParamf(const EffectProps *props, ALCcontext *context, ALenum p
context->setError(AL_INVALID_ENUM, "Invalid reverb float property 0x%04x", param);
}
}
-void StdReverb_getParamfv(const EffectProps *props, ALCcontext *context, ALenum param, ALfloat *vals)
+void StdReverb_getParamfv(const EffectProps *props, ALCcontext *context, ALenum param, float *vals)
{ StdReverb_getParamf(props, context, param, vals); }
DEFINE_ALEFFECT_VTABLE(StdReverb);