Merge pull request #2281 from marauder2k7/OpenALDevBuildBranch

OpenALEffects
This commit is contained in:
Areloch 2019-03-30 14:39:06 -05:00 committed by GitHub
commit 33f8a75529
11 changed files with 1982 additions and 1233 deletions

View file

@ -36,6 +36,8 @@
#else #else
# include <al/al.h> # include <al/al.h>
# include <al/alc.h> # include <al/alc.h>
# include <AL/alext.h>
# include <AL/efx-presets.h>
#endif #endif
#ifndef ALAPIENTRY #ifndef ALAPIENTRY
@ -134,6 +136,31 @@ typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, con
typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname );
typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param );
typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest );
///Changes for effects
typedef void (ALAPIENTRY *LPALGENEFFECTS)(ALsizei n, ALuint *effects);
typedef void (ALAPIENTRY *LPALDELETEEFFECTS)(ALsizei n, const ALuint *effects);
typedef ALboolean (ALAPIENTRY *LPALISEFFECT)(ALuint effect);
typedef void (ALAPIENTRY *LPALEFFECTI)(ALuint effect, ALenum param, ALint value);
typedef void (ALAPIENTRY *LPALEFFECTIV)(ALuint effect, ALenum param, const ALint *values);
typedef void (ALAPIENTRY *LPALEFFECTF)(ALuint effect, ALenum param, ALfloat value);
typedef void (ALAPIENTRY *LPALEFFECTFV)(ALuint effect, ALenum param, const ALfloat *values);
typedef void (ALAPIENTRY *LPALGETEFFECTI)(ALuint effect, ALenum param, ALint *value);
typedef void (ALAPIENTRY *LPALGETEFFECTIV)(ALuint effect, ALenum param, ALint *values);
typedef void (ALAPIENTRY *LPALGETEFFECTF)(ALuint effect, ALenum param, ALfloat *value);
typedef void (ALAPIENTRY *LPALGETEFFECTFV)(ALuint effect, ALenum param, ALfloat *values);
typedef void (ALAPIENTRY *LPALRELEASEALEFFECTS)(ALCdevice *device);
typedef void (ALAPIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei n, ALuint *effectslots);
typedef void (ALAPIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei n, const ALuint *effectslots);
typedef ALboolean (ALAPIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint effectslot);
typedef void (ALAPIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint effectslot, ALenum param, ALint value);
typedef void (ALAPIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint effectslot, ALenum param, const ALint *values);
typedef void (ALAPIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint effectslot, ALenum param, ALfloat value);
typedef void (ALAPIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint effectslot, ALenum param, const ALfloat *values);
typedef void (ALAPIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint effectslot, ALenum param, ALint *value);
typedef void (ALAPIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint effectslot, ALenum param, ALint *values);
typedef void (ALAPIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint effectslot, ALenum param, ALfloat *value);
typedef void (ALAPIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint effectslot, ALenum param, ALfloat *values);
typedef void (ALAPIENTRY *LPALSOURCE3I)(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3);
typedef struct typedef struct
{ {
@ -166,6 +193,7 @@ typedef struct
LPALISSOURCE alIsSource; LPALISSOURCE alIsSource;
LPALSOURCEI alSourcei; LPALSOURCEI alSourcei;
LPALSOURCEF alSourcef; LPALSOURCEF alSourcef;
LPALSOURCE3I alSource3i;
LPALSOURCE3F alSource3f; LPALSOURCE3F alSource3f;
LPALSOURCEFV alSourcefv; LPALSOURCEFV alSourcefv;
LPALGETSOURCEI alGetSourcei; LPALGETSOURCEI alGetSourcei;
@ -203,6 +231,29 @@ typedef struct
LPALCISEXTENSIONPRESENT alcIsExtensionPresent; LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
LPALCGETPROCADDRESS alcGetProcAddress; LPALCGETPROCADDRESS alcGetProcAddress;
LPALCGETENUMVALUE alcGetEnumValue; LPALCGETENUMVALUE alcGetEnumValue;
LPALGENEFFECTS alGenEffects;
LPALDELETEEFFECTS alDeleteEffects;
LPALISEFFECT alIsEffect;
LPALEFFECTI alEffecti;
LPALEFFECTIV alEffectiv;
LPALEFFECTF alEffectf;
LPALEFFECTFV alEffectfv;
LPALGETEFFECTI alGetEffecti;
LPALGETEFFECTIV alGetEffectiv;
LPALGETEFFECTF alGetEffectf;
LPALGETEFFECTFV alGetEffectfv;
LPALRELEASEALEFFECTS alReleaseEffects;
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots;
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv;
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv;
LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti;
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
} OPENALFNTABLE, *LPOPENALFNTABLE; } OPENALFNTABLE, *LPOPENALFNTABLE;
#endif #endif

View file

