From 470f454c5363b09eb4ae7cf12bde9c5fbe6d8266 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 13 Jul 2016 23:08:11 -0700 Subject: Modify bs2b_cross_feed to do multiple samples at once --- OpenAL32/Include/bs2b.h | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) (limited to 'OpenAL32/Include/bs2b.h') diff --git a/OpenAL32/Include/bs2b.h b/OpenAL32/Include/bs2b.h index 903c6bc5..bfe5c274 100644 --- a/OpenAL32/Include/bs2b.h +++ b/OpenAL32/Include/bs2b.h @@ -63,10 +63,10 @@ struct bs2b { * [0] - first channel, [1] - second channel */ struct t_last_sample { - float asis[2]; - float lo[2]; - float hi[2]; - } last_sample; + float asis; + float lo; + float hi; + } last_sample[2]; }; /* Clear buffers and set new coefficients with new crossfeed level and sample @@ -85,38 +85,7 @@ int bs2b_get_srate(struct bs2b *bs2b); /* Clear buffer */ void bs2b_clear(struct bs2b *bs2b); -/* Crossfeeds one stereo sample that are pointed by sample. - * [0] - first channel, [1] - second channel. - * Returns crossfided sample by sample pointer. - */ -inline void bs2b_cross_feed(struct bs2b *bs2b, float *restrict sample) -{ -/* 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(sample[0], bs2b->last_sample.lo[0]); - bs2b->last_sample.lo[1] = lo_filter(sample[1], bs2b->last_sample.lo[1]); - - /* Highboost filter */ - bs2b->last_sample.hi[0] = hi_filter(sample[0], bs2b->last_sample.asis[0], bs2b->last_sample.hi[0]); - bs2b->last_sample.hi[1] = hi_filter(sample[1], bs2b->last_sample.asis[1], bs2b->last_sample.hi[1]); - bs2b->last_sample.asis[0] = sample[0]; - bs2b->last_sample.asis[1] = sample[1]; - - /* Crossfeed */ - sample[0] = bs2b->last_sample.hi[0] + bs2b->last_sample.lo[1]; - sample[1] = bs2b->last_sample.hi[1] + bs2b->last_sample.lo[0]; -#undef hi_filter -#undef lo_filter -} /* bs2b_cross_feed */ +void bs2b_cross_feed(struct bs2b *bs2b, float *restrict Left, float *restrict Right, unsigned int SamplesToDo); #ifdef __cplusplus } /* extern "C" */ -- cgit v1.2.3 From e92229f8395979591a14a980543d92aa4e7489c0 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 10 Feb 2017 06:20:16 -0800 Subject: Fix more uses of unsigned sizes and offsets --- Alc/ALu.c | 10 +++++----- Alc/bs2b.c | 8 ++++---- OpenAL32/Include/bs2b.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenAL32/Include/bs2b.h') diff --git a/Alc/ALu.c b/Alc/ALu.c index 67f61f07..29097c2a 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -1369,9 +1369,9 @@ static inline ALubyte aluF2UB(ALfloat val) #define DECL_TEMPLATE(T, func) \ static void Write_##T(ALfloatBUFFERSIZE *InBuffer, ALvoid *OutBuffer, \ - ALuint SamplesToDo, ALuint numchans) \ + ALsizei SamplesToDo, ALsizei numchans) \ { \ - ALuint i, j; \ + ALsizei i, j; \ for(j = 0;j < numchans;j++) \ { \ const ALfloat *in = InBuffer[j]; \ @@ -1394,7 +1394,7 @@ DECL_TEMPLATE(ALbyte, aluF2B) void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) { - ALuint SamplesToDo; + ALsizei SamplesToDo; ALvoice *voice, *voice_end; ALeffectslot *slot; ALsource *source; @@ -1406,7 +1406,7 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) while(size > 0) { - SamplesToDo = minu(size, BUFFERSIZE); + SamplesToDo = mini(size, BUFFERSIZE); for(c = 0;c < device->Dry.NumChannels;c++) memset(device->Dry.Buffer[c], 0, SamplesToDo*sizeof(ALfloat)); if(device->Dry.Buffer != device->RealOut.Buffer) @@ -1559,7 +1559,7 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) if(buffer) { ALfloat (*OutBuffer)[BUFFERSIZE] = device->RealOut.Buffer; - ALuint OutChannels = device->RealOut.NumChannels; + ALsizei OutChannels = device->RealOut.NumChannels; #define WRITE(T, a, b, c, d) do { \ Write_##T((a), (b), (c), (d)); \ diff --git a/Alc/bs2b.c b/Alc/bs2b.c index ddc2e2f2..e235e547 100644 --- a/Alc/bs2b.c +++ b/Alc/bs2b.c @@ -129,16 +129,16 @@ void bs2b_clear(struct bs2b *bs2b) memset(&bs2b->last_sample, 0, sizeof(bs2b->last_sample)); } /* bs2b_clear */ -void bs2b_cross_feed(struct bs2b *bs2b, float *restrict Left, float *restrict Right, unsigned int SamplesToDo) +void bs2b_cross_feed(struct bs2b *bs2b, float *restrict Left, float *restrict Right, int SamplesToDo) { float lsamples[128][2]; float rsamples[128][2]; - unsigned int base; + int base; for(base = 0;base < SamplesToDo;) { - unsigned int todo = minu(128, SamplesToDo-base); - unsigned int i; + int todo = mini(128, SamplesToDo-base); + int i; /* Process left input */ lsamples[0][0] = bs2b->a0_lo*Left[0] + diff --git a/OpenAL32/Include/bs2b.h b/OpenAL32/Include/bs2b.h index bfe5c274..e845d906 100644 --- a/OpenAL32/Include/bs2b.h +++ b/OpenAL32/Include/bs2b.h @@ -85,7 +85,7 @@ int bs2b_get_srate(struct bs2b *bs2b); /* Clear buffer */ void bs2b_clear(struct bs2b *bs2b); -void bs2b_cross_feed(struct bs2b *bs2b, float *restrict Left, float *restrict Right, unsigned int SamplesToDo); +void bs2b_cross_feed(struct bs2b *bs2b, float *restrict Left, float *restrict Right, int SamplesToDo); #ifdef __cplusplus } /* extern "C" */ -- cgit v1.2.3