diff options
author | Chris Robinson <[email protected]> | 2009-04-13 20:33:41 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-04-13 20:33:41 -0700 |
commit | f245f0ef87cfefd053c656b7f93cc618d46c6532 (patch) | |
tree | a0501dd5b2666f5f991def77a6d111c992d1ae6f /Alc | |
parent | a30f431b63efdcd6a17f2cad5dca205984243723 (diff) |
Make the number of source sends variable
The highest value is clamped to MAX_SENDS
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 21 | ||||
-rw-r--r-- | Alc/ALu.c | 17 |
2 files changed, 30 insertions, 8 deletions
@@ -481,6 +481,9 @@ static ALvoid InitContext(ALCcontext *pContext) pContext->lNumMonoSources = pContext->Device->MaxNoOfSources - pContext->lNumStereoSources; pContext->AuxiliaryEffectSlotMax = GetConfigValueInt(NULL, "slots", 4); + pContext->NumSends = GetConfigValueInt(NULL, "sends", MAX_SENDS); + if(pContext->NumSends > MAX_SENDS) + pContext->NumSends = MAX_SENDS; pContext->ExtensionList = "AL_EXTX_buffer_sub_data AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET AL_EXTX_source_distance_model AL_LOKI_quadriphonic"; @@ -819,6 +822,8 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize case ALC_MAX_AUXILIARY_SENDS: if(!size) SetALCError(ALC_INVALID_VALUE); + else if(device && device->Context) + *data = device->Context->NumSends; else *data = MAX_SENDS; break; @@ -860,7 +865,7 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize data[i++] = device->Context->lNumStereoSources; data[i++] = ALC_MAX_AUXILIARY_SENDS; - data[i++] = MAX_SENDS; + data[i++] = device->Context->NumSends; } ProcessContext(NULL); @@ -1025,6 +1030,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint { ALCcontext *ALContext = NULL; ALuint ulAttributeIndex, ulRequestedStereoSources; + ALuint RequestedSends; if ((device)&&(!device->IsCaptureDevice)) { @@ -1054,7 +1060,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint ProcessContext(NULL); - // Check for Voice Count attributes + // Check for attributes if (attrList) { ulAttributeIndex = 0; @@ -1069,7 +1075,16 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint ALContext->lNumStereoSources = ulRequestedStereoSources; ALContext->lNumMonoSources = ALContext->Device->MaxNoOfSources - ALContext->lNumStereoSources; - break; + } + + if(attrList[ulAttributeIndex] == ALC_MAX_AUXILIARY_SENDS) + { + RequestedSends = attrList[ulAttributeIndex + 1]; + + if(RequestedSends > ALContext->NumSends) + RequestedSends = ALContext->NumSends; + + ALContext->NumSends = RequestedSends; } ulAttributeIndex += 2; @@ -573,12 +573,14 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALfloat DryGainHF = 1.0f; ALfloat DirGain, AmbientGain; const ALfloat *SpeakerGain; + ALint NumSends; ALint pos, s, i; //Get context properties DopplerFactor = ALContext->DopplerFactor * ALSource->DopplerFactor; DopplerVelocity = ALContext->DopplerVelocity; flSpeedOfSound = ALContext->flSpeedOfSound; + NumSends = ALContext->NumSends; //Get listener properties ListenerGain = ALContext->Listener.Gain; @@ -666,7 +668,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, { if ((MinDist + (Rolloff * (Distance - MinDist))) > 0.0f) flAttenuation = MinDist / (MinDist + (Rolloff * (Distance - MinDist))); - for(i = 0;i < MAX_SENDS;i++) + for(i = 0;i < NumSends;i++) { if ((MinDist + (RoomRolloff[i] * (Distance - MinDist))) > 0.0f) RoomAttenuation[i] = MinDist / (MinDist + (RoomRolloff[i] * (Distance - MinDist))); @@ -685,7 +687,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, if (MaxDist != MinDist) { flAttenuation = 1.0f - (Rolloff*(Distance-MinDist)/(MaxDist - MinDist)); - for(i = 0;i < MAX_SENDS;i++) + for(i = 0;i < NumSends;i++) RoomAttenuation[i] = 1.0f - (RoomRolloff[i]*(Distance-MinDist)/(MaxDist - MinDist)); } break; @@ -700,7 +702,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, if ((Distance > 0.0f) && (MinDist > 0.0f)) { flAttenuation = (ALfloat)pow(Distance/MinDist, -Rolloff); - for(i = 0;i < MAX_SENDS;i++) + for(i = 0;i < NumSends;i++) RoomAttenuation[i] = (ALfloat)pow(Distance/MinDist, -RoomRolloff[i]); } break; @@ -714,7 +716,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, DryMix = __min(DryMix,MaxVolume); DryMix = __max(DryMix,MinVolume); - for(i = 0;i < MAX_SENDS;i++) + for(i = 0;i < NumSends;i++) { ALfloat WetMix = SourceVolume * RoomAttenuation[i]; WetMix = __min(WetMix,MaxVolume); @@ -792,7 +794,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, else pitch[0] = ALSource->flPitch; - for(i = 0;i < MAX_SENDS;i++) + for(i = 0;i < NumSends;i++) { if(ALSource->Send[i].Slot && ALSource->Send[i].Slot->effect.type != AL_EFFECT_NULL) @@ -836,6 +838,11 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, wetgainhf[i] = 1.0f; } } + for(i = NumSends;i < MAX_SENDS;i++) + { + wetsend[i] = 0.0f; + wetgainhf[i] = 1.0f; + } //5. Apply filter gains and filters switch(ALSource->DirectFilter.type) |