From dfded9595cb878c350a8852066601a921a3c2c44 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 10 Jun 2014 12:46:58 -0700 Subject: Make bs2b_cross_feed inline --- OpenAL32/Include/bs2b.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/bs2b.h b/OpenAL32/Include/bs2b.h index 0f06b1ca..2cc76931 100644 --- a/OpenAL32/Include/bs2b.h +++ b/OpenAL32/Include/bs2b.h @@ -96,8 +96,39 @@ void bs2b_clear(struct bs2b *bs2b); * Returns crossfided samle by sample pointer. */ -/* sample poits to floats */ -void bs2b_cross_feed(struct bs2b *bs2b, float *sample); +/* sample points to floats */ +inline void bs2b_cross_feed(struct bs2b *bs2b, float *restrict samples) +{ +/* Single pole IIR filter. + * O[n] = a0*I[n] + a1*I[n-1] + b1*O[n-1] + */ + +/* Lowpass filter */ +#define lo_filter(in, out_1) (bs2b->a0_lo*(in) + bs2b->b1_lo*(out_1)) + +/* Highboost filter */ +#define hi_filter(in, in_1, out_1) (bs2b->a0_hi*(in) + bs2b->a1_hi*(in_1) + bs2b->b1_hi*(out_1)) + + /* Lowpass filter */ + bs2b->last_sample.lo[0] = lo_filter(samples[0], bs2b->last_sample.lo[0]); + bs2b->last_sample.lo[1] = lo_filter(samples[1], bs2b->last_sample.lo[1]); + + /* Highboost filter */ + bs2b->last_sample.hi[0] = hi_filter(samples[0], bs2b->last_sample.asis[0], bs2b->last_sample.hi[0]); + bs2b->last_sample.hi[1] = hi_filter(samples[1], bs2b->last_sample.asis[1], bs2b->last_sample.hi[1]); + bs2b->last_sample.asis[0] = samples[0]; + bs2b->last_sample.asis[1] = samples[1]; + + /* Crossfeed */ + samples[0] = (float)(bs2b->last_sample.hi[0] + bs2b->last_sample.lo[1]); + samples[1] = (float)(bs2b->last_sample.hi[1] + bs2b->last_sample.lo[0]); + + /* Bass boost cause allpass attenuation */ + samples[0] *= bs2b->gain; + samples[1] *= bs2b->gain; +#undef hi_filter +#undef lo_filter +} /* bs2b_cross_feed */ #ifdef __cplusplus } /* extern "C" */ -- cgit v1.2.3