aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-06-29 23:18:49 -0700
committerChris Robinson <[email protected]>2011-06-29 23:18:49 -0700
commit5736bbc3e43145aa59d3e611ad95e4e73fb836df (patch)
treebeb6f03976fa2887260493fe9ac978d2d5738611 /Alc
parent1b773a858534693056161c90702c4cdb013e8a64 (diff)
Add a source property to skip channel virtualization for multi-channel buffers
With virtualization disabled, channels are mapped directly from input to output and any input channel that is missing an output is dropped. Any virtualization effects (such as HRTF filters) for positional cues are also skipped. The idea is to allow applications a way to play pre-filtered audio that channel vitualization effects could interfere with.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c2
-rw-r--r--Alc/ALu.c64
2 files changed, 48 insertions, 18 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 65984934..d880441e 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -389,7 +389,7 @@ static const ALchar alExtList[] =
"AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW "
"AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model "
"AL_LOKI_quadriphonic AL_SOFTX_buffer_samples AL_SOFT_buffer_sub_data "
- "AL_SOFT_loop_points";
+ "AL_SOFT_loop_points AL_SOFTX_non_virtual_channels";
// Mixing Priority Level
static ALint RTPrioLevel;
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 8bfe305b..845436a5 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -89,6 +89,22 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
static const ALfloat angles_X71[8] = { -30.0f, 30.0f, 0.0f, 0.0f,
-110.0f, 110.0f, -90.0f, 90.0f };
+ static const Channel chans_Mono[1] = { FRONT_CENTER };
+ static const Channel chans_Stereo[2] = { FRONT_LEFT, FRONT_RIGHT };
+ static const Channel chans_Rear[2] = { BACK_LEFT, BACK_RIGHT };
+ static const Channel chans_Quad[4] = { FRONT_LEFT, FRONT_RIGHT,
+ BACK_LEFT, BACK_RIGHT };
+ static const Channel chans_X51[6] = { FRONT_LEFT, FRONT_RIGHT,
+ FRONT_CENTER, LFE,
+ BACK_LEFT, BACK_RIGHT };
+ static const Channel chans_X61[7] = { FRONT_LEFT, FRONT_RIGHT,
+ FRONT_CENTER, LFE, BACK_CENTER,
+ SIDE_LEFT, SIDE_RIGHT };
+ static const Channel chans_X71[8] = { FRONT_LEFT, FRONT_RIGHT,
+ FRONT_CENTER, LFE,
+ BACK_LEFT, BACK_RIGHT,
+ SIDE_LEFT, SIDE_RIGHT };
+
ALCdevice *Device = ALContext->Device;
ALfloat SourceVolume,ListenerGain,MinVolume,MaxVolume;
ALbufferlistitem *BufferListItem;
@@ -101,8 +117,9 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALint NumSends, Frequency;
const ALfloat *SpeakerGain;
const ALfloat *angles = NULL;
+ const Channel *chans = NULL;
ALint num_channels = 0;
- ALint lfe_chan = -1;
+ ALboolean VirtualChannels;
ALfloat Pitch;
ALfloat cw;
ALuint pos;
@@ -117,10 +134,11 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ListenerGain = ALContext->Listener.Gain;
/* Get source properties */
- SourceVolume = ALSource->flGain;
- MinVolume = ALSource->flMinGain;
- MaxVolume = ALSource->flMaxGain;
- Pitch = ALSource->flPitch;
+ SourceVolume = ALSource->flGain;
+ MinVolume = ALSource->flMinGain;
+ MaxVolume = ALSource->flMaxGain;
+ Pitch = ALSource->flPitch;
+ VirtualChannels = ALSource->VirtualChannels;
/* Calculate the stepping value */
Channels = FmtMono;
@@ -148,11 +166,14 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
Channels = ALBuffer->FmtChannels;
- ALSource->Params.DoMix = ((Device->Flags&DEVICE_USE_HRTF) ?
- SelectHrtfMixer(ALBuffer, (ALSource->Params.Step==FRACTIONONE) ?
- POINT_RESAMPLER : ALSource->Resampler) :
- SelectMixer(ALBuffer, (ALSource->Params.Step==FRACTIONONE) ?
- POINT_RESAMPLER : ALSource->Resampler));
+ if(ALSource->VirtualChannels && (Device->Flags&DEVICE_USE_HRTF))
+ ALSource->Params.DoMix = SelectHrtfMixer(ALBuffer,
+ (ALSource->Params.Step==FRACTIONONE) ? POINT_RESAMPLER :
+ ALSource->Resampler);
+ else
+ ALSource->Params.DoMix = SelectMixer(ALBuffer,
+ (ALSource->Params.Step==FRACTIONONE) ? POINT_RESAMPLER :
+ ALSource->Resampler);
break;
}
BufferListItem = BufferListItem->next;
@@ -182,10 +203,11 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
case FmtMono:
angles = angles_Mono;
+ chans = chans_Mono;
num_channels = 1;
break;
case FmtStereo:
- if((ALContext->Device->Flags&DEVICE_DUPLICATE_STEREO))
+ if(VirtualChannels && (ALContext->Device->Flags&DEVICE_DUPLICATE_STEREO))
{
DryGain *= aluSqrt(2.0f/4.0f);
for(c = 0;c < 2;c++)
@@ -203,45 +225,53 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
}
angles = angles_Stereo;
+ chans = chans_Stereo;
num_channels = 2;
break;
case FmtRear:
angles = angles_Rear;
+ chans = chans_Rear;
num_channels = 2;
break;
case FmtQuad:
angles = angles_Quad;
+ chans = chans_Quad;
num_channels = 4;
break;
case FmtX51:
angles = angles_X51;
+ chans = chans_X51;
num_channels = 6;
- lfe_chan = 3;
break;
case FmtX61:
angles = angles_X61;
+ chans = chans_X61;
num_channels = 7;
- lfe_chan = 3;
break;
case FmtX71:
angles = angles_X71;
+ chans = chans_X71;
num_channels = 8;
- lfe_chan = 3;
break;
}
- if((Device->Flags&DEVICE_USE_HRTF))
+ if(VirtualChannels == AL_FALSE)
+ {
+ for(c = 0;c < num_channels;c++)
+ SrcMatrix[c][chans[c]] += DryGain * ListenerGain;
+ }
+ else if((Device->Flags&DEVICE_USE_HRTF))
{
for(c = 0;c < num_channels;c++)
{
const ALshort *hrtf_left, *hrtf_right;
- if(c == lfe_chan)
+ if(chans[c] == LFE)
{
/* Skip LFE */
ALSource->Params.HrtfDelay[c][0] = 0;
@@ -271,7 +301,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
for(c = 0;c < num_channels;c++)
{
- if(c == lfe_chan) /* Special-case LFE */
+ if(chans[c] == LFE) /* Special-case LFE */
{
SrcMatrix[c][LFE] += DryGain * ListenerGain;
continue;