diff options
author | Chris Robinson <[email protected]> | 2010-08-07 05:43:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-08-07 05:43:16 -0700 |
commit | 5f22d30fc91e677933e12034979f42f74c4f653d (patch) | |
tree | 71e9f5de28e2f6b1cb21ccf0dea02289a9081ac3 /Alc/ALu.c | |
parent | d6dc855511982a76be8289966842030d135a8578 (diff) |
Calculate the source stepping value with the param calculations
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r-- | Alc/ALu.c | 45 |
1 files changed, 40 insertions, 5 deletions
@@ -84,6 +84,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) ALfloat WetGain[MAX_SENDS]; ALfloat WetGainHF[MAX_SENDS]; ALint NumSends, Frequency; + ALfloat Pitch; ALfloat cw; ALint i; @@ -100,19 +101,30 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) MaxVolume = ALSource->flMaxGain; //1. Multi-channel buffers always play "normal" + Pitch = ALSource->flPitch; BufferListItem = ALSource->queue; while(BufferListItem != NULL) { ALbuffer *ALBuffer; if((ALBuffer=BufferListItem->buffer) != NULL) { - ALSource->Params.Pitch = ALSource->flPitch*ALBuffer->frequency / - Frequency; + Pitch = Pitch * ALBuffer->frequency / Frequency; break; } BufferListItem = BufferListItem->next; } + if(Pitch > (float)MAX_PITCH) + ALSource->Params.Step = MAX_PITCH<<FRACTIONBITS; + else if(!(Pitch > 0.0f)) + ALSource->Params.Step = 1<<FRACTIONBITS; + else + { + ALSource->Params.Step = Pitch*(1<<FRACTIONBITS); + if(ALSource->Params.Step == 0) + ALSource->Params.Step = 1; + } + DryGain = SourceVolume; DryGain = __min(DryGain,MaxVolume); DryGain = __max(DryGain,MinVolume); @@ -178,6 +190,7 @@ ALvoid CalcNonAttnStereoSourceParams(ALsource *ALSource, const ALCcontext *ALCon ALfloat WetGainHF[MAX_SENDS]; ALint NumSends, Frequency; ALboolean DupStereo; + ALfloat Pitch; ALenum Format; ALfloat cw; ALint i; @@ -197,19 +210,30 @@ ALvoid CalcNonAttnStereoSourceParams(ALsource *ALSource, const ALCcontext *ALCon MaxVolume = ALSource->flMaxGain; //1. Multi-channel buffers always play "normal" + Pitch = ALSource->flPitch; BufferListItem = ALSource->queue; while(BufferListItem != NULL) { ALbuffer *ALBuffer; if((ALBuffer=BufferListItem->buffer) != NULL) { - ALSource->Params.Pitch = ALSource->flPitch*ALBuffer->frequency / - Frequency; + Pitch = Pitch * ALBuffer->frequency / Frequency; break; } BufferListItem = BufferListItem->next; } + if(Pitch > (float)MAX_PITCH) + ALSource->Params.Step = MAX_PITCH<<FRACTIONBITS; + else if(!(Pitch > 0.0f)) + ALSource->Params.Step = 1<<FRACTIONBITS; + else + { + ALSource->Params.Step = Pitch*(1<<FRACTIONBITS); + if(ALSource->Params.Step == 0) + ALSource->Params.Step = 1; + } + DryGain = SourceVolume; DryGain = __min(DryGain,MaxVolume); DryGain = __max(DryGain,MinVolume); @@ -663,12 +687,23 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) ALbuffer *ALBuffer; if((ALBuffer=BufferListItem->buffer) != NULL) { - ALSource->Params.Pitch = Pitch*ALBuffer->frequency / Frequency; + Pitch = Pitch * ALBuffer->frequency / Frequency; break; } BufferListItem = BufferListItem->next; } + if(Pitch > (float)MAX_PITCH) + ALSource->Params.Step = MAX_PITCH<<FRACTIONBITS; + else if(!(Pitch > 0.0f)) + ALSource->Params.Step = 1<<FRACTIONBITS; + else + { + ALSource->Params.Step = Pitch*(1<<FRACTIONBITS); + if(ALSource->Params.Step == 0) + ALSource->Params.Step = 1; + } + // Use energy-preserving panning algorithm for multi-speaker playback length = __max(OrigDist, MinDist); if(length > 0.0f) |