aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-04 14:15:55 -0800
committerChris Robinson <[email protected]>2008-01-04 14:15:55 -0800
commitb3badbf97d95d84bb0de655275b00e30948e311f (patch)
treebf9c4ce80ffdcdade9176cd979a1188d67364291 /Alc
parent4d5885e27bef05004ab16be8da4e93b458b736a9 (diff)
Use 6 point spatialization for 6.1 and 7.1 output
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c49
1 files changed, 38 insertions, 11 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 7f5011a9..0b668b65 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -396,9 +396,6 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource,
case 4:
/* TODO: Add center/lfe channel in spatial calculations? */
case 6:
- /* TODO: Special paths for 6.1 and 7.1 output would be nice */
- case 7:
- case 8:
// Apply a scalar so each individual speaker has more weight
PanningLR = 0.5f + (0.5f*Position[0]*1.41421356f);
PanningLR = __min(1.0f, PanningLR);
@@ -410,15 +407,49 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource,
drysend[FRONT_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*(1.0f-PanningFB));
drysend[BACK_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt((1.0f-PanningLR)*( PanningFB));
drysend[BACK_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*( PanningFB));
- drysend[SIDE_LEFT] = 0.0f;
- drysend[SIDE_RIGHT] = 0.0f;
wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB));
wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB));
wetsend[BACK_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*( PanningFB));
wetsend[BACK_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*( PanningFB));
- wetsend[SIDE_LEFT] = 0.0f;
- wetsend[SIDE_RIGHT] = 0.0f;
break;
+ case 7:
+ case 8:
+ PanningFB = 1.0f - fabs(Position[2]*1.15470054f);
+ PanningFB = __min(1.0f, PanningFB);
+ PanningFB = __max(0.0f, PanningFB);
+ PanningLR = 0.5f + (0.5*Position[0]*((1.0f-PanningFB)*2.0f));
+ PanningLR = __min(1.0f, PanningLR);
+ PanningLR = __max(0.0f, PanningLR);
+ if(Position[2] > 0.0f)
+ {
+ drysend[BACK_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB));
+ drysend[BACK_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*(1.0f-PanningFB));
+ drysend[SIDE_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt((1.0f-PanningLR)*( PanningFB));
+ drysend[SIDE_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*( PanningFB));
+ drysend[FRONT_LEFT] = 0.0f;
+ drysend[FRONT_RIGHT] = 0.0f;
+ wetsend[BACK_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB));
+ wetsend[BACK_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB));
+ wetsend[SIDE_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*( PanningFB));
+ wetsend[SIDE_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*( PanningFB));
+ wetsend[FRONT_LEFT] = 0.0f;
+ wetsend[FRONT_RIGHT] = 0.0f;
+ }
+ else
+ {
+ drysend[FRONT_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB));
+ drysend[FRONT_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*(1.0f-PanningFB));
+ drysend[SIDE_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt((1.0f-PanningLR)*( PanningFB));
+ drysend[SIDE_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*( PanningFB));
+ drysend[BACK_LEFT] = 0.0f;
+ drysend[BACK_RIGHT] = 0.0f;
+ wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB));
+ wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB));
+ wetsend[SIDE_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*( PanningFB));
+ wetsend[SIDE_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*( PanningFB));
+ wetsend[BACK_LEFT] = 0.0f;
+ wetsend[BACK_RIGHT] = 0.0f;
+ }
default:
break;
}
@@ -579,19 +610,15 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
//Direct path final mix buffer and panning
DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT];
DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT];
-#if 0 /* FIXME: Re-enable when proper 6-channel spatialization is used */
DryBuffer[j][SIDE_LEFT] += value*DrySend[SIDE_LEFT];
DryBuffer[j][SIDE_RIGHT] += value*DrySend[SIDE_RIGHT];
-#endif
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][FRONT_LEFT] += value*WetSend[FRONT_LEFT];
WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT];
-#if 0 /* FIXME: Re-enable when proper 6-channel spatialization is used */
WetBuffer[j][SIDE_LEFT] += value*WetSend[SIDE_LEFT];
WetBuffer[j][SIDE_RIGHT] += value*WetSend[SIDE_RIGHT];
-#endif
WetBuffer[j][BACK_LEFT] += value*WetSend[BACK_LEFT];
WetBuffer[j][BACK_RIGHT] += value*WetSend[BACK_RIGHT];
}