@ -42,16 +42,21 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
// TODO: The OpenAL device doesn't set the primary buffer // TODO: The OpenAL device doesn't set the primary buffer
// $pref::SFX::frequency or $pref::SFX::bitrate! // $pref::SFX::frequency or $pref::SFX::bitrate!
//check auxiliary device sends 4 and add them to the device
ALint attribs[4] = { 0 };
ALCint iSends = 0;
attribs[0] = ALC_MAX_AUXILIARY_SENDS;
attribs[1] = 4;
mDevice = mOpenAL.alcOpenDevice( name ); mDevice = mOpenAL.alcOpenDevice( name );
mOpenAL.alcGetError( mDevice ); mOpenAL.alcGetError( mDevice );
if( mDevice ) if( mDevice )
{ {
mContext = mOpenAL.alcCreateContext( mDevice, NULL ); mContext = mOpenAL.alcCreateContext( mDevice, attribs );
if( mContext ) if( mContext )
mOpenAL.alcMakeContextCurrent( mContext ); mOpenAL.alcMakeContextCurrent( mContext );
mOpenAL.alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends);
U32 err = mOpenAL.alcGetError( mDevice ); U32 err = mOpenAL.alcGetError( mDevice );
if( err != ALC_NO_ERROR ) if( err != ALC_NO_ERROR )
@ -78,7 +83,10 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
SFXALDevice::~SFXALDevice() SFXALDevice::~SFXALDevice()
{ {
_releaseAllResources(); _releaseAllResources();
///cleanup our effects
mOpenAL.alDeleteAuxiliaryEffectSlots(4, effectSlot);
mOpenAL.alDeleteEffects(2, effect);
///cleanup of effects ends
mOpenAL.alcMakeContextCurrent( NULL ); mOpenAL.alcMakeContextCurrent( NULL );
mOpenAL.alcDestroyContext( mContext ); mOpenAL.alcDestroyContext( mContext );
mOpenAL.alcCloseDevice( mDevice ); mOpenAL.alcCloseDevice( mDevice );
@ -145,6 +153,9 @@ void SFXALDevice::setListener( U32 index, const SFXListenerProperties& listener
mOpenAL.alListenerfv( AL_POSITION, pos ); mOpenAL.alListenerfv( AL_POSITION, pos );
mOpenAL.alListenerfv( AL_VELOCITY, velocity ); mOpenAL.alListenerfv( AL_VELOCITY, velocity );
mOpenAL.alListenerfv( AL_ORIENTATION, (const F32 *)&tupple[0] ); mOpenAL.alListenerfv( AL_ORIENTATION, (const F32 *)&tupple[0] );
///Pass a unit size to openal, 1.0 assumes 1 meter to 1 game unit.
///Crucial for air absorbtion calculations.
mOpenAL.alListenerf(AL_METERS_PER_UNIT, 1.0f);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -164,6 +175,12 @@ void SFXALDevice::setDistanceModel( SFXDistanceModel model )
if( mUserRolloffFactor != mRolloffFactor ) if( mUserRolloffFactor != mRolloffFactor )
_setRolloffFactor( mUserRolloffFactor ); _setRolloffFactor( mUserRolloffFactor );
break; break;
/// create a case for our exponential distance model
case SFXDistanceModelExponent:
mOpenAL.alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);
if (mUserRolloffFactor != mRolloffFactor)
_setRolloffFactor(mUserRolloffFactor);
break;
default: default:
AssertWarn( false, "SFXALDevice::setDistanceModel - distance model not implemented" ); AssertWarn( false, "SFXALDevice::setDistanceModel - distance model not implemented" );
@ -200,3 +217,109 @@ void SFXALDevice::setRolloffFactor( F32 factor )
mUserRolloffFactor = factor; mUserRolloffFactor = factor;
} }
void SFXALDevice::openSlots()
{
for (uLoop = 0; uLoop < 4; uLoop++)
{
mOpenAL.alGenAuxiliaryEffectSlots(1, &effectSlot[uLoop]);
}
for (uLoop = 0; uLoop < 2; uLoop++)
{
mOpenAL.alGenEffects(1, &effect[uLoop]);
}
///debug string output so we know our slots are open
Platform::outputDebugString("Slots Open");
}
///create reverb effect
void SFXALDevice::setReverb(const SFXReverbProperties& reverb)
{
///output a debug string so we know each time the reverb changes
Platform::outputDebugString("Updated");
///load an efxeaxreverb default and add our values from
///sfxreverbproperties to it
EFXEAXREVERBPROPERTIES prop = EFX_REVERB_PRESET_GENERIC;
prop.flDensity = reverb.flDensity;
prop.flDiffusion = reverb.flDiffusion;
prop.flGain = reverb.flGain;
prop.flGainHF = reverb.flGainHF;
prop.flGainLF = reverb.flGainLF;
prop.flDecayTime = reverb.flDecayTime;
prop.flDecayHFRatio = reverb.flDecayHFRatio;
prop.flDecayLFRatio = reverb.flDecayLFRatio;
prop.flReflectionsGain = reverb.flReflectionsGain;
prop.flReflectionsDelay = reverb.flReflectionsDelay;
prop.flLateReverbGain = reverb.flLateReverbGain;
prop.flLateReverbDelay = reverb.flLateReverbDelay;
prop.flEchoTime = reverb.flEchoTime;
prop.flEchoDepth = reverb.flEchoDepth;
prop.flModulationTime = reverb.flModulationTime;
prop.flModulationDepth = reverb.flModulationDepth;
prop.flAirAbsorptionGainHF = reverb.flAirAbsorptionGainHF;
prop.flHFReference = reverb.flHFReference;
prop.flLFReference = reverb.flLFReference;
prop.flRoomRolloffFactor = reverb.flRoomRolloffFactor;
prop.iDecayHFLimit = reverb.iDecayHFLimit;
if (mOpenAL.alGetEnumValue("AL_EFFECT_EAXREVERB") != 0)
{
/// EAX Reverb is available. Set the EAX effect type
mOpenAL.alEffecti(effect[0], AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
///add our values to the setup of the reverb
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DENSITY, prop.flDensity);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DIFFUSION, prop.flDiffusion);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAIN, prop.flGain);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAINHF, prop.flGainHF);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAINLF, prop.flGainLF);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_TIME, prop.flDecayTime);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_HFRATIO, prop.flDecayHFRatio);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_LFRATIO, prop.flDecayLFRatio);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_REFLECTIONS_GAIN, prop.flReflectionsGain);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_REFLECTIONS_DELAY, prop.flReflectionsDelay);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LATE_REVERB_GAIN, prop.flLateReverbGain);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LATE_REVERB_DELAY, prop.flLateReverbDelay);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ECHO_TIME, prop.flEchoTime);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ECHO_DEPTH, prop.flEchoDepth);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_MODULATION_TIME, prop.flModulationTime);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_MODULATION_DEPTH, prop.flModulationDepth);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_AIR_ABSORPTION_GAINHF, prop.flAirAbsorptionGainHF);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_HFREFERENCE, prop.flHFReference);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LFREFERENCE, prop.flLFReference);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, prop.flRoomRolloffFactor);
mOpenAL.alEffecti(effect[0], AL_EAXREVERB_DECAY_HFLIMIT, prop.iDecayHFLimit);
mOpenAL.alAuxiliaryEffectSloti(1, AL_EFFECTSLOT_EFFECT, effect[0]);
Platform::outputDebugString("eax reverb properties set");
}
else
{
/// No EAX Reverb. Set the standard reverb effect
mOpenAL.alEffecti(effect[0], AL_EFFECT_TYPE, AL_EFFECT_REVERB);
mOpenAL.alEffectf(effect[0], AL_REVERB_DENSITY, prop.flDensity);
mOpenAL.alEffectf(effect[0], AL_REVERB_DIFFUSION, prop.flDiffusion);
mOpenAL.alEffectf(effect[0], AL_REVERB_GAIN, prop.flGain);
mOpenAL.alEffectf(effect[0], AL_REVERB_GAINHF, prop.flGainHF);
mOpenAL.alEffectf(effect[0], AL_REVERB_DECAY_TIME, prop.flDecayTime);
mOpenAL.alEffectf(effect[0], AL_REVERB_DECAY_HFRATIO, prop.flDecayHFRatio);
mOpenAL.alEffectf(effect[0], AL_REVERB_REFLECTIONS_GAIN, prop.flReflectionsGain);
mOpenAL.alEffectf(effect[0], AL_REVERB_REFLECTIONS_DELAY, prop.flReflectionsDelay);
mOpenAL.alEffectf(effect[0], AL_REVERB_LATE_REVERB_GAIN, prop.flLateReverbGain);
mOpenAL.alEffectf(effect[0], AL_REVERB_LATE_REVERB_DELAY, prop.flLateReverbDelay);
mOpenAL.alEffectf(effect[0], AL_REVERB_AIR_ABSORPTION_GAINHF, prop.flAirAbsorptionGainHF);
mOpenAL.alEffectf(effect[0], AL_REVERB_ROOM_ROLLOFF_FACTOR, prop.flRoomRolloffFactor);
mOpenAL.alEffecti(effect[0], AL_REVERB_DECAY_HFLIMIT, prop.iDecayHFLimit);
mOpenAL.alAuxiliaryEffectSloti(1, AL_EFFECTSLOT_EFFECT, effect[0]);
}
}

View file

@ -85,6 +85,15 @@ class SFXALDevice : public SFXDevice
virtual void setDistanceModel( SFXDistanceModel model ); virtual void setDistanceModel( SFXDistanceModel model );
virtual void setDopplerFactor( F32 factor ); virtual void setDopplerFactor( F32 factor );
virtual void setRolloffFactor( F32 factor ); virtual void setRolloffFactor( F32 factor );
//function for openAL to open slots
virtual void openSlots();
//slots
ALuint effectSlot[4] = { 0 };
ALuint effect[2] = { 0 };
ALuint uLoop;
//get values from sfxreverbproperties and pass it to openal device
virtual void setReverb(const SFXReverbProperties& reverb);
virtual void resetReverb() {}
}; };
#endif // _SFXALDEVICE_H_ #endif // _SFXALDEVICE_H_

View file

@ -118,7 +118,8 @@ void SFXALVoice::_play()
#ifdef DEBUG_SPEW #ifdef DEBUG_SPEW
Platform::outputDebugString( "[SFXALVoice] Starting playback" ); Platform::outputDebugString( "[SFXALVoice] Starting playback" );
#endif #endif
//send every voice that plays to the alauxiliary slot that has the reverb
mOpenAL.alSource3i(mSourceName, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL);
mOpenAL.alSourcePlay( mSourceName ); mOpenAL.alSourcePlay( mSourceName );
//WORKAROUND: Adjust play cursor for buggy OAL when resuming playback. Do this after alSourcePlay //WORKAROUND: Adjust play cursor for buggy OAL when resuming playback. Do this after alSourcePlay

View file

