void aluInitMixer(void) { ALuint i; for(i = 0;i < FRACTIONONE;i++) { ALfloat mu = (ALfloat)i / FRACTIONONE; ResampleCoeffs[i][0] = lanc2(mu - -1.0f); ResampleCoeffs[i][1] = lanc2(mu - 0.0f); ResampleCoeffs[i][2] = lanc2(mu - 1.0f); ResampleCoeffs[i][3] = lanc2(mu - 2.0f); } MixHrtfSamples = SelectHrtfMixer(); MixSamples = SelectMixer(); ResampleSamples = SelectResampler(DefaultResampler); }
ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) { static const ALfloat angles_Mono[1] = { 0.0f }; static const ALfloat angles_Stereo[2] = { -30.0f, 30.0f }; static const ALfloat angles_Rear[2] = { -150.0f, 150.0f }; static const ALfloat angles_Quad[4] = { -45.0f, 45.0f, -135.0f, 135.0f }; static const ALfloat angles_X51[6] = { -30.0f, 30.0f, 0.0f, 0.0f, -110.0f, 110.0f }; static const ALfloat angles_X61[7] = { -30.0f, 30.0f, 0.0f, 0.0f, 180.0f, -90.0f, 90.0f }; static const ALfloat angles_X71[8] = { -30.0f, 30.0f, 0.0f, 0.0f, -110.0f, 110.0f, -90.0f, 90.0f }; static const enum Channel chans_Mono[1] = { FRONT_CENTER }; static const enum Channel chans_Stereo[2] = { FRONT_LEFT, FRONT_RIGHT }; static const enum Channel chans_Rear[2] = { BACK_LEFT, BACK_RIGHT }; static const enum Channel chans_Quad[4] = { FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT }; static const enum Channel chans_X51[6] = { FRONT_LEFT, FRONT_RIGHT, FRONT_CENTER, LFE, BACK_LEFT, BACK_RIGHT }; static const enum Channel chans_X61[7] = { FRONT_LEFT, FRONT_RIGHT, FRONT_CENTER, LFE, BACK_CENTER, SIDE_LEFT, SIDE_RIGHT }; static const enum 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; enum DevFmtChannels DevChans; enum FmtChannels Channels; ALfloat (*SrcMatrix)[MAXCHANNELS]; ALfloat DryGain, DryGainHF; ALfloat WetGain[MAX_SENDS]; ALfloat WetGainHF[MAX_SENDS]; ALint NumSends, Frequency; const ALfloat *SpeakerGain; const ALfloat *angles = NULL; const enum Channel *chans = NULL; enum Resampler Resampler; ALint num_channels = 0; ALboolean VirtualChannels; ALfloat Pitch; ALfloat cw; ALuint pos; ALint i, c; /* Get device properties */ DevChans = ALContext->Device->FmtChans; NumSends = ALContext->Device->NumAuxSends; Frequency = ALContext->Device->Frequency; /* Get listener properties */ ListenerGain = ALContext->Listener.Gain; /* Get source properties */ SourceVolume = ALSource->flGain; MinVolume = ALSource->flMinGain; MaxVolume = ALSource->flMaxGain; Pitch = ALSource->flPitch; Resampler = ALSource->Resampler; VirtualChannels = ALSource->VirtualChannels; /* Calculate the stepping value */ Channels = FmtMono; BufferListItem = ALSource->queue; while(BufferListItem != NULL) { ALbuffer *ALBuffer; if((ALBuffer=BufferListItem->buffer) != NULL) { ALint maxstep = STACK_DATA_SIZE / ALSource->NumChannels / ALSource->SampleSize; maxstep -= ResamplerPadding[Resampler] + ResamplerPrePadding[Resampler] + 1; maxstep = mini(maxstep, INT_MAX>>FRACTIONBITS); Pitch = Pitch * ALBuffer->Frequency / Frequency; if(Pitch > (ALfloat)maxstep) ALSource->Params.Step = maxstep<<FRACTIONBITS; else { ALSource->Params.Step = Pitch*FRACTIONONE; if(ALSource->Params.Step == 0) ALSource->Params.Step = 1; } Channels = ALBuffer->FmtChannels; if(ALSource->VirtualChannels && (Device->Flags&DEVICE_USE_HRTF)) ALSource->Params.DoMix = SelectHrtfMixer(ALBuffer, (ALSource->Params.Step==FRACTIONONE) ? POINT_RESAMPLER : Resampler); else ALSource->Params.DoMix = SelectMixer(ALBuffer, (ALSource->Params.Step==FRACTIONONE) ? POINT_RESAMPLER : Resampler); break; } BufferListItem = BufferListItem->next; }