From a43868c32ba3b5517a60c4d1cfc68a239709da7d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 01:47:10 -0800 Subject: Use an enum list for dealing with channels This will make it easier to remap channels, especially the center and lfe channels --- Alc/ALu.c | 146 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 79 insertions(+), 67 deletions(-) (limited to 'Alc/ALu.c') diff --git a/Alc/ALu.c b/Alc/ALu.c index bb2bbd0a..682132e1 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -60,7 +60,17 @@ typedef long long ALint64; #define FRACTIONBITS 14 #define FRACTIONMASK ((1L<>FRACTIONBITS)); //Direct path final mix buffer and panning - DryBuffer[j][0] += value*DrySend[0]; - DryBuffer[j][1] += value*DrySend[1]; - DryBuffer[j][2] += value*DrySend[2]; - DryBuffer[j][3] += value*DrySend[3]; + DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT]; + DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT]; + DryBuffer[j][BACK_LEFT] += value*DrySend[BACK_LEFT]; + DryBuffer[j][BACK_RIGHT] += value*DrySend[BACK_RIGHT]; //Room path final mix buffer and panning - WetBuffer[j][0] += value*WetSend[0]; - WetBuffer[j][1] += value*WetSend[1]; - WetBuffer[j][2] += value*WetSend[2]; - WetBuffer[j][3] += value*WetSend[3]; + WetBuffer[j][FRONT_LEFT] += value*WetSend[FRONT_LEFT]; + WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT]; + WetBuffer[j][BACK_LEFT] += value*WetSend[BACK_LEFT]; + WetBuffer[j][BACK_RIGHT] += value*WetSend[BACK_RIGHT]; } else { //First order interpolator (left) value = (ALfloat)((ALshort)(((Data[k*2 ]*((1L<>FRACTIONBITS)); //Direct path final mix buffer and panning (left) - DryBuffer[j][0] += value*DrySend[0]; + DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT]; //Room path final mix buffer and panning (left) - WetBuffer[j][0] += value*WetSend[0]; + WetBuffer[j][FRONT_LEFT] += value*WetSend[FRONT_LEFT]; //First order interpolator (right) value = (ALfloat)((ALshort)(((Data[k*2+1]*((1L<>FRACTIONBITS)); //Direct path final mix buffer and panning (right) - DryBuffer[j][1] += value*DrySend[1]; + DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT]; //Room path final mix buffer and panning (right) - WetBuffer[j][1] += value*WetSend[1]; + WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT]; } DataPosFrac += increment; j++; @@ -648,74 +658,76 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma case AL_FORMAT_MONO8: for(i = 0;i < SamplesToDo;i++) { - ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+DryBuffer[i][1]+WetBuffer[i][0]+WetBuffer[i][1])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT]+DryBuffer[i][FRONT_RIGHT]+ + WetBuffer[i][FRONT_LEFT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); buffer = ((ALubyte*)buffer) + 1; } break; case AL_FORMAT_STEREO8: for(i = 0;i < SamplesToDo;i++) { - ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); - ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); buffer = ((ALubyte*)buffer) + 2; } break; case AL_FORMAT_QUAD8: for(i = 0;i < SamplesToDo;i++) { - ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); - ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); - ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][2]+WetBuffer[i][2])>>8)+128); - ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][3]+WetBuffer[i][3])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); + ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT])>>8)+128); + ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT])>>8)+128); buffer = ((ALubyte*)buffer) + 4; } break; case AL_FORMAT_51CHN8: for(i = 0;i < SamplesToDo;i++) { - ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); - ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); - ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][2]+WetBuffer[i][2])>>8)+128); - ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][3]+WetBuffer[i][3])>>8)+128); - ((ALubyte*)buffer)[4] = (ALubyte)((aluF2S(DryBuffer[i][4]+WetBuffer[i][4])>>8)+128); - ((ALubyte*)buffer)[5] = (ALubyte)((aluF2S(DryBuffer[i][5]+WetBuffer[i][5])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); + ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT])>>8)+128); + ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT])>>8)+128); + ((ALubyte*)buffer)[4] = (ALubyte)((aluF2S(DryBuffer[i][CENTER] +WetBuffer[i][CENTER])>>8)+128); + ((ALubyte*)buffer)[5] = (ALubyte)((aluF2S(DryBuffer[i][LFE] +WetBuffer[i][LFE])>>8)+128); buffer = ((ALubyte*)buffer) + 6; } break; case AL_FORMAT_MONO16: for(i = 0;i < SamplesToDo;i++) { - ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+DryBuffer[i][1]+WetBuffer[i][0]+WetBuffer[i][1]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT]+DryBuffer[i][FRONT_RIGHT]+ + WetBuffer[i][FRONT_LEFT]+WetBuffer[i][FRONT_RIGHT]); buffer = ((ALshort*)buffer) + 1; } break; case AL_FORMAT_STEREO16: for(i = 0;i < SamplesToDo;i++) { - ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); - ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT]); buffer = ((ALshort*)buffer) + 2; } break; case AL_FORMAT_QUAD16: for(i = 0;i < SamplesToDo;i++) { - ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); - ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); - ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][2]+WetBuffer[i][2]); - ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][3]+WetBuffer[i][3]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT]); + ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT]); + ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT]); buffer = ((ALshort*)buffer) + 4; } break; case AL_FORMAT_51CHN16: for(i = 0;i < SamplesToDo;i++) { - ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); - ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); - ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][2]+WetBuffer[i][2]); - ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][3]+WetBuffer[i][3]); - ((ALshort*)buffer)[4] = aluF2S(DryBuffer[i][4]+WetBuffer[i][4]); - ((ALshort*)buffer)[5] = aluF2S(DryBuffer[i][5]+WetBuffer[i][5]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT]); + ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT]); + ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT]); + ((ALshort*)buffer)[4] = aluF2S(DryBuffer[i][CENTER] +WetBuffer[i][CENTER]); + ((ALshort*)buffer)[5] = aluF2S(DryBuffer[i][LFE] +WetBuffer[i][LFE]); buffer = ((ALshort*)buffer) + 6; } break; -- cgit v1.2.3