@ -439,7 +439,118 @@ ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable
OutputDebugStringA("Failed to retrieve 'alcGetEnumValue' function address\n"); OutputDebugStringA("Failed to retrieve 'alcGetEnumValue' function address\n");
return AL_FALSE; return AL_FALSE;
} }
lpOALFnTable->alGenEffects = (LPALGENEFFECTS)GetProcAddress(g_hOpenALDLL, "alGenEffects");
if (lpOALFnTable->alGenEffects == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGenEffects' function address\n");
}
lpOALFnTable->alEffecti = (LPALEFFECTI)GetProcAddress(g_hOpenALDLL, "alEffecti");
if (lpOALFnTable->alEffecti == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEffecti' function address\n");
}
lpOALFnTable->alEffectiv = (LPALEFFECTIV)GetProcAddress(g_hOpenALDLL, "alEffectiv");
if (lpOALFnTable->alEffectiv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEffectiv' function address\n");
}
lpOALFnTable->alEffectf = (LPALEFFECTF)GetProcAddress(g_hOpenALDLL, "alEffectf");
if (lpOALFnTable->alEffectf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEffectf' function address\n");
}
lpOALFnTable->alEffectfv = (LPALEFFECTFV)GetProcAddress(g_hOpenALDLL, "alEffectfv");
if (lpOALFnTable->alEffectfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEffectfv' function address\n");
}
lpOALFnTable->alGetEffecti = (LPALGETEFFECTI)GetProcAddress(g_hOpenALDLL, "alGetEffecti");
if (lpOALFnTable->alGetEffecti == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEffecti' function address\n");
}
lpOALFnTable->alGetEffectiv = (LPALGETEFFECTIV)GetProcAddress(g_hOpenALDLL, "alGetEffectiv");
if (lpOALFnTable->alGetEffectiv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEffectiv' function address\n");
}
lpOALFnTable->alGetEffectf = (LPALGETEFFECTF)GetProcAddress(g_hOpenALDLL, "alGetEffectf");
if (lpOALFnTable->alGetEffectf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEffectf' function address\n");
}
lpOALFnTable->alGetEffectfv = (LPALGETEFFECTFV)GetProcAddress(g_hOpenALDLL, "alGetEffectfv");
if (lpOALFnTable->alGetEffectfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEffectfv' function address\n");
}
lpOALFnTable->alDeleteEffects = (LPALDELETEEFFECTS)GetProcAddress(g_hOpenALDLL, "alDeleteEffects");
if (lpOALFnTable->alDeleteEffects == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDeleteEffects' function address\n");
}
lpOALFnTable->alIsEffect = (LPALISEFFECT)GetProcAddress(g_hOpenALDLL, "alIsEffect");
if (lpOALFnTable->alIsEffect == NULL)
{
OutputDebugStringA("Failed to retrieve 'alIsEffect' function address\n");
}
lpOALFnTable->alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotf");
if (lpOALFnTable->alAuxiliaryEffectSlotf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotf' function address\n");
}
lpOALFnTable->alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotfv");
if (lpOALFnTable->alAuxiliaryEffectSlotfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotfv' function address\n");
}
lpOALFnTable->alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSloti");
if (lpOALFnTable->alAuxiliaryEffectSloti == NULL)
{
OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSloti' function address\n");
}
lpOALFnTable->alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotiv");
if (lpOALFnTable->alAuxiliaryEffectSlotiv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotiv' function address\n");
}
lpOALFnTable->alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)GetProcAddress(g_hOpenALDLL, "alIsAuxiliaryEffectSlot");
if (lpOALFnTable->alIsAuxiliaryEffectSlot == NULL)
{
OutputDebugStringA("Failed to retrieve 'alIsAuxiliaryEffectSlot' function address\n");
}
lpOALFnTable->alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)GetProcAddress(g_hOpenALDLL, "alGenAuxiliaryEffectSlots");
if (lpOALFnTable->alGenAuxiliaryEffectSlots == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGenAuxiliaryEffectSlots' function address\n");
}
lpOALFnTable->alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)GetProcAddress(g_hOpenALDLL, "alDeleteAuxiliaryEffectSlots");
if (lpOALFnTable->alDeleteAuxiliaryEffectSlots == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDeleteAuxiliaryEffectSlots' function address\n");
}
lpOALFnTable->alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotf");
if (lpOALFnTable->alGetAuxiliaryEffectSlotf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotf' function address\n");
}
lpOALFnTable->alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotfv");
if (lpOALFnTable->alGetAuxiliaryEffectSlotfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotfv' function address\n");
}
lpOALFnTable->alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSloti");
if (lpOALFnTable->alGetAuxiliaryEffectSloti == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSloti' function address\n");
}
lpOALFnTable->alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotiv");
if (lpOALFnTable->alGetAuxiliaryEffectSlotiv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotiv' function address\n");
}
lpOALFnTable->alSource3i = (LPALSOURCE3I)GetProcAddress(g_hOpenALDLL, "alSource3i");
return AL_TRUE; return AL_TRUE;
} }

View file

