Allow getting and setting reverb parameters, as well as setting reverb effects

Reverb is still not implemented. The parameters just no-op for now.
This commit is contained in:
Chris Robinson 2008-01-15 23:32:28 -08:00
parent 24f433b938
commit 8cbbf17519
2 changed files with 316 additions and 55 deletions

View File

@ -43,6 +43,23 @@ typedef struct ALeffect_struct
// Effect type (AL_EFFECT_NULL, ...)
ALenum type;
struct {
ALfloat Density;
ALfloat Diffusion;
ALfloat Gain;
ALfloat GainHF;
ALfloat DecayTime;
ALfloat DecayHFRatio;
ALfloat ReflectionsGain;
ALfloat ReflectionsDelay;
ALfloat LateReverbGain;
ALfloat LateReverbDelay;
ALfloat AirAbsorptionGainHF;
ALfloat RoomRolloffFactor;
ALboolean DecayHFLimit;
} Reverb;
// Index to itself
ALuint effect;

View File

@ -164,11 +164,21 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
{
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
if(param == AL_EFFECT_TYPE)
{
if(iValue == AL_EFFECT_NULL ||
iValue == AL_EFFECT_REVERB)
InitEffectParams(ALEffect, iValue);
else
alSetError(AL_INVALID_VALUE);
}
else if(ALEffect->type == AL_EFFECT_REVERB)
{
switch(param)
{
case AL_EFFECT_TYPE:
if(iValue == AL_EFFECT_NULL)
InitEffectParams(ALEffect, iValue);
case AL_REVERB_DECAY_HFLIMIT:
if(iValue == AL_TRUE || iValue == AL_FALSE)
ALEffect->Reverb.DecayHFLimit = iValue;
else
alSetError(AL_INVALID_VALUE);
break;
@ -178,6 +188,9 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
break;
}
}
else
alSetError(AL_INVALID_ENUM);
}
else
alSetError(AL_INVALID_NAME);
@ -192,10 +205,18 @@ AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValue
SuspendContext(Context);
if (effect && alIsEffect(effect))
{
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
if(param == AL_EFFECT_TYPE)
{
alEffecti(effect, param, piValues[0]);
}
else if(ALEffect->type == AL_EFFECT_REVERB)
{
switch(param)
{
case AL_EFFECT_TYPE:
case AL_REVERB_DECAY_HFLIMIT:
alEffecti(effect, param, piValues[0]);
break;
@ -204,6 +225,9 @@ AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValue
break;
}
}
else
alSetError(AL_INVALID_ENUM);
}
else
alSetError(AL_INVALID_NAME);
@ -214,20 +238,109 @@ AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue
{
ALCcontext *Context;
(void)flValue;
Context = alcGetCurrentContext();
SuspendContext(Context);
if (effect && alIsEffect(effect))
{
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
if(ALEffect->type == AL_EFFECT_REVERB)
{
switch(param)
{
case AL_REVERB_DENSITY:
if(flValue >= 0.0f && flValue <= 1.0f)
ALEffect->Reverb.Density = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_DIFFUSION:
if(flValue >= 0.0f && flValue <= 1.0f)
ALEffect->Reverb.Diffusion = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_GAIN:
if(flValue >= 0.0f && flValue <= 1.0f)
ALEffect->Reverb.Gain = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_GAINHF:
if(flValue >= 0.0f && flValue <= 1.0f)
ALEffect->Reverb.GainHF = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_DECAY_TIME:
if(flValue >= 0.1f && flValue <= 20.0f)
ALEffect->Reverb.DecayTime = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_DECAY_HFRATIO:
if(flValue >= 0.1f && flValue <= 2.0f)
ALEffect->Reverb.DecayHFRatio = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_REFLECTIONS_GAIN:
if(flValue >= 0.0f && flValue <= 3.16f)
ALEffect->Reverb.ReflectionsGain = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_REFLECTIONS_DELAY:
if(flValue >= 0.0f && flValue <= 0.3f)
ALEffect->Reverb.ReflectionsDelay = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_LATE_REVERB_GAIN:
if(flValue >= 0.0f && flValue <= 10.0f)
ALEffect->Reverb.LateReverbGain = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_LATE_REVERB_DELAY:
if(flValue >= 0.0f && flValue <= 0.1f)
ALEffect->Reverb.LateReverbDelay = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_AIR_ABSORPTION_GAINHF:
if(flValue >= 0.892f && flValue <= 1.0f)
ALEffect->Reverb.AirAbsorptionGainHF = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REVERB_ROOM_ROLLOFF_FACTOR:
if(flValue >= 0.0f && flValue <= 10.0f)
ALEffect->Reverb.RoomRolloffFactor = flValue;
else
alSetError(AL_INVALID_VALUE);
break;
default:
alSetError(AL_INVALID_ENUM);
break;
}
}
else
alSetError(AL_INVALID_ENUM);
}
else
alSetError(AL_INVALID_NAME);
@ -238,20 +351,40 @@ AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflVa
{
ALCcontext *Context;
(void)pflValues;
Context = alcGetCurrentContext();
SuspendContext(Context);
if (effect && alIsEffect(effect))
{
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
if(ALEffect->type == AL_EFFECT_REVERB)
{
switch(param)
{
case AL_REVERB_DENSITY:
case AL_REVERB_DIFFUSION:
case AL_REVERB_GAIN:
case AL_REVERB_GAINHF:
case AL_REVERB_DECAY_TIME:
case AL_REVERB_DECAY_HFRATIO:
case AL_REVERB_REFLECTIONS_GAIN:
case AL_REVERB_REFLECTIONS_DELAY:
case AL_REVERB_LATE_REVERB_GAIN:
case AL_REVERB_LATE_REVERB_DELAY:
case AL_REVERB_AIR_ABSORPTION_GAINHF:
case AL_REVERB_ROOM_ROLLOFF_FACTOR:
alEffectf(effect, param, pflValues[0]);
break;
default:
alSetError(AL_INVALID_ENUM);
break;
}
}
else
alSetError(AL_INVALID_ENUM);
}
else
alSetError(AL_INVALID_NAME);
@ -269,10 +402,16 @@ AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piVal
{
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
if(param == AL_EFFECT_TYPE)
{
*piValue = ALEffect->type;
}
else if(ALEffect->type == AL_EFFECT_REVERB)
{
switch(param)
{
case AL_EFFECT_TYPE:
*piValue = ALEffect->type;
case AL_REVERB_DECAY_HFLIMIT:
*piValue = ALEffect->Reverb.DecayHFLimit;
break;
default:
@ -280,6 +419,9 @@ AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piVal
break;
}
}
else
alSetError(AL_INVALID_ENUM);
}
else
alSetError(AL_INVALID_NAME);
@ -294,10 +436,18 @@ AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piVa
SuspendContext(Context);
if (effect && alIsEffect(effect))
{
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
if(param == AL_EFFECT_TYPE)
{
alGetEffecti(effect, param, piValues);
}
else if(ALEffect->type == AL_EFFECT_REVERB)
{
switch(param)
{
case AL_EFFECT_TYPE:
case AL_REVERB_DECAY_HFLIMIT:
alGetEffecti(effect, param, piValues);
break;
@ -306,6 +456,9 @@ AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piVa
break;
}
}
else
alSetError(AL_INVALID_ENUM);
}
else
alSetError(AL_INVALID_NAME);
@ -316,20 +469,73 @@ AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pfl
{
ALCcontext *Context;
(void)pflValue;
Context = alcGetCurrentContext();
SuspendContext(Context);
if (effect && alIsEffect(effect))
{
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
if(ALEffect->type == AL_EFFECT_REVERB)
{
switch(param)
{
case AL_REVERB_DENSITY:
*pflValue = ALEffect->Reverb.Density;
break;
case AL_REVERB_DIFFUSION:
*pflValue = ALEffect->Reverb.Diffusion;
break;
case AL_REVERB_GAIN:
*pflValue = ALEffect->Reverb.Gain;
break;
case AL_REVERB_GAINHF:
*pflValue = ALEffect->Reverb.GainHF;
break;
case AL_REVERB_DECAY_TIME:
*pflValue = ALEffect->Reverb.DecayTime;
break;
case AL_REVERB_DECAY_HFRATIO:
*pflValue = ALEffect->Reverb.DecayHFRatio;
break;
case AL_REVERB_REFLECTIONS_GAIN:
*pflValue = ALEffect->Reverb.ReflectionsGain;
break;
case AL_REVERB_REFLECTIONS_DELAY:
*pflValue = ALEffect->Reverb.ReflectionsDelay;
break;
case AL_REVERB_LATE_REVERB_GAIN:
*pflValue = ALEffect->Reverb.LateReverbGain;
break;
case AL_REVERB_LATE_REVERB_DELAY:
*pflValue = ALEffect->Reverb.LateReverbDelay;
break;
case AL_REVERB_AIR_ABSORPTION_GAINHF:
*pflValue = ALEffect->Reverb.AirAbsorptionGainHF;
break;
case AL_REVERB_ROOM_ROLLOFF_FACTOR:
*pflValue = ALEffect->Reverb.RoomRolloffFactor;
break;
default:
alSetError(AL_INVALID_ENUM);
break;
}
}
else
alSetError(AL_INVALID_ENUM);
}
else
alSetError(AL_INVALID_NAME);
@ -340,20 +546,40 @@ AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pf
{
ALCcontext *Context;
(void)pflValues;
Context = alcGetCurrentContext();
SuspendContext(Context);
if (effect && alIsEffect(effect))
{
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
if(ALEffect->type == AL_EFFECT_REVERB)
{
switch(param)
{
case AL_REVERB_DENSITY:
case AL_REVERB_DIFFUSION:
case AL_REVERB_GAIN:
case AL_REVERB_GAINHF:
case AL_REVERB_DECAY_TIME:
case AL_REVERB_DECAY_HFRATIO:
case AL_REVERB_REFLECTIONS_GAIN:
case AL_REVERB_REFLECTIONS_DELAY:
case AL_REVERB_LATE_REVERB_GAIN:
case AL_REVERB_LATE_REVERB_DELAY:
case AL_REVERB_AIR_ABSORPTION_GAINHF:
case AL_REVERB_ROOM_ROLLOFF_FACTOR:
alGetEffectf(effect, param, pflValues);
break;
default:
alSetError(AL_INVALID_ENUM);
break;
}
}
else
alSetError(AL_INVALID_ENUM);
}
else
alSetError(AL_INVALID_NAME);
@ -384,4 +610,22 @@ ALvoid ReleaseALEffects(ALvoid)
static void InitEffectParams(ALeffect *effect, ALenum type)
{
effect->type = type;
switch(type)
{
case AL_EFFECT_REVERB:
effect->Reverb.Density = 1.0f;
effect->Reverb.Diffusion = 1.0f;
effect->Reverb.Gain = 0.32f;
effect->Reverb.GainHF = 0.89f;
effect->Reverb.DecayTime = 1.49f;
effect->Reverb.DecayHFRatio = 0.83f;
effect->Reverb.ReflectionsGain = 0.05f;
effect->Reverb.ReflectionsDelay = 0.007f;
effect->Reverb.LateReverbGain = 1.26f;
effect->Reverb.LateReverbDelay = 0.011f;
effect->Reverb.AirAbsorptionGainHF = 0.994f;
effect->Reverb.RoomRolloffFactor = 0.0f;
effect->Reverb.DecayHFLimit = AL_TRUE;
break;
}
}