From 37b17c8c783aba13d5c5f16e40632945126180a9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 19 Jan 2012 20:02:57 -0800 Subject: Add the ability to specify a preset for forced reverb --- OpenAL32/Include/alEffect.h | 2 +- OpenAL32/alEffect.c | 80 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 2 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h index 264ada0d..97def48a 100644 --- a/OpenAL32/Include/alEffect.h +++ b/OpenAL32/Include/alEffect.h @@ -102,7 +102,7 @@ typedef struct ALeffect static __inline ALboolean IsReverbEffect(ALenum type) { return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; } -ALvoid GetReverbEffect(ALeffect *effect); +ALvoid GetReverbEffect(const char *name, ALeffect *effect); ALvoid ReleaseALEffects(ALCdevice *device); #ifdef __cplusplus diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index d7f7c3c1..99127fac 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -1308,7 +1308,85 @@ static void InitEffectParams(ALeffect *effect, ALenum type) } -ALvoid GetReverbEffect(ALeffect *effect) +#include "AL/efx-presets.h" + +#define DECL(x) { #x, EFX_REVERB_PRESET_##x } +static const struct { + const char name[32]; + EFXEAXREVERBPROPERTIES props; +} reverblist[] = { + DECL(GENERIC), + DECL(PADDEDCELL), + DECL(ROOM), + DECL(BATHROOM), + DECL(LIVINGROOM), + DECL(STONEROOM), + DECL(AUDITORIUM), + DECL(CONCERTHALL), + DECL(CAVE), + DECL(ARENA), + DECL(HANGAR), + DECL(CARPETTEDHALLWAY), + DECL(HALLWAY), + DECL(STONECORRIDOR), + DECL(ALLEY), + DECL(FOREST), + DECL(CITY), + DECL(MOUNTAINS), + DECL(QUARRY), + DECL(PLAIN), + DECL(PARKINGLOT), + DECL(SEWERPIPE), + DECL(UNDERWATER), + DECL(DRUGGED), + DECL(DIZZY), + DECL(PSYCHOTIC), + { "", EFX_REVERB_PRESET_GENERIC } +}; + +ALvoid GetReverbEffect(const char *name, ALeffect *effect) { + int i; + InitEffectParams(effect, AL_EFFECT_EAXREVERB); + for(i = 0;reverblist[i].name[0];i++) + { + const EFXEAXREVERBPROPERTIES *props; + + if(strcasecmp(name, reverblist[i].name) != 0) + continue; + + TRACE("Loading reverb '%s'\n", reverblist[i].name); + props = &reverblist[i].props; + effect->Reverb.Density = props->flDensity; + effect->Reverb.Diffusion = props->flDiffusion; + effect->Reverb.Gain = props->flGain; + effect->Reverb.GainHF = props->flGainHF; + effect->Reverb.GainLF = props->flGainLF; + effect->Reverb.DecayTime = props->flDecayTime; + effect->Reverb.DecayHFRatio = props->flDecayHFRatio; + effect->Reverb.DecayLFRatio = props->flDecayLFRatio; + effect->Reverb.ReflectionsGain = props->flReflectionsGain; + effect->Reverb.ReflectionsDelay = props->flReflectionsDelay; + effect->Reverb.ReflectionsPan[0] = props->flReflectionsPan[0]; + effect->Reverb.ReflectionsPan[1] = props->flReflectionsPan[1]; + effect->Reverb.ReflectionsPan[2] = props->flReflectionsPan[2]; + effect->Reverb.LateReverbGain = props->flLateReverbGain; + effect->Reverb.LateReverbDelay = props->flLateReverbDelay; + effect->Reverb.LateReverbPan[0] = props->flLateReverbPan[0]; + effect->Reverb.LateReverbPan[1] = props->flLateReverbPan[1]; + effect->Reverb.LateReverbPan[2] = props->flLateReverbPan[2]; + effect->Reverb.EchoTime = props->flEchoTime; + effect->Reverb.EchoDepth = props->flEchoDepth; + effect->Reverb.ModulationTime = props->flModulationTime; + effect->Reverb.ModulationDepth = props->flModulationDepth; + effect->Reverb.AirAbsorptionGainHF = props->flAirAbsorptionGainHF; + effect->Reverb.HFReference = props->flHFReference; + effect->Reverb.LFReference = props->flLFReference; + effect->Reverb.RoomRolloffFactor = props->flRoomRolloffFactor; + effect->Reverb.DecayHFLimit = props->iDecayHFLimit; + break; + } + if(!reverblist[i].name[0]) + WARN("Reverb preset '%s' not found\n", name); } -- cgit v1.2.3