@ -153,6 +153,7 @@ enum SFXDistanceModel
{ {
SFXDistanceModelLinear, ///< Volume decreases linearly from min to max where it reaches zero. SFXDistanceModelLinear, ///< Volume decreases linearly from min to max where it reaches zero.
SFXDistanceModelLogarithmic, ///< Volume halves every min distance steps starting from min distance; attenuation stops at max distance. SFXDistanceModelLogarithmic, ///< Volume halves every min distance steps starting from min distance; attenuation stops at max distance.
SFXDistanceModelExponent, /// exponential falloff for distance attenuation.
}; };
DefineEnumType( SFXDistanceModel ); DefineEnumType( SFXDistanceModel );
@ -188,6 +189,14 @@ inline F32 SFXDistanceAttenuation( SFXDistanceModel model, F32 minDistance, F32
gain = minDistance / ( minDistance + rolloffFactor * ( distance - minDistance ) ); gain = minDistance / ( minDistance + rolloffFactor * ( distance - minDistance ) );
break; break;
///create exponential distance model
case SFXDistanceModelExponent:
distance = getMax(distance, minDistance);
distance = getMin(distance, maxDistance);
gain = pow((distance / minDistance), (-rolloffFactor));
break;
} }
return ( volume * gain ); return ( volume * gain );
@ -313,96 +322,96 @@ class SFXFormat
/// Reverb environment properties. /// Reverb environment properties.
/// ///
/// @note A given device may not implement all properties. /// @note A given device may not implement all properties.
///restructure our reverbproperties to match openal
class SFXReverbProperties class SFXReverbProperties
{ {
public: public:
typedef void Parent; struct Parent;
F32 mEnvSize; float flDensity;
F32 mEnvDiffusion; float flDiffusion;
S32 mRoom; float flGain;
S32 mRoomHF; float flGainHF;
S32 mRoomLF; float flGainLF;
F32 mDecayTime; float flDecayTime;
F32 mDecayHFRatio; float flDecayHFRatio;
F32 mDecayLFRatio; float flDecayLFRatio;
S32 mReflections; float flReflectionsGain;
F32 mReflectionsDelay; float flReflectionsDelay;
F32 mReflectionsPan[ 3 ]; float flReflectionsPan[3];
S32 mReverb; float flLateReverbGain;
F32 mReverbDelay; float flLateReverbDelay;
F32 mReverbPan[ 3 ]; float flLateReverbPan[3];
F32 mEchoTime; float flEchoTime;
F32 mEchoDepth; float flEchoDepth;
F32 mModulationTime; float flModulationTime;
F32 mModulationDepth; float flModulationDepth;
F32 mAirAbsorptionHF; float flAirAbsorptionGainHF;
F32 mHFReference; float flHFReference;
F32 mLFReference; float flLFReference;
F32 mRoomRolloffFactor; float flRoomRolloffFactor;
F32 mDiffusion; int iDecayHFLimit;
F32 mDensity;
S32 mFlags;
///set our defaults to be the same as no reverb otherwise our reverb
///effects menu sounds
SFXReverbProperties() SFXReverbProperties()
: mEnvSize( 7.5f ),
mEnvDiffusion( 1.0f ),
mRoom( -1000 ),
mRoomHF( -100 ),
mRoomLF( 0 ),
mDecayTime( 1.49f ),
mDecayHFRatio( 0.83f ),
mDecayLFRatio( 1.0f ),
mReflections( -2602 ),
mReflectionsDelay( 0.007f ),
mReverb( 200 ),
mReverbDelay( 0.011f ),
mEchoTime( 0.25f ),
mEchoDepth( 0.0f ),
mModulationTime( 0.25f ),
mModulationDepth( 0.0f ),
mAirAbsorptionHF( -5.0f ),
mHFReference( 5000.0f ),
mLFReference( 250.0f ),
mRoomRolloffFactor( 0.0f ),
mDiffusion( 100.0f ),
mDensity( 100.0f ),
mFlags( 0 )
{ {
mReflectionsPan[ 0 ] = 0.0f; flDensity = 0.0f;
mReflectionsPan[ 1 ] = 0.0f; flDiffusion = 0.0f;
mReflectionsPan[ 2 ] = 0.0f; flGain = 0.0f;
flGainHF = 0.0f;
mReverbPan[ 0 ] = 0.0f; flGainLF = 0.0000f;
mReverbPan[ 1 ] = 0.0f; flDecayTime = 0.0f;
mReverbPan[ 2 ] = 0.0f; flDecayHFRatio = 0.0f;
flDecayLFRatio = 0.0f;
flReflectionsGain = 0.0f;
flReflectionsDelay = 0.0f;
flReflectionsPan[3] = 0.0f;
flLateReverbGain = 0.0f;
flLateReverbDelay = 0.0f;
flLateReverbPan[3] = 0.0f;
flEchoTime = 0.0f;
flEchoDepth = 0.0f;
flModulationTime = 0.0f;
flModulationDepth = 0.0f;
flAirAbsorptionGainHF = 0.0f;
flHFReference = 0.0f;
flLFReference = 0.0f;
flRoomRolloffFactor = 0.0f;
iDecayHFLimit = 0;
} }
void validate() void validate()
{ {
mEnvSize = mClampF( mEnvSize, 1.0f, 100.0f ); flDensity = mClampF(flDensity, 0.0f, 1.0f);
mEnvDiffusion = mClampF( mEnvDiffusion, 0.0f, 1.0f ); flDiffusion = mClampF(flDiffusion, 0.0f, 1.0f);
mRoom = mClamp( mRoom, -10000, 0 ); flGain = mClampF(flGain, 0.0f, 1.0f);
mRoomHF = mClamp( mRoomHF, -10000, 0 ); flGainHF = mClampF(flGainHF, 0.0f, 1.0f);
mRoomLF = mClamp( mRoomLF, -10000, 0 ); flGainLF = mClampF(flGainLF, 0.0f, 1.0f);
mDecayTime = mClampF( mDecayTime, 0.1f, 20.0f ); flDecayTime = mClampF(flDecayTime, 0.1f, 20.0f);
mDecayHFRatio = mClampF( mDecayHFRatio, 0.1f, 2.0f ); flDecayHFRatio = mClampF(flDecayHFRatio, 0.1f, 2.0f);
mDecayLFRatio = mClampF( mDecayLFRatio, 0.1f, 2.0f ); flDecayLFRatio = mClampF(flDecayLFRatio, 0.1f, 2.0f);
mReflections = mClamp( mReflections, -10000, 1000 ); flReflectionsGain = mClampF(flReflectionsGain, 0.0f, 3.16f);
mReflectionsDelay = mClampF( mReflectionsDelay, 0.0f, 0.3f ); flReflectionsDelay = mClampF(flReflectionsDelay, 0.0f, 0.3f);
mReverb = mClamp( mReverb, -10000, 2000 ); flReflectionsPan[0] = mClampF(flReflectionsPan[0], -1.0f, 1.0f);
mReverbDelay = mClampF( mReverbDelay, 0.0f, 0.1f ); flReflectionsPan[1] = mClampF(flReflectionsPan[1], -1.0f, 1.0f);
mEchoTime = mClampF( mEchoTime, 0.075f, 0.25f ); flReflectionsPan[2] = mClampF(flReflectionsPan[2], -1.0f, 1.0f);
mEchoDepth = mClampF( mEchoDepth, 0.0f, 1.0f ); flLateReverbGain = mClampF(flLateReverbGain, 0.0f, 10.0f);
mModulationTime = mClampF( mModulationTime, 0.04f, 4.0f ); flLateReverbDelay = mClampF(flLateReverbDelay, 0.0f, 0.1f);
mModulationDepth = mClampF( mModulationDepth, 0.0f, 1.0f ); flLateReverbPan[0] = mClampF(flLateReverbPan[0], -1.0f, 1.0f);
mAirAbsorptionHF = mClampF( mAirAbsorptionHF, -100.0f, 0.0f ); flLateReverbPan[1] = mClampF(flLateReverbPan[1], -1.0f, 1.0f);
mHFReference = mClampF( mHFReference, 1000.0f, 20000.0f ); flLateReverbPan[2] = mClampF(flLateReverbPan[2], -1.0f, 1.0f);
mLFReference = mClampF( mLFReference, 20.0f, 1000.0f ); flEchoTime = mClampF(flEchoTime, 0.075f, 0.25f);
mRoomRolloffFactor = mClampF( mRoomRolloffFactor, 0.0f, 10.0f ); flEchoDepth = mClampF(flEchoDepth, 0.0f, 1.0f);
mDiffusion = mClampF( mDiffusion, 0.0f, 100.0f ); flModulationTime = mClampF(flModulationTime, 0.04f, 4.0f);
mDensity = mClampF( mDensity, 0.0f, 100.0f ); flModulationDepth = mClampF(flModulationDepth, 0.0f, 1.0f);
flAirAbsorptionGainHF = mClampF(flAirAbsorptionGainHF, 0.892f, 1.0f);
flHFReference = mClampF(flHFReference, 1000.0f, 20000.0f);
flLFReference = mClampF(flLFReference, 20.0f, 1000.0f);
flRoomRolloffFactor = mClampF(flRoomRolloffFactor, 0.0f, 10.0f);
iDecayHFLimit = mClampF(iDecayHFLimit, 0, 1);
} }
}; };
@ -415,72 +424,98 @@ class SFXReverbProperties
/// Sound reverb properties. /// Sound reverb properties.
/// ///
/// @note A given SFX device may not implement all properties. /// @note A given SFX device may not implement all properties.
///not in use by openal yet if u are going to use ambient reverb zones its
///probably best to not have reverb on the sound effect itself.
class SFXSoundReverbProperties class SFXSoundReverbProperties
{ {
public: public:
typedef void Parent; typedef void Parent;
S32 mDirect; float flDensity;
S32 mDirectHF; float flDiffusion;
S32 mRoom; float flGain;
S32 mRoomHF; float flGainHF;
S32 mObstruction; float flGainLF;
F32 mObstructionLFRatio; float flDecayTime;
S32 mOcclusion; float flDecayHFRatio;
F32 mOcclusionLFRatio; float flDecayLFRatio;
F32 mOcclusionRoomRatio; float flReflectionsGain;
F32 mOcclusionDirectRatio; float flReflectionsDelay;
S32 mExclusion; float flReflectionsPan[3];
F32 mExclusionLFRatio; float flLateReverbGain;
S32 mOutsideVolumeHF; float flLateReverbDelay;
F32 mDopplerFactor; float flLateReverbPan[3];
F32 mRolloffFactor; float flEchoTime;
F32 mRoomRolloffFactor; float flEchoDepth;
F32 mAirAbsorptionFactor; float flModulationTime;
S32 mFlags; float flModulationDepth;
float flAirAbsorptionGainHF;
float flHFReference;
float flLFReference;
float flRoomRolloffFactor;
int iDecayHFLimit;
///Set our defaults to have no reverb
///if you are going to use zone reverbs its
///probably best not to use per-voice reverb
SFXSoundReverbProperties() SFXSoundReverbProperties()
: mDirect( 0 ),
mDirectHF( 0 ),
mRoom( 0 ),
mRoomHF( 0 ),
mObstruction( 0 ),
mObstructionLFRatio( 0.0f ),
mOcclusion( 0 ),
mOcclusionLFRatio( 0.25f ),
mOcclusionRoomRatio( 1.5f ),
mOcclusionDirectRatio( 1.0f ),
mExclusion( 0 ),
mExclusionLFRatio( 1.0f ),
mOutsideVolumeHF( 0 ),
mDopplerFactor( 0.0f ),
mRolloffFactor( 0.0f ),
mRoomRolloffFactor( 0.0f ),
mAirAbsorptionFactor( 1.0f ),
mFlags( 0 )
{ {
flDensity = 0.0f;
flDiffusion = 0.0f;
flGain = 0.0f;
flGainHF = 0.0f;
flGainLF = 0.0000f;
flDecayTime = 0.0f;
flDecayHFRatio = 0.0f;
flDecayLFRatio = 0.0f;
flReflectionsGain = 0.0f;
flReflectionsDelay = 0.0f;
flReflectionsPan[3] = 0.0f;
flLateReverbGain = 0.0f;
flLateReverbDelay = 0.0f;
flLateReverbPan[3] = 0.0f;
flEchoTime = 0.0f;
flEchoDepth = 0.0f;
flModulationTime = 0.0f;
flModulationDepth = 0.0f;
flAirAbsorptionGainHF = 0.0f;
flHFReference = 0.0f;
flLFReference = 0.0f;
flRoomRolloffFactor = 0.0f;
iDecayHFLimit = 0;
} }
void validate() void validate()
{ {
mDirect = mClamp( mDirect, -10000, 1000 ); flDensity = mClampF(flDensity, 0.0f, 1.0f);
mDirectHF = mClamp( mDirectHF, -10000, 0 ); flDiffusion = mClampF(flDiffusion, 0.0f, 1.0f);
mRoom = mClamp( mRoom, -10000, 1000 ); flGain = mClampF(flGain, 0.0f, 1.0f);
mRoomHF = mClamp( mRoomHF, -10000, 0 ); flGainHF = mClampF(flGainHF, 0.0f, 1.0f);
mObstruction = mClamp( mObstruction, -10000, 0 ); flGainLF = mClampF(flGainLF, 0.0f, 1.0f);
mObstructionLFRatio = mClampF( mObstructionLFRatio, 0.0f, 1.0f ); flDecayTime = mClampF(flDecayTime, 0.1f, 20.0f);
mOcclusion = mClamp( mOcclusion, -10000, 0 ); flDecayHFRatio = mClampF(flDecayHFRatio, 0.1f, 2.0f);
mOcclusionLFRatio = mClampF( mOcclusionLFRatio, 0.0f, 1.0f ); flDecayLFRatio = mClampF(flDecayLFRatio, 0.1f, 2.0f);
mOcclusionRoomRatio = mClampF( mOcclusionRoomRatio, 0.0f, 10.0f ); flReflectionsGain = mClampF(flReflectionsGain, 0.0f, 3.16f);
mOcclusionDirectRatio= mClampF( mOcclusionDirectRatio, 0.0f, 10.0f ); flReflectionsDelay = mClampF(flReflectionsDelay, 0.0f, 0.3f);
mExclusion = mClamp( mExclusion, -10000, 0 ); flReflectionsPan[0] = mClampF(flReflectionsPan[0], -1.0f, 1.0f);
mExclusionLFRatio = mClampF( mExclusionLFRatio, 0.0f, 1.0f ); flReflectionsPan[1] = mClampF(flReflectionsPan[1], -1.0f, 1.0f);
mOutsideVolumeHF = mClamp( mOutsideVolumeHF, -10000, 0 ); flReflectionsPan[2] = mClampF(flReflectionsPan[2], -1.0f, 1.0f);
mDopplerFactor = mClampF( mDopplerFactor, 0.0f, 10.0f ); flLateReverbGain = mClampF(flLateReverbGain, 0.0f, 10.0f);
mRolloffFactor = mClampF( mRolloffFactor, 0.0f, 10.0f ); flLateReverbDelay = mClampF(flLateReverbDelay, 0.0f, 0.1f);
mRoomRolloffFactor = mClampF( mRoomRolloffFactor, 0.0f, 10.0f ); flLateReverbPan[0] = mClampF(flLateReverbPan[0], -1.0f, 1.0f);
mAirAbsorptionFactor = mClampF( mAirAbsorptionFactor, 0.0f, 10.0f ); flLateReverbPan[1] = mClampF(flLateReverbPan[1], -1.0f, 1.0f);
flLateReverbPan[2] = mClampF(flLateReverbPan[2], -1.0f, 1.0f);
flEchoTime = mClampF(flEchoTime, 0.075f, 0.25f);
flEchoDepth = mClampF(flEchoDepth, 0.0f, 1.0f);
flModulationTime = mClampF(flModulationTime, 0.04f, 4.0f);
flModulationDepth = mClampF(flModulationDepth, 0.0f, 1.0f);
flAirAbsorptionGainHF = mClampF(flAirAbsorptionGainHF, 0.892f, 1.0f);
flHFReference = mClampF(flHFReference, 1000.0f, 20000.0f);
flLFReference = mClampF(flLFReference, 20.0f, 1000.0f);
flRoomRolloffFactor = mClampF(flRoomRolloffFactor, 0.0f, 10.0f);
iDecayHFLimit = mClampF(iDecayHFLimit, 0, 1);
} }
}; };

