From 8dbac9c0bdd9bf45a9a3c871c59766b3693d8d59 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 21 Oct 2009 14:25:54 -0700 Subject: Store the calculated source parameters in the source struct --- Alc/ALu.c | 23 ++++++++++++++++------- OpenAL32/Include/alSource.h | 28 ++++++++++++++++++---------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index 490a092e..ef5c5696 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -823,7 +823,7 @@ static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANN static float DummyBuffer[BUFFERSIZE]; ALfloat *WetBuffer[MAX_SENDS]; ALfloat (*Matrix)[OUTPUTCHANNELS] = ALContext->ChannelMatrix; - ALfloat DrySend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + ALfloat DrySend[OUTPUTCHANNELS]; ALfloat dryGainStep[OUTPUTCHANNELS]; ALfloat wetGainStep[MAX_SENDS]; ALuint i, j, k, out; @@ -879,18 +879,19 @@ another_source: goto skipmix; /* Get source info */ - DryFilter = &ALSource->iirFilter; + DryFilter = &ALSource->Params.iirFilter; for(i = 0;i < MAX_SENDS;i++) { - WetFilter[i] = &ALSource->Send[i].iirFilter; + WetFilter[i] = &ALSource->Params.Send[i].iirFilter; WetBuffer[i] = (ALSource->Send[i].Slot ? ALSource->Send[i].Slot->WetBuffer : DummyBuffer); } CalcSourceParams(ALContext, ALSource, (Channels==1)?AL_TRUE:AL_FALSE, - DrySend, WetSend, &Pitch, DryFilter, WetFilter); - Pitch = (Pitch*ALBuffer->frequency) / frequency; + ALSource->Params.DryGains, ALSource->Params.WetGains, + &ALSource->Params.Pitch, DryFilter, WetFilter); + Pitch = (ALSource->Params.Pitch*ALBuffer->frequency) / frequency; if(DuplicateStereo && Channels == 2) { @@ -912,20 +913,28 @@ another_source: { ALSource->FirstStart = AL_FALSE; for(i = 0;i < OUTPUTCHANNELS;i++) + { + DrySend[i] = ALSource->Params.DryGains[i]; dryGainStep[i] = 0.0f; + } for(i = 0;i < MAX_SENDS;i++) + { + WetSend[i] = ALSource->Params.WetGains[i]; wetGainStep[i] = 0.0f; + } } else { for(i = 0;i < OUTPUTCHANNELS;i++) { - dryGainStep[i] = (DrySend[i]-ALSource->DryGains[i]) / rampLength; + dryGainStep[i] = (ALSource->Params.DryGains[i]- + ALSource->DryGains[i]) / rampLength; DrySend[i] = ALSource->DryGains[i]; } for(i = 0;i < MAX_SENDS;i++) { - wetGainStep[i] = (WetSend[i]-ALSource->WetGains[i]) / rampLength; + wetGainStep[i] = (ALSource->Params.WetGains[i]- + ALSource->WetGains[i]) / rampLength; WetSend[i] = ALSource->WetGains[i]; } } diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 1002d077..8c6ba813 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -66,8 +66,6 @@ typedef struct ALsource struct { struct ALeffectslot *Slot; ALfilter WetFilter; - FILTER iirFilter; - ALfloat history[2]; } Send[MAX_SENDS]; ALboolean DryGainHFAuto; @@ -75,18 +73,10 @@ typedef struct ALsource ALboolean WetGainHFAuto; ALfloat OuterGainHF; - FILTER iirFilter; - ALfloat history[OUTPUTCHANNELS*2]; - ALfloat AirAbsorptionFactor; - ALfloat RoomRolloffFactor; - ALfloat DopplerFactor; - // Index to itself - ALuint source; - ALint lOffset; ALint lOffsetType; @@ -98,6 +88,24 @@ typedef struct ALsource ALfloat WetGains[MAX_SENDS]; ALboolean FirstStart; + // Current target parameters used for mixing + struct { + ALfloat DryGains[OUTPUTCHANNELS]; + ALfloat WetGains[MAX_SENDS]; + ALfloat Pitch; + + struct { + FILTER iirFilter; + ALfloat history[2]; + } Send[MAX_SENDS]; + + FILTER iirFilter; + ALfloat history[OUTPUTCHANNELS*2]; + } Params; + + // Index to itself + ALuint source; + struct ALsource *next; } ALsource; -- cgit v1.2.3