aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/bformatdec.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-07-19 02:48:01 -0700
committerChris Robinson <[email protected]>2017-07-19 02:48:01 -0700
commitfea74124c88e00a27e51b89fdb769d2467bda0e7 (patch)
tree8e39847575424b6de5066c1a4f74b376ae153263 /Alc/bformatdec.c
parent0135ddc2e5857e172fccd6ec635275eeae4ae869 (diff)
Add an all-pass filter that replicates the band splitter's phase shift
Diffstat (limited to 'Alc/bformatdec.c')
-rw-r--r--Alc/bformatdec.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c
index 92a2aecf..ba6daac5 100644
--- a/Alc/bformatdec.c
+++ b/Alc/bformatdec.c
@@ -75,6 +75,45 @@ void bandsplit_process(BandSplitter *splitter, ALfloat *restrict hpout, ALfloat
}
+void splitterap_init(SplitterAllpass *splitter, ALfloat freq_mult)
+{
+ ALfloat w = freq_mult * F_TAU;
+ ALfloat cw = cosf(w);
+ if(cw > FLT_EPSILON)
+ splitter->coeff = (sinf(w) - 1.0f) / cw;
+ else
+ splitter->coeff = cw * -0.5f;
+
+ splitter->z1 = 0.0f;
+}
+
+void splitterap_clear(SplitterAllpass *splitter)
+{
+ splitter->z1 = 0.0f;
+}
+
+void splitterap_process(SplitterAllpass *splitter, ALfloat *restrict samples, ALsizei count)
+{
+ ALfloat coeff, d, x;
+ ALfloat z1;
+ ALsizei i;
+
+ coeff = splitter->coeff;
+ z1 = splitter->z1;
+ for(i = 0;i < count;i++)
+ {
+ x = samples[i];
+
+ d = x - coeff*z1;
+ x = z1 + coeff*d;
+ z1 = d;
+
+ samples[i] = x;
+ }
+ splitter->z1 = z1;
+}
+
+
static const ALfloat UnitScale[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