View file

@ -395,84 +395,48 @@ void SFXDescription::initPersistFields()
"a custom reverb setup can be defined using the \"Reverb\" properties that will then be assigned " "a custom reverb setup can be defined using the \"Reverb\" properties that will then be assigned "
"to sounds playing with the description.\n\n" "to sounds playing with the description.\n\n"
"@ref SFX_reverb"); "@ref SFX_reverb");
addField( "reverbDirect", TypeS32, Offset( mReverb.mDirect, SFXDescription ), addField("reverbDensity", TypeF32, Offset(mReverb.flDensity, SFXDescription),
"Direct path level (at low and mid frequencies).\n" "Density of reverb environment.");
"@note SUPPORTED: EAX/I3DL2/FMODSFX\n\n" addField("reverbDiffusion", TypeF32, Offset(mReverb.flDiffusion, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "Environment diffusion.");
addField( "reverbDirectHF", TypeS32, Offset( mReverb.mDirectHF, SFXDescription ), addField("reverbGain", TypeF32, Offset(mReverb.flGain, SFXDescription),
"Relative direct path level at high frequencies.\n" "Reverb Gain Level.");
"@note SUPPORTED: EAX/I3DL2\n\n" addField("reverbGainHF", TypeF32, Offset(mReverb.flGainHF, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "Reverb Gain to high frequencies");
addField( "reverbRoom", TypeS32, Offset( mReverb.mRoom, SFXDescription ), addField("reverbGainLF", TypeF32, Offset(mReverb.flGainLF, SFXDescription),
"Room effect level (at low and mid frequencies).\n" "Reverb Gain to high frequencies");
"@note SUPPORTED: EAX/I3DL2/FMODSFX\n\n" addField("reverbDecayTime", TypeF32, Offset(mReverb.flDecayTime, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "Decay time for the reverb.");
addField( "reverbRoomHF", TypeS32, Offset( mReverb.mRoomHF, SFXDescription ), addField("reverbDecayHFRatio", TypeF32, Offset(mReverb.flDecayHFRatio, SFXDescription),
"Relative room effect level at high frequencies.\n" "High frequency decay time ratio.");
"@note SUPPORTED: EAX/I3DL2\n\n" addField("reverbDecayLFRatio", TypeF32, Offset(mReverb.flDecayLFRatio, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "High frequency decay time ratio.");
addField( "reverbObstruction", TypeS32, Offset( mReverb.mObstruction, SFXDescription ), addField("reflectionsGain", TypeF32, Offset(mReverb.flReflectionsGain, SFXDescription),
"Main obstruction control (attenuation at high frequencies).\n" "Reflection Gain.");
"@note SUPPORTED: EAX/I3DL2\n\n" addField("reflectionDelay", TypeF32, Offset(mReverb.flReflectionsDelay, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "How long to delay reflections.");
addField( "reverbObstructionLFRatio", TypeF32, Offset( mReverb.mObstructionLFRatio, SFXDescription ), addField("lateReverbGain", TypeF32, Offset(mReverb.flLateReverbGain, SFXDescription),
"Obstruction low-frequency level re. main control.\n" "Late reverb gain amount.");
"@note SUPPORTED: EAX/I3DL2\n\n" addField("lateReverbDelay", TypeF32, Offset(mReverb.flLateReverbDelay, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "Late reverb delay time.");
addField( "reverbOcclusion", TypeS32, Offset( mReverb.mOcclusion, SFXDescription ), addField("reverbEchoTime", TypeF32, Offset(mReverb.flEchoTime, SFXDescription),
"Main occlusion control (attenuation at high frequencies)." "Reverb echo time.");
"@note SUPPORTED: EAX/I3DL2\n\n" addField("reverbEchoDepth", TypeF32, Offset(mReverb.flEchoDepth, SFXDescription),
"\n@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "Reverb echo depth.");
addField( "reverbOcclusionLFRatio", TypeF32, Offset( mReverb.mOcclusionLFRatio, SFXDescription ), addField("reverbModTime", TypeF32, Offset(mReverb.flModulationTime, SFXDescription),
"Occlusion low-frequency level re. main control.\n" "Reverb Modulation time.");
"@note SUPPORTED: EAX/I3DL2\n\n" addField("reverbModTime", TypeF32, Offset(mReverb.flModulationDepth, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "Reverb Modulation time.");
addField( "reverbOcclusionRoomRatio", TypeF32, Offset( mReverb.mOcclusionRoomRatio, SFXDescription ), addField("airAbsorbtionGainHF", TypeF32, Offset(mReverb.flAirAbsorptionGainHF, SFXDescription),
"Relative occlusion control for room effect.\n" "High Frequency air absorbtion");
"@note SUPPORTED: EAX Only\n\n" addField("reverbHFRef", TypeF32, Offset(mReverb.flHFReference, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "Reverb High Frequency Reference.");
addField( "reverbOcclusionDirectRatio",TypeF32, Offset( mReverb.mOcclusionDirectRatio, SFXDescription ), addField("reverbLFRef", TypeF32, Offset(mReverb.flLFReference, SFXDescription),
"Relative occlusion control for direct path.\n" "Reverb Low Frequency Reference.");
"@note SUPPORTED: EAX Only\n\n" addField("roomRolloffFactor", TypeF32, Offset(mReverb.flRoomRolloffFactor, SFXDescription),
"@see http://www.atc.creative.com/algorithms/eax20.pdf" ); "Rolloff factor for reverb.");
addField( "reverbExclusion", TypeS32, Offset( mReverb.mExclusion, SFXDescription ), addField("decayHFLimit", TypeS32, Offset(mReverb.iDecayHFLimit, SFXDescription),
"Main exclusion control (attenuation at high frequencies).\n" "High Frequency decay limit.");
"@note SUPPORTED: EAX Only\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbExclusionLFRatio", TypeF32, Offset( mReverb.mExclusionLFRatio, SFXDescription ),
"Exclusion low-frequency level re. main control.\n"
"@note SUPPORTED: EAX Only\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbOutsideVolumeHF", TypeS32, Offset( mReverb.mOutsideVolumeHF, SFXDescription ),
"Outside sound cone level at high frequencies.\n"
"@note SUPPORTED: EAX Only\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbDopplerFactor", TypeF32, Offset( mReverb.mDopplerFactor, SFXDescription ),
"Per-source doppler factor.\n"
"@note SUPPORTED: EAX Only\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbReverbRolloffFactor", TypeF32, Offset( mReverb.mRolloffFactor, SFXDescription ),
"Per-source logarithmic falloff factor.\n"
"@note SUPPORTED: EAX Only\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbRoomRolloffFactor", TypeF32, Offset( mReverb.mRoomRolloffFactor, SFXDescription ),
"Room effect falloff factor.\n"
"@note SUPPORTED: EAX/I3DL2\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbAirAbsorptionFactor", TypeF32, Offset( mReverb.mAirAbsorptionFactor, SFXDescription ),
"Multiplies SFXEnvironment::airAbsorptionHR.\n"
"@note SUPPORTED: EAX Only\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbFlags", TypeS32, Offset( mReverb.mFlags, SFXDescription ),
"Bitfield combination of per-sound reverb flags.\n"
"@see REVERB_DIRECTHFAUTO\n"
"@see REVERB_ROOMAUTO\n"
"@see REVERB_ROOMHFAUTO\n"
"@see REVERB_INSTANCE0\n"
"@see REVERB_INSTANCE1\n"
"@see REVERB_INSTANCE2\n"
"@see REVERB_INSTANCE3\n" );
endGroup("Reverb"); endGroup("Reverb");
Parent::initPersistFields(); Parent::initPersistFields();
@ -570,24 +534,27 @@ void SFXDescription::packData( BitStream *stream )
if( mUseReverb ) if( mUseReverb )
{ {
stream->writeRangedS32( mReverb.mDirect, -10000, 1000 ); stream->write(mReverb.flDensity);
stream->writeRangedS32( mReverb.mDirectHF, -10000, 0 ); stream->write(mReverb.flDiffusion);
stream->writeRangedS32( mReverb.mRoom, -10000, 1000 ); stream->write(mReverb.flGain);
stream->writeRangedS32( mReverb.mRoomHF, -10000, 0 ); stream->write(mReverb.flGainHF);
stream->writeRangedS32( mReverb.mObstruction, -10000, 0 ); stream->write(mReverb.flGainLF);
stream->writeRangedF32( mReverb.mObstructionLFRatio, 0.0, 1.0, 7 ); stream->write(mReverb.flDecayTime);
stream->writeRangedS32( mReverb.mOcclusion, -10000, 0 ); stream->write(mReverb.flDecayHFRatio);
stream->writeRangedF32( mReverb.mOcclusionLFRatio, 0.0, 1.0, 7 ); stream->write(mReverb.flDecayLFRatio);
stream->writeRangedF32( mReverb.mOcclusionRoomRatio, 0.0, 10.0, 7 ); stream->write(mReverb.flReflectionsGain);
stream->writeRangedF32( mReverb.mOcclusionDirectRatio, 0.0, 10.0, 7 ); stream->write(mReverb.flReflectionsDelay);
stream->writeRangedS32( mReverb.mExclusion, -10000, 0 ); stream->write(mReverb.flLateReverbGain);
stream->writeRangedF32( mReverb.mExclusionLFRatio, 0.0, 1.0, 7 ); stream->write(mReverb.flLateReverbDelay);
stream->writeRangedS32( mReverb.mOutsideVolumeHF, -10000, 0 ); stream->write(mReverb.flEchoTime);
stream->writeRangedF32( mReverb.mDopplerFactor, 0.0, 10.0, 7 ); stream->write(mReverb.flEchoDepth);
stream->writeRangedF32( mReverb.mRolloffFactor, 0.0, 10.0, 7 ); stream->write(mReverb.flModulationTime);
stream->writeRangedF32( mReverb.mRoomRolloffFactor, 0.0, 10.0, 7 ); stream->write(mReverb.flModulationDepth);
stream->writeRangedF32( mReverb.mAirAbsorptionFactor, 0.0, 10.0, 7 ); stream->write(mReverb.flAirAbsorptionGainHF);
stream->writeInt( mReverb.mFlags, 6 ); stream->write(mReverb.flHFReference);
stream->write(mReverb.flLFReference);
stream->write(mReverb.flRoomRolloffFactor);
stream->write(mReverb.iDecayHFLimit);
} }
} }
@ -640,24 +607,27 @@ void SFXDescription::unpackData( BitStream *stream )
if( mUseReverb ) if( mUseReverb )
{ {
mReverb.mDirect = stream->readRangedS32( -10000, 1000 ); stream->read(&mReverb.flDensity);
mReverb.mDirectHF = stream->readRangedS32( -10000, 0 ); stream->read(&mReverb.flDiffusion);
mReverb.mRoom = stream->readRangedS32( -10000, 1000 ); stream->read(&mReverb.flGain);
mReverb.mRoomHF = stream->readRangedS32( -10000, 0 ); stream->read(&mReverb.flGainHF);
mReverb.mObstruction = stream->readRangedS32( -10000, 0 ); stream->read(&mReverb.flGainLF);
mReverb.mObstructionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 ); stream->read(&mReverb.flDecayTime);
mReverb.mOcclusion = stream->readRangedS32( -10000, 0 ); stream->read(&mReverb.flDecayHFRatio);
mReverb.mOcclusionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 ); stream->read(&mReverb.flDecayLFRatio);
mReverb.mOcclusionRoomRatio = stream->readRangedF32( 0.0, 10.0, 7 ); stream->read(&mReverb.flReflectionsGain);
mReverb.mOcclusionDirectRatio = stream->readRangedF32( 0.0, 10.0, 7 ); stream->read(&mReverb.flReflectionsDelay);
mReverb.mExclusion = stream->readRangedS32( -10000, 0 ); stream->read(&mReverb.flLateReverbGain);
mReverb.mExclusionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 ); stream->read(&mReverb.flLateReverbDelay);
mReverb.mOutsideVolumeHF = stream->readRangedS32( -10000, 0 ); stream->read(&mReverb.flEchoTime);
mReverb.mDopplerFactor = stream->readRangedF32( 0.0, 10.0, 7 ); stream->read(&mReverb.flEchoDepth);
mReverb.mRolloffFactor = stream->readRangedF32( 0.0, 10.0, 7 ); stream->read(&mReverb.flModulationTime);
mReverb.mRoomRolloffFactor = stream->readRangedF32( 0.0, 10.0, 7 ); stream->read(&mReverb.flModulationDepth);
mReverb.mAirAbsorptionFactor = stream->readRangedF32( 0.0, 10.0, 7 ); stream->read(&mReverb.flAirAbsorptionGainHF);
mReverb.mFlags = stream->readInt( 6 ); stream->read(&mReverb.flHFReference);
stream->read(&mReverb.flLFReference);
stream->read(&mReverb.flRoomRolloffFactor);
stream->read(&mReverb.iDecayHFLimit);
} }
} }

View file

@ -179,6 +179,9 @@ public:
/// Set the rolloff scale factor for distance attenuation of 3D sounds. /// Set the rolloff scale factor for distance attenuation of 3D sounds.
virtual void setRolloffFactor( F32 factor ) {} virtual void setRolloffFactor( F32 factor ) {}
/// send empty function to all sfxdevices
virtual void openSlots() {}
/// Set the global reverb environment. /// Set the global reverb environment.
virtual void setReverb( const SFXReverbProperties& reverb ) {} virtual void setReverb( const SFXReverbProperties& reverb ) {}

View file

@ -144,69 +144,52 @@ void SFXEnvironment::initPersistFields()
{ {
addGroup( "Reverb" ); addGroup( "Reverb" );
addField( "envSize", TypeF32, Offset( mReverb.mEnvSize, SFXEnvironment ), addField("reverbDensity", TypeF32, Offset(mReverb.flDensity, SFXEnvironment),
"Environment size in meters." ); "Density of reverb environment.");
addField( "envDiffusion", TypeF32, Offset( mReverb.mEnvDiffusion, SFXEnvironment ), addField("reverbDiffusion", TypeF32, Offset(mReverb.flDiffusion, SFXEnvironment),
"Environment diffusion."); "Environment diffusion.");
addField( "room", TypeS32, Offset( mReverb.mRoom, SFXEnvironment ), addField("reverbGain", TypeF32, Offset(mReverb.flGain, SFXEnvironment),
"Room effect level at mid-frequencies." ); "Reverb Gain Level.");
addField( "roomHF", TypeS32, Offset( mReverb.mRoomHF, SFXEnvironment ), addField("reverbGainHF", TypeF32, Offset(mReverb.flGainHF, SFXEnvironment),
"Relative room effect level at high frequencies." ); "Reverb Gain to high frequencies");
addField( "roomLF", TypeS32, Offset( mReverb.mRoomLF, SFXEnvironment ), addField("reverbGainLF", TypeF32, Offset(mReverb.flGainLF, SFXEnvironment),
"Relative room effect level at low frequencies." ); "Reverb Gain to high frequencies");
addField( "decayTime", TypeF32, Offset( mReverb.mDecayTime, SFXEnvironment ), addField("reverbDecayTime", TypeF32, Offset(mReverb.flDecayTime, SFXEnvironment),
"Reverberation decay time at mid frequencies." ); "Decay time for the reverb.");
addField( "decayHFRatio", TypeF32, Offset( mReverb.mDecayHFRatio, SFXEnvironment ), addField("reverbDecayHFRatio", TypeF32, Offset(mReverb.flDecayHFRatio, SFXEnvironment),
"High-frequency to mid-frequency decay time ratio." ); "High frequency decay time ratio.");
addField( "decayLFRatio", TypeF32, Offset( mReverb.mDecayLFRatio, SFXEnvironment ), addField("reverbDecayLFRatio", TypeF32, Offset(mReverb.flDecayLFRatio, SFXEnvironment),
"Low-frequency to mid-frequency decay time ratio." ); "High frequency decay time ratio.");
addField( "reflections", TypeS32, Offset( mReverb.mReflections, SFXEnvironment ), addField("reflectionsGain", TypeF32, Offset(mReverb.flReflectionsGain, SFXEnvironment),
"Early reflections level relative to room effect." ); "Reflection Gain.");
addField( "reflectionsDelay", TypeF32, Offset( mReverb.mReflectionsDelay, SFXEnvironment ), addField("reflectionDelay", TypeF32, Offset(mReverb.flReflectionsDelay, SFXEnvironment),
"Initial reflection delay time." ); "How long to delay reflections.");
addField( "reflectionsPan", TypeF32, Offset( mReverb.mReflectionsPan, SFXEnvironment ), 3, addField("reflectionsPan", TypeF32, Offset(mReverb.flReflectionsPan, SFXEnvironment), 3,
"Early reflections panning vector." ); "Reflection reverberation panning vector.");
addField( "reverb", TypeS32, Offset( mReverb.mReverb, SFXEnvironment ), addField("lateReverbGain", TypeF32, Offset(mReverb.flLateReverbGain, SFXEnvironment),
"Late reverberation level relative to room effect." ); "Late reverb gain amount.");
addField( "reverbDelay", TypeF32, Offset( mReverb.mReverbDelay, SFXEnvironment ), addField("lateReverbDelay", TypeF32, Offset(mReverb.flLateReverbDelay, SFXEnvironment),
"Late reverberation delay time relative to initial reflection." ); "Late reverb delay time.");
addField( "reverbPan", TypeF32, Offset( mReverb.mReverbPan, SFXEnvironment ), 3, addField("lateReverbPan", TypeF32, Offset(mReverb.flLateReverbPan, SFXEnvironment), 3,
"Late reverberation panning vector."); "Late reverberation panning vector.");
addField( "echoTime", TypeF32, Offset( mReverb.mEchoTime, SFXEnvironment ), addField("reverbEchoTime", TypeF32, Offset(mReverb.flEchoTime, SFXEnvironment),
"Echo time." ); "Reverb echo time.");
addField( "echoDepth", TypeF32, Offset( mReverb.mEchoDepth, SFXEnvironment ), addField("reverbEchoDepth", TypeF32, Offset(mReverb.flEchoDepth, SFXEnvironment),
"Echo depth." ); "Reverb echo depth.");
addField( "modulationTime", TypeF32, Offset( mReverb.mModulationTime, SFXEnvironment ), addField("reverbModTime", TypeF32, Offset(mReverb.flModulationTime, SFXEnvironment),
"Modulation time." ); "Reverb Modulation time.");
addField( "modulationDepth", TypeF32, Offset( mReverb.mModulationDepth, SFXEnvironment ), addField("reverbModDepth", TypeF32, Offset(mReverb.flModulationDepth, SFXEnvironment),
"Modulation depth." ); "Reverb Modulation time.");
addField( "airAbsorptionHF", TypeF32, Offset( mReverb.mAirAbsorptionHF, SFXEnvironment ), addField("airAbsorbtionGainHF", TypeF32, Offset(mReverb.flAirAbsorptionGainHF, SFXEnvironment),
"Change in level per meter at high frequencies." ); "High Frequency air absorbtion");
addField( "HFReference", TypeF32, Offset( mReverb.mHFReference, SFXEnvironment ), addField("reverbHFRef", TypeF32, Offset(mReverb.flHFReference, SFXEnvironment),
"Reference high frequency in Hertz." ); "Reverb High Frequency Reference.");
addField( "LFReference", TypeF32, Offset( mReverb.mLFReference, SFXEnvironment ), addField("reverbLFRef", TypeF32, Offset(mReverb.flLFReference, SFXEnvironment),
"Reference low frequency in Hertz." ); "Reverb Low Frequency Reference.");
addField( "roomRolloffFactor", TypeF32, Offset( mReverb.mRoomRolloffFactor, SFXEnvironment ), addField("roomRolloffFactor", TypeF32, Offset(mReverb.flRoomRolloffFactor, SFXEnvironment),
"Logarithmic distance attenuation rolloff scale factor for reverb room size effect." ); "Rolloff factor for reverb.");
addField( "diffusion", TypeF32, Offset( mReverb.mDiffusion, SFXEnvironment ), addField("decayHFLimit", TypeS32, Offset(mReverb.iDecayHFLimit, SFXEnvironment),
"Value that controls the echo density in the late reverberation decay." ); "High Frequency decay limit.");
addField( "density", TypeF32, Offset( mReverb.mDensity, SFXEnvironment ),
"Value that controls the modal density in the late reverberation decay." );
addField( "flags", TypeS32, Offset( mReverb.mFlags, SFXEnvironment ),
"A bitfield of reverb flags.\n"
"@see REVERB_DECAYTIMESCALE\n"
"@see REVERB_REFLECTIONSSCALE\n"
"@see REVERB_REFLECTIONSDELAYSCALE\n"
"@see REVERB_REVERBSCALE\n"
"@see REVERB_REVERBDELAYSCALE\n"
"@see REVERB_DECAYHFLIMIT\n"
"@see REVERB_ECHOTIMESCALE\n"
"@see REVERB_MODULATIONTIMESCALE\n"
"@see REVERB_CORE0\n"
"@see REVERB_CORE1\n"
"@see REVERB_HIGHQUALITYREVERB\n"
"@see REVERB_HIGHQUALITYDPL2REVERB\n" );
endGroup("Reverb"); endGroup("Reverb");
Parent::initPersistFields(); Parent::initPersistFields();
@ -257,35 +240,27 @@ void SFXEnvironment::packData( BitStream* stream )
{ {
Parent::packData( stream ); Parent::packData( stream );
stream->write( mReverb.mEnvSize ); stream->write(mReverb.flDensity);
stream->write( mReverb.mEnvDiffusion ); stream->write(mReverb.flDiffusion);
stream->write( mReverb.mRoom ); stream->write(mReverb.flGain);
stream->write( mReverb.mRoomHF ); stream->write(mReverb.flGainHF);
stream->write( mReverb.mRoomLF ); stream->write(mReverb.flGainLF);
stream->write( mReverb.mDecayTime ); stream->write(mReverb.flDecayTime);
stream->write( mReverb.mDecayHFRatio ); stream->write(mReverb.flDecayHFRatio);
stream->write( mReverb.mDecayLFRatio ); stream->write(mReverb.flDecayLFRatio);
stream->write( mReverb.mReflections ); stream->write(mReverb.flReflectionsGain);
stream->write( mReverb.mReflectionsDelay ); stream->write(mReverb.flReflectionsDelay);
stream->write( mReverb.mReflectionsPan[ 0 ] ); stream->write(mReverb.flLateReverbGain);
stream->write( mReverb.mReflectionsPan[ 1 ] ); stream->write(mReverb.flLateReverbDelay);
stream->write( mReverb.mReflectionsPan[ 2 ] ); stream->write(mReverb.flEchoTime);
stream->write( mReverb.mReverb ); stream->write(mReverb.flEchoDepth);
stream->write( mReverb.mReverbDelay ); stream->write(mReverb.flModulationTime);
stream->write( mReverb.mReverbPan[ 0 ] ); stream->write(mReverb.flModulationDepth);
stream->write( mReverb.mReverbPan[ 1 ] ); stream->write(mReverb.flAirAbsorptionGainHF);
stream->write( mReverb.mReverbPan[ 2 ] ); stream->write(mReverb.flHFReference);
stream->write( mReverb.mEchoTime ); stream->write(mReverb.flLFReference);
stream->write( mReverb.mEchoDepth ); stream->write(mReverb.flRoomRolloffFactor);
stream->write( mReverb.mModulationTime ); stream->write(mReverb.iDecayHFLimit);
stream->write( mReverb.mModulationDepth );
stream->write( mReverb.mAirAbsorptionHF );
stream->write( mReverb.mHFReference );
stream->write( mReverb.mLFReference );
stream->write( mReverb.mRoomRolloffFactor );
stream->write( mReverb.mDiffusion );
stream->write( mReverb.mDensity );
stream->write( mReverb.mFlags );
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -294,33 +269,25 @@ void SFXEnvironment::unpackData( BitStream* stream )
{ {
Parent::unpackData( stream ); Parent::unpackData( stream );
stream->read( &mReverb.mEnvSize ); stream->read(&mReverb.flDensity);
stream->read( &mReverb.mEnvDiffusion ); stream->read(&mReverb.flDiffusion);
stream->read( &mReverb.mRoom ); stream->read(&mReverb.flGain);
stream->read( &mReverb.mRoomHF ); stream->read(&mReverb.flGainHF);
stream->read( &mReverb.mRoomLF ); stream->read(&mReverb.flGainLF);
stream->read( &mReverb.mDecayTime ); stream->read(&mReverb.flDecayTime);
stream->read( &mReverb.mDecayHFRatio ); stream->read(&mReverb.flDecayHFRatio);
stream->read( &mReverb.mDecayLFRatio ); stream->read(&mReverb.flDecayLFRatio);
stream->read( &mReverb.mReflections ); stream->read(&mReverb.flReflectionsGain);
stream->read( &mReverb.mReflectionsDelay ); stream->read(&mReverb.flReflectionsDelay);
stream->read( &mReverb.mReflectionsPan[ 0 ] ); stream->read(&mReverb.flLateReverbGain);
stream->read( &mReverb.mReflectionsPan[ 1 ] ); stream->read(&mReverb.flLateReverbDelay);
stream->read( &mReverb.mReflectionsPan[ 2 ] ); stream->read(&mReverb.flEchoTime);
stream->read( &mReverb.mReverb ); stream->read(&mReverb.flEchoDepth);
stream->read( &mReverb.mReverbDelay ); stream->read(&mReverb.flModulationTime);
stream->read( &mReverb.mReverbPan[ 0 ] ); stream->read(&mReverb.flModulationDepth);
stream->read( &mReverb.mReverbPan[ 1 ] ); stream->read(&mReverb.flAirAbsorptionGainHF);
stream->read( &mReverb.mReverbPan[ 2 ] ); stream->read(&mReverb.flHFReference);
stream->read( &mReverb.mEchoTime ); stream->read(&mReverb.flLFReference);
stream->read( &mReverb.mEchoDepth ); stream->read(&mReverb.flRoomRolloffFactor);
stream->read( &mReverb.mModulationTime ); stream->read(&mReverb.iDecayHFLimit);
stream->read( &mReverb.mModulationDepth );
stream->read( &mReverb.mAirAbsorptionHF );
stream->read( &mReverb.mHFReference );
stream->read( &mReverb.mLFReference );
stream->read( &mReverb.mRoomRolloffFactor );
stream->read( &mReverb.mDiffusion );
stream->read( &mReverb.mDensity );
stream->read( &mReverb.mFlags );
} }

View file

@ -94,6 +94,9 @@ ImplementEnumType( SFXDistanceModel,
{ SFXDistanceModelLogarithmic, "Logarithmic", { SFXDistanceModelLogarithmic, "Logarithmic",
"Volume attenuates logarithmically starting from the reference distance and halving every reference distance step from there on. " "Volume attenuates logarithmically starting from the reference distance and halving every reference distance step from there on. "
"Attenuation stops at max distance but volume won't reach zero." }, "Attenuation stops at max distance but volume won't reach zero." },
{ SFXDistanceModelExponent, "Exponential",
"Volume attenuates exponentially starting from the reference distance and attenuating every reference distance step by the rolloff factor. "
"Attenuation stops at max distance but volume won't reach zero." },
EndImplementEnumType; EndImplementEnumType;
ImplementEnumType( SFXChannel, ImplementEnumType( SFXChannel,
@ -473,6 +476,9 @@ bool SFXSystem::createDevice( const String& providerName, const String& deviceNa
mDevice->setDistanceModel( mDistanceModel ); mDevice->setDistanceModel( mDistanceModel );
mDevice->setDopplerFactor( mDopplerFactor ); mDevice->setDopplerFactor( mDopplerFactor );
mDevice->setRolloffFactor( mRolloffFactor ); mDevice->setRolloffFactor( mRolloffFactor );
//OpenAL requires slots for effects, this creates an empty function
//that will run when a sfxdevice is created.
mDevice->openSlots();
mDevice->setReverb( mReverb ); mDevice->setReverb( mReverb );
// Signal system. // Signal system.

File diff suppressed because it is too large Load diff