aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-04 20:55:10 -0800
committerChris Robinson <[email protected]>2018-12-04 20:55:10 -0800
commit36a8b615c883ccc90705b97402e2e2046058720a (patch)
tree88e5fbe4968a730018b002b3fe93c12c74352d33 /Alc
parent2a30ae3807134be37cf79139e7e7943df5b1bf64 (diff)
Avoid using AL types with the filters
Diffstat (limited to 'Alc')
-rw-r--r--Alc/filters/defs.h18
-rw-r--r--Alc/filters/filter.cpp34
-rw-r--r--Alc/filters/splitter.cpp18
-rw-r--r--Alc/filters/splitter.h26
4 files changed, 48 insertions, 48 deletions
diff --git a/Alc/filters/defs.h b/Alc/filters/defs.h
index 19514b62..fb8c9312 100644
--- a/Alc/filters/defs.h
+++ b/Alc/filters/defs.h
@@ -35,11 +35,11 @@ enum class BiquadType {
struct BiquadFilter {
/* Last two delayed components for direct form II. */
- ALfloat z1{0.0f}, z2{0.0f};
+ float z1{0.0f}, z2{0.0f};
/* Transfer function coefficients "b" (numerator) */
- ALfloat b0{1.0f}, b1{0.0f}, b2{0.0f};
+ float b0{1.0f}, b1{0.0f}, b2{0.0f};
/* Transfer function coefficients "a" (denominator; a0 is pre-applied). */
- ALfloat a1{0.0f}, a2{0.0f};
+ float a1{0.0f}, a2{0.0f};
};
/* Currently only a C-based filter process method is implemented. */
#define BiquadFilter_process BiquadFilter_processC
@@ -50,7 +50,7 @@ struct BiquadFilter {
* \param gain 0 < gain
* \param slope 0 < slope <= 1
*/
-inline ALfloat calc_rcpQ_from_slope(ALfloat gain, ALfloat slope)
+inline float calc_rcpQ_from_slope(float gain, float slope)
{
return std::sqrt((gain + 1.0f/gain)*(1.0f/slope - 1.0f) + 2.0f);
}
@@ -60,9 +60,9 @@ inline ALfloat calc_rcpQ_from_slope(ALfloat gain, ALfloat slope)
* \param f0norm 0 < f0norm < 0.5.
* \param bandwidth 0 < bandwidth
*/
-inline ALfloat calc_rcpQ_from_bandwidth(ALfloat f0norm, ALfloat bandwidth)
+inline ALfloat calc_rcpQ_from_bandwidth(float f0norm, float bandwidth)
{
- ALfloat w0 = F_TAU * f0norm;
+ float w0 = F_TAU * f0norm;
return 2.0f*std::sinh(std::log(2.0f)/2.0f*bandwidth*w0/std::sin(w0));
}
@@ -87,7 +87,7 @@ inline void BiquadFilter_clear(BiquadFilter *filter)
* band. Can be generated from calc_rcpQ_from_slope or
* calc_rcpQ_from_bandwidth depending on the available data.
*/
-void BiquadFilter_setParams(BiquadFilter *filter, BiquadType type, ALfloat gain, ALfloat f0norm, ALfloat rcpQ);
+void BiquadFilter_setParams(BiquadFilter *filter, BiquadType type, float gain, float f0norm, float rcpQ);
inline void BiquadFilter_copyParams(BiquadFilter *RESTRICT dst, const BiquadFilter *RESTRICT src)
{
@@ -98,9 +98,9 @@ inline void BiquadFilter_copyParams(BiquadFilter *RESTRICT dst, const BiquadFilt
dst->a2 = src->a2;
}
-void BiquadFilter_processC(BiquadFilter *filter, ALfloat *RESTRICT dst, const ALfloat *RESTRICT src, ALsizei numsamples);
+void BiquadFilter_processC(BiquadFilter *filter, float *RESTRICT dst, const float *RESTRICT src, int numsamples);
-inline void BiquadFilter_passthru(BiquadFilter *filter, ALsizei numsamples)
+inline void BiquadFilter_passthru(BiquadFilter *filter, int numsamples)
{
if(LIKELY(numsamples >= 2))
{
diff --git a/Alc/filters/filter.cpp b/Alc/filters/filter.cpp
index 5dc5d9b4..980841c0 100644
--- a/Alc/filters/filter.cpp
+++ b/Alc/filters/filter.cpp
@@ -10,12 +10,12 @@
#include "defs.h"
-void BiquadFilter_setParams(BiquadFilter *filter, BiquadType type, ALfloat gain, ALfloat f0norm, ALfloat rcpQ)
+void BiquadFilter_setParams(BiquadFilter *filter, BiquadType type, float gain, float f0norm, float rcpQ)
{
- ALfloat alpha, sqrtgain_alpha_2;
- ALfloat w0, sin_w0, cos_w0;
- ALfloat a[3] = { 1.0f, 0.0f, 0.0f };
- ALfloat b[3] = { 1.0f, 0.0f, 0.0f };
+ float alpha, sqrtgain_alpha_2;
+ float w0, sin_w0, cos_w0;
+ float a[3] = { 1.0f, 0.0f, 0.0f };
+ float b[3] = { 1.0f, 0.0f, 0.0f };
// Limit gain to -100dB
assert(gain > 0.00001f);
@@ -90,18 +90,18 @@ void BiquadFilter_setParams(BiquadFilter *filter, BiquadType type, ALfloat gain,
}
-void BiquadFilter_processC(BiquadFilter *filter, ALfloat *RESTRICT dst, const ALfloat *RESTRICT src, ALsizei numsamples)
+void BiquadFilter_processC(BiquadFilter *filter, float *RESTRICT dst, const float *RESTRICT src, int numsamples)
{
- const ALfloat b0 = filter->b0;
- const ALfloat b1 = filter->b1;
- const ALfloat b2 = filter->b2;
- const ALfloat a1 = filter->a1;
- const ALfloat a2 = filter->a2;
- ALfloat z1 = filter->z1;
- ALfloat z2 = filter->z2;
-
ASSUME(numsamples > 0);
+ const float b0{filter->b0};
+ const float b1{filter->b1};
+ const float b2{filter->b2};
+ const float a1{filter->a1};
+ const float a2{filter->a2};
+ float z1{filter->z1};
+ float z2{filter->z2};
+
/* Processing loop is Transposed Direct Form II. This requires less storage
* compared to Direct Form I (only two delay components, instead of a four-
* sample history; the last two inputs and outputs), and works better for
@@ -110,14 +110,14 @@ void BiquadFilter_processC(BiquadFilter *filter, ALfloat *RESTRICT dst, const AL
*
* See: http://www.earlevel.com/main/2003/02/28/biquads/
*/
- auto proc_sample = [b0,b1,b2,a1,a2,&z1,&z2](ALfloat input) noexcept -> ALfloat
+ auto proc_sample = [b0,b1,b2,a1,a2,&z1,&z2](float input) noexcept -> float
{
- ALfloat output = input*b0 + z1;
+ float output = input*b0 + z1;
z1 = input*b1 - output*a1 + z2;
z2 = input*b2 - output*a2;
return output;
};
- std::transform<const ALfloat*RESTRICT>(src, src+numsamples, dst, proc_sample);
+ std::transform<const float*RESTRICT>(src, src+numsamples, dst, proc_sample);
filter->z1 = z1;
filter->z2 = z2;
diff --git a/Alc/filters/splitter.cpp b/Alc/filters/splitter.cpp
index 570f5e2c..d13c8a77 100644
--- a/Alc/filters/splitter.cpp
+++ b/Alc/filters/splitter.cpp
@@ -9,10 +9,10 @@
#include "math_defs.h"
-void bandsplit_init(BandSplitter *splitter, ALfloat f0norm)
+void bandsplit_init(BandSplitter *splitter, float f0norm)
{
- ALfloat w = f0norm * F_TAU;
- ALfloat cw = std::cos(w);
+ float w = f0norm * F_TAU;
+ float cw = std::cos(w);
if(cw > FLT_EPSILON)
splitter->coeff = (std::sin(w) - 1.0f) / cw;
else
@@ -30,8 +30,8 @@ void bandsplit_clear(BandSplitter *splitter)
splitter->hp_z1 = 0.0f;
}
-void bandsplit_process(BandSplitter *splitter, ALfloat *RESTRICT hpout, ALfloat *RESTRICT lpout,
- const ALfloat *input, ALsizei count)
+void bandsplit_process(BandSplitter *splitter, float *RESTRICT hpout, float *RESTRICT lpout,
+ const ALfloat *input, int count)
{
ASSUME(count > 0);
@@ -67,10 +67,10 @@ void bandsplit_process(BandSplitter *splitter, ALfloat *RESTRICT hpout, ALfloat
}
-void splitterap_init(SplitterAllpass *splitter, ALfloat f0norm)
+void splitterap_init(SplitterAllpass *splitter, float f0norm)
{
- ALfloat w = f0norm * F_TAU;
- ALfloat cw = std::cos(w);
+ float w = f0norm * F_TAU;
+ float cw = std::cos(w);
if(cw > FLT_EPSILON)
splitter->coeff = (std::sin(w) - 1.0f) / cw;
else
@@ -84,7 +84,7 @@ void splitterap_clear(SplitterAllpass *splitter)
splitter->z1 = 0.0f;
}
-void splitterap_process(SplitterAllpass *splitter, ALfloat *RESTRICT samples, ALsizei count)
+void splitterap_process(SplitterAllpass *splitter, float *RESTRICT samples, int count)
{
ASSUME(count > 0);
diff --git a/Alc/filters/splitter.h b/Alc/filters/splitter.h
index 13f4cd55..96ecdb43 100644
--- a/Alc/filters/splitter.h
+++ b/Alc/filters/splitter.h
@@ -7,35 +7,35 @@
/* Band splitter. Splits a signal into two phase-matching frequency bands. */
struct BandSplitter {
- ALfloat coeff{0.0f};
- ALfloat lp_z1{0.0f};
- ALfloat lp_z2{0.0f};
- ALfloat hp_z1{0.0f};
+ float coeff{0.0f};
+ float lp_z1{0.0f};
+ float lp_z2{0.0f};
+ float hp_z1{0.0f};
};
-void bandsplit_init(BandSplitter *splitter, ALfloat f0norm);
+void bandsplit_init(BandSplitter *splitter, float f0norm);
void bandsplit_clear(BandSplitter *splitter);
-void bandsplit_process(BandSplitter *splitter, ALfloat *RESTRICT hpout, ALfloat *RESTRICT lpout,
- const ALfloat *input, ALsizei count);
+void bandsplit_process(BandSplitter *splitter, float *RESTRICT hpout, float *RESTRICT lpout,
+ const float *input, int count);
/* The all-pass portion of the band splitter. Applies the same phase shift
* without splitting the signal.
*/
struct SplitterAllpass {
- ALfloat coeff{0.0f};
- ALfloat z1{0.0f};
+ float coeff{0.0f};
+ float z1{0.0f};
};
-void splitterap_init(SplitterAllpass *splitter, ALfloat f0norm);
+void splitterap_init(SplitterAllpass *splitter, float f0norm);
void splitterap_clear(SplitterAllpass *splitter);
-void splitterap_process(SplitterAllpass *splitter, ALfloat *RESTRICT samples, ALsizei count);
+void splitterap_process(SplitterAllpass *splitter, float *RESTRICT samples, int count);
struct FrontStablizer {
SplitterAllpass APFilter[MAX_OUTPUT_CHANNELS];
BandSplitter LFilter, RFilter;
- alignas(16) ALfloat LSplit[2][BUFFERSIZE];
- alignas(16) ALfloat RSplit[2][BUFFERSIZE];
+ alignas(16) float LSplit[2][BUFFERSIZE];
+ alignas(16) float RSplit[2][BUFFERSIZE];
DEF_NEWDEL(FrontStablizer)
};