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
# include <al/al.h>
# include <al/alc.h>
# include <AL/alext.h>
# include <AL/efx-presets.h>
#endif
#ifndef ALAPIENTRY
@ -134,6 +136,31 @@ typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, con
typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname );
typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param );
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
{
@ -166,6 +193,7 @@ typedef struct
LPALISSOURCE alIsSource;
LPALSOURCEI alSourcei;
LPALSOURCEF alSourcef;
LPALSOURCE3I alSource3i;
LPALSOURCE3F alSource3f;
LPALSOURCEFV alSourcefv;
LPALGETSOURCEI alGetSourcei;
@ -203,6 +231,29 @@ typedef struct
LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
LPALCGETPROCADDRESS alcGetProcAddress;
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;
#endif

View file

@ -42,16 +42,21 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
// TODO: The OpenAL device doesn't set the primary buffer
// $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 );
mOpenAL.alcGetError( mDevice );
if( mDevice )
{
mContext = mOpenAL.alcCreateContext( mDevice, NULL );
mContext = mOpenAL.alcCreateContext( mDevice, attribs );
if( mContext )
mOpenAL.alcMakeContextCurrent( mContext );
mOpenAL.alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends);
U32 err = mOpenAL.alcGetError( mDevice );
if( err != ALC_NO_ERROR )
@ -78,7 +83,10 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
SFXALDevice::~SFXALDevice()
{
_releaseAllResources();
///cleanup our effects
mOpenAL.alDeleteAuxiliaryEffectSlots(4, effectSlot);
mOpenAL.alDeleteEffects(2, effect);
///cleanup of effects ends
mOpenAL.alcMakeContextCurrent( NULL );
mOpenAL.alcDestroyContext( mContext );
mOpenAL.alcCloseDevice( mDevice );
@ -145,6 +153,9 @@ void SFXALDevice::setListener( U32 index, const SFXListenerProperties& listener
mOpenAL.alListenerfv( AL_POSITION, pos );
mOpenAL.alListenerfv( AL_VELOCITY, velocity );
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,7 +175,13 @@ void SFXALDevice::setDistanceModel( SFXDistanceModel model )
if( mUserRolloffFactor != mRolloffFactor )
_setRolloffFactor( mUserRolloffFactor );
break;
/// create a case for our exponential distance model
case SFXDistanceModelExponent:
mOpenAL.alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);
if (mUserRolloffFactor != mRolloffFactor)
_setRolloffFactor(mUserRolloffFactor);
break;
default:
AssertWarn( false, "SFXALDevice::setDistanceModel - distance model not implemented" );
}
@ -200,3 +217,109 @@ void SFXALDevice::setRolloffFactor( F32 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 setDopplerFactor( 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_

View file

@ -118,7 +118,8 @@ void SFXALVoice::_play()
#ifdef DEBUG_SPEW
Platform::outputDebugString( "[SFXALVoice] Starting playback" );
#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 );
//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");
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;
}

View file

@ -153,6 +153,7 @@ enum SFXDistanceModel
{
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.
SFXDistanceModelExponent, /// exponential falloff for distance attenuation.
};
DefineEnumType( SFXDistanceModel );
@ -187,6 +188,14 @@ inline F32 SFXDistanceAttenuation( SFXDistanceModel model, F32 minDistance, F32
gain = minDistance / ( minDistance + rolloffFactor * ( distance - minDistance ) );
break;
///create exponential distance model
case SFXDistanceModelExponent:
distance = getMax(distance, minDistance);
distance = getMin(distance, maxDistance);
gain = pow((distance / minDistance), (-rolloffFactor));
break;
}
@ -313,97 +322,97 @@ class SFXFormat
/// Reverb environment properties.
///
/// @note A given device may not implement all properties.
///restructure our reverbproperties to match openal
class SFXReverbProperties
{
public:
typedef void Parent;
F32 mEnvSize;
F32 mEnvDiffusion;
S32 mRoom;
S32 mRoomHF;
S32 mRoomLF;
F32 mDecayTime;
F32 mDecayHFRatio;
F32 mDecayLFRatio;
S32 mReflections;
F32 mReflectionsDelay;
F32 mReflectionsPan[ 3 ];
S32 mReverb;
F32 mReverbDelay;
F32 mReverbPan[ 3 ];
F32 mEchoTime;
F32 mEchoDepth;
F32 mModulationTime;
F32 mModulationDepth;
F32 mAirAbsorptionHF;
F32 mHFReference;
F32 mLFReference;
F32 mRoomRolloffFactor;
F32 mDiffusion;
F32 mDensity;
S32 mFlags;
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;
mReflectionsPan[ 1 ] = 0.0f;
mReflectionsPan[ 2 ] = 0.0f;
mReverbPan[ 0 ] = 0.0f;
mReverbPan[ 1 ] = 0.0f;
mReverbPan[ 2 ] = 0.0f;
}
void validate()
{
mEnvSize = mClampF( mEnvSize, 1.0f, 100.0f );
mEnvDiffusion = mClampF( mEnvDiffusion, 0.0f, 1.0f );
mRoom = mClamp( mRoom, -10000, 0 );
mRoomHF = mClamp( mRoomHF, -10000, 0 );
mRoomLF = mClamp( mRoomLF, -10000, 0 );
mDecayTime = mClampF( mDecayTime, 0.1f, 20.0f );
mDecayHFRatio = mClampF( mDecayHFRatio, 0.1f, 2.0f );
mDecayLFRatio = mClampF( mDecayLFRatio, 0.1f, 2.0f );
mReflections = mClamp( mReflections, -10000, 1000 );
mReflectionsDelay = mClampF( mReflectionsDelay, 0.0f, 0.3f );
mReverb = mClamp( mReverb, -10000, 2000 );
mReverbDelay = mClampF( mReverbDelay, 0.0f, 0.1f );
mEchoTime = mClampF( mEchoTime, 0.075f, 0.25f );
mEchoDepth = mClampF( mEchoDepth, 0.0f, 1.0f );
mModulationTime = mClampF( mModulationTime, 0.04f, 4.0f );
mModulationDepth = mClampF( mModulationDepth, 0.0f, 1.0f );
mAirAbsorptionHF = mClampF( mAirAbsorptionHF, -100.0f, 0.0f );
mHFReference = mClampF( mHFReference, 1000.0f, 20000.0f );
mLFReference = mClampF( mLFReference, 20.0f, 1000.0f );
mRoomRolloffFactor = mClampF( mRoomRolloffFactor, 0.0f, 10.0f );
mDiffusion = mClampF( mDiffusion, 0.0f, 100.0f );
mDensity = mClampF( mDensity, 0.0f, 100.0f );
}
public:
struct Parent;
float flDensity;
float flDiffusion;
float flGain;
float flGainHF;
float flGainLF;
float flDecayTime;
float flDecayHFRatio;
float flDecayLFRatio;
float flReflectionsGain;
float flReflectionsDelay;
float flReflectionsPan[3];
float flLateReverbGain;
float flLateReverbDelay;
float flLateReverbPan[3];
float flEchoTime;
float flEchoDepth;
float flModulationTime;
float flModulationDepth;
float flAirAbsorptionGainHF;
float flHFReference;
float flLFReference;
float flRoomRolloffFactor;
int iDecayHFLimit;
///set our defaults to be the same as no reverb otherwise our reverb
///effects menu sounds
SFXReverbProperties()
{
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()
{
flDensity = mClampF(flDensity, 0.0f, 1.0f);
flDiffusion = mClampF(flDiffusion, 0.0f, 1.0f);
flGain = mClampF(flGain, 0.0f, 1.0f);
flGainHF = mClampF(flGainHF, 0.0f, 1.0f);
flGainLF = mClampF(flGainLF, 0.0f, 1.0f);
flDecayTime = mClampF(flDecayTime, 0.1f, 20.0f);
flDecayHFRatio = mClampF(flDecayHFRatio, 0.1f, 2.0f);
flDecayLFRatio = mClampF(flDecayLFRatio, 0.1f, 2.0f);
flReflectionsGain = mClampF(flReflectionsGain, 0.0f, 3.16f);
flReflectionsDelay = mClampF(flReflectionsDelay, 0.0f, 0.3f);
flReflectionsPan[0] = mClampF(flReflectionsPan[0], -1.0f, 1.0f);
flReflectionsPan[1] = mClampF(flReflectionsPan[1], -1.0f, 1.0f);
flReflectionsPan[2] = mClampF(flReflectionsPan[2], -1.0f, 1.0f);
flLateReverbGain = mClampF(flLateReverbGain, 0.0f, 10.0f);
flLateReverbDelay = mClampF(flLateReverbDelay, 0.0f, 0.1f);
flLateReverbPan[0] = mClampF(flLateReverbPan[0], -1.0f, 1.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);
}
};
@ -415,73 +424,99 @@ class SFXReverbProperties
/// Sound reverb 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
{
public:
typedef void Parent;
S32 mDirect;
S32 mDirectHF;
S32 mRoom;
S32 mRoomHF;
S32 mObstruction;
F32 mObstructionLFRatio;
S32 mOcclusion;
F32 mOcclusionLFRatio;
F32 mOcclusionRoomRatio;
F32 mOcclusionDirectRatio;
S32 mExclusion;
F32 mExclusionLFRatio;
S32 mOutsideVolumeHF;
F32 mDopplerFactor;
F32 mRolloffFactor;
F32 mRoomRolloffFactor;
F32 mAirAbsorptionFactor;
S32 mFlags;
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 )
{
}
void validate()
{
mDirect = mClamp( mDirect, -10000, 1000 );
mDirectHF = mClamp( mDirectHF, -10000, 0 );
mRoom = mClamp( mRoom, -10000, 1000 );
mRoomHF = mClamp( mRoomHF, -10000, 0 );
mObstruction = mClamp( mObstruction, -10000, 0 );
mObstructionLFRatio = mClampF( mObstructionLFRatio, 0.0f, 1.0f );
mOcclusion = mClamp( mOcclusion, -10000, 0 );
mOcclusionLFRatio = mClampF( mOcclusionLFRatio, 0.0f, 1.0f );
mOcclusionRoomRatio = mClampF( mOcclusionRoomRatio, 0.0f, 10.0f );
mOcclusionDirectRatio= mClampF( mOcclusionDirectRatio, 0.0f, 10.0f );
mExclusion = mClamp( mExclusion, -10000, 0 );
mExclusionLFRatio = mClampF( mExclusionLFRatio, 0.0f, 1.0f );
mOutsideVolumeHF = mClamp( mOutsideVolumeHF, -10000, 0 );
mDopplerFactor = mClampF( mDopplerFactor, 0.0f, 10.0f );
mRolloffFactor = mClampF( mRolloffFactor, 0.0f, 10.0f );
mRoomRolloffFactor = mClampF( mRoomRolloffFactor, 0.0f, 10.0f );
mAirAbsorptionFactor = mClampF( mAirAbsorptionFactor, 0.0f, 10.0f );
}
public:
typedef void Parent;
float flDensity;
float flDiffusion;
float flGain;
float flGainHF;
float flGainLF;
float flDecayTime;
float flDecayHFRatio;
float flDecayLFRatio;
float flReflectionsGain;
float flReflectionsDelay;
float flReflectionsPan[3];
float flLateReverbGain;
float flLateReverbDelay;
float flLateReverbPan[3];
float flEchoTime;
float flEchoDepth;
float flModulationTime;
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()
{
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()
{
flDensity = mClampF(flDensity, 0.0f, 1.0f);
flDiffusion = mClampF(flDiffusion, 0.0f, 1.0f);
flGain = mClampF(flGain, 0.0f, 1.0f);
flGainHF = mClampF(flGainHF, 0.0f, 1.0f);
flGainLF = mClampF(flGainLF, 0.0f, 1.0f);
flDecayTime = mClampF(flDecayTime, 0.1f, 20.0f);
flDecayHFRatio = mClampF(flDecayHFRatio, 0.1f, 2.0f);
flDecayLFRatio = mClampF(flDecayLFRatio, 0.1f, 2.0f);
flReflectionsGain = mClampF(flReflectionsGain, 0.0f, 3.16f);
flReflectionsDelay = mClampF(flReflectionsDelay, 0.0f, 0.3f);
flReflectionsPan[0] = mClampF(flReflectionsPan[0], -1.0f, 1.0f);
flReflectionsPan[1] = mClampF(flReflectionsPan[1], -1.0f, 1.0f);
flReflectionsPan[2] = mClampF(flReflectionsPan[2], -1.0f, 1.0f);
flLateReverbGain = mClampF(flLateReverbGain, 0.0f, 10.0f);
flLateReverbDelay = mClampF(flLateReverbDelay, 0.0f, 0.1f);
flLateReverbPan[0] = mClampF(flLateReverbPan[0], -1.0f, 1.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

@ -389,91 +389,55 @@ void SFXDescription::initPersistFields()
addGroup( "Reverb" );
addField( "useCustomReverb", TypeBool, Offset( mUseReverb, SFXDescription ),
"If true, use the reverb properties defined here on sounds.\n"
"By default, sounds will be assigned a generic reverb profile. By setting this flag to true, "
"a custom reverb setup can be defined using the \"Reverb\" properties that will then be assigned "
"to sounds playing with the description.\n\n"
"@ref SFX_reverb" );
addField( "reverbDirect", TypeS32, Offset( mReverb.mDirect, SFXDescription ),
"Direct path level (at low and mid frequencies).\n"
"@note SUPPORTED: EAX/I3DL2/FMODSFX\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbDirectHF", TypeS32, Offset( mReverb.mDirectHF, SFXDescription ),
"Relative direct path level at high frequencies.\n"
"@note SUPPORTED: EAX/I3DL2\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbRoom", TypeS32, Offset( mReverb.mRoom, SFXDescription ),
"Room effect level (at low and mid frequencies).\n"
"@note SUPPORTED: EAX/I3DL2/FMODSFX\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbRoomHF", TypeS32, Offset( mReverb.mRoomHF, SFXDescription ),
"Relative room effect level at high frequencies.\n"
"@note SUPPORTED: EAX/I3DL2\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbObstruction", TypeS32, Offset( mReverb.mObstruction, SFXDescription ),
"Main obstruction control (attenuation at high frequencies).\n"
"@note SUPPORTED: EAX/I3DL2\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbObstructionLFRatio", TypeF32, Offset( mReverb.mObstructionLFRatio, SFXDescription ),
"Obstruction low-frequency level re. main control.\n"
"@note SUPPORTED: EAX/I3DL2\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbOcclusion", TypeS32, Offset( mReverb.mOcclusion, SFXDescription ),
"Main occlusion control (attenuation at high frequencies)."
"@note SUPPORTED: EAX/I3DL2\n\n"
"\n@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbOcclusionLFRatio", TypeF32, Offset( mReverb.mOcclusionLFRatio, SFXDescription ),
"Occlusion low-frequency level re. main control.\n"
"@note SUPPORTED: EAX/I3DL2\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbOcclusionRoomRatio", TypeF32, Offset( mReverb.mOcclusionRoomRatio, SFXDescription ),
"Relative occlusion control for room effect.\n"
"@note SUPPORTED: EAX Only\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbOcclusionDirectRatio",TypeF32, Offset( mReverb.mOcclusionDirectRatio, SFXDescription ),
"Relative occlusion control for direct path.\n"
"@note SUPPORTED: EAX Only\n\n"
"@see http://www.atc.creative.com/algorithms/eax20.pdf" );
addField( "reverbExclusion", TypeS32, Offset( mReverb.mExclusion, SFXDescription ),
"Main exclusion control (attenuation at high frequencies).\n"
"@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" );
addField("useCustomReverb", TypeBool, Offset(mUseReverb, SFXDescription),
"If true, use the reverb properties defined here on sounds.\n"
"By default, sounds will be assigned a generic reverb profile. By setting this flag to true, "
"a custom reverb setup can be defined using the \"Reverb\" properties that will then be assigned "
"to sounds playing with the description.\n\n"
"@ref SFX_reverb");
addField("reverbDensity", TypeF32, Offset(mReverb.flDensity, SFXDescription),
"Density of reverb environment.");
addField("reverbDiffusion", TypeF32, Offset(mReverb.flDiffusion, SFXDescription),
"Environment diffusion.");
addField("reverbGain", TypeF32, Offset(mReverb.flGain, SFXDescription),
"Reverb Gain Level.");
addField("reverbGainHF", TypeF32, Offset(mReverb.flGainHF, SFXDescription),
"Reverb Gain to high frequencies");
addField("reverbGainLF", TypeF32, Offset(mReverb.flGainLF, SFXDescription),
"Reverb Gain to high frequencies");
addField("reverbDecayTime", TypeF32, Offset(mReverb.flDecayTime, SFXDescription),
"Decay time for the reverb.");
addField("reverbDecayHFRatio", TypeF32, Offset(mReverb.flDecayHFRatio, SFXDescription),
"High frequency decay time ratio.");
addField("reverbDecayLFRatio", TypeF32, Offset(mReverb.flDecayLFRatio, SFXDescription),
"High frequency decay time ratio.");
addField("reflectionsGain", TypeF32, Offset(mReverb.flReflectionsGain, SFXDescription),
"Reflection Gain.");
addField("reflectionDelay", TypeF32, Offset(mReverb.flReflectionsDelay, SFXDescription),
"How long to delay reflections.");
addField("lateReverbGain", TypeF32, Offset(mReverb.flLateReverbGain, SFXDescription),
"Late reverb gain amount.");
addField("lateReverbDelay", TypeF32, Offset(mReverb.flLateReverbDelay, SFXDescription),
"Late reverb delay time.");
addField("reverbEchoTime", TypeF32, Offset(mReverb.flEchoTime, SFXDescription),
"Reverb echo time.");
addField("reverbEchoDepth", TypeF32, Offset(mReverb.flEchoDepth, SFXDescription),
"Reverb echo depth.");
addField("reverbModTime", TypeF32, Offset(mReverb.flModulationTime, SFXDescription),
"Reverb Modulation time.");
addField("reverbModTime", TypeF32, Offset(mReverb.flModulationDepth, SFXDescription),
"Reverb Modulation time.");
addField("airAbsorbtionGainHF", TypeF32, Offset(mReverb.flAirAbsorptionGainHF, SFXDescription),
"High Frequency air absorbtion");
addField("reverbHFRef", TypeF32, Offset(mReverb.flHFReference, SFXDescription),
"Reverb High Frequency Reference.");
addField("reverbLFRef", TypeF32, Offset(mReverb.flLFReference, SFXDescription),
"Reverb Low Frequency Reference.");
addField("roomRolloffFactor", TypeF32, Offset(mReverb.flRoomRolloffFactor, SFXDescription),
"Rolloff factor for reverb.");
addField("decayHFLimit", TypeS32, Offset(mReverb.iDecayHFLimit, SFXDescription),
"High Frequency decay limit.");
endGroup("Reverb");
Parent::initPersistFields();
}
@ -570,24 +534,27 @@ void SFXDescription::packData( BitStream *stream )
if( mUseReverb )
{
stream->writeRangedS32( mReverb.mDirect, -10000, 1000 );
stream->writeRangedS32( mReverb.mDirectHF, -10000, 0 );
stream->writeRangedS32( mReverb.mRoom, -10000, 1000 );
stream->writeRangedS32( mReverb.mRoomHF, -10000, 0 );
stream->writeRangedS32( mReverb.mObstruction, -10000, 0 );
stream->writeRangedF32( mReverb.mObstructionLFRatio, 0.0, 1.0, 7 );
stream->writeRangedS32( mReverb.mOcclusion, -10000, 0 );
stream->writeRangedF32( mReverb.mOcclusionLFRatio, 0.0, 1.0, 7 );
stream->writeRangedF32( mReverb.mOcclusionRoomRatio, 0.0, 10.0, 7 );
stream->writeRangedF32( mReverb.mOcclusionDirectRatio, 0.0, 10.0, 7 );
stream->writeRangedS32( mReverb.mExclusion, -10000, 0 );
stream->writeRangedF32( mReverb.mExclusionLFRatio, 0.0, 1.0, 7 );
stream->writeRangedS32( mReverb.mOutsideVolumeHF, -10000, 0 );
stream->writeRangedF32( mReverb.mDopplerFactor, 0.0, 10.0, 7 );
stream->writeRangedF32( mReverb.mRolloffFactor, 0.0, 10.0, 7 );
stream->writeRangedF32( mReverb.mRoomRolloffFactor, 0.0, 10.0, 7 );
stream->writeRangedF32( mReverb.mAirAbsorptionFactor, 0.0, 10.0, 7 );
stream->writeInt( mReverb.mFlags, 6 );
stream->write(mReverb.flDensity);
stream->write(mReverb.flDiffusion);
stream->write(mReverb.flGain);
stream->write(mReverb.flGainHF);
stream->write(mReverb.flGainLF);
stream->write(mReverb.flDecayTime);
stream->write(mReverb.flDecayHFRatio);
stream->write(mReverb.flDecayLFRatio);
stream->write(mReverb.flReflectionsGain);
stream->write(mReverb.flReflectionsDelay);
stream->write(mReverb.flLateReverbGain);
stream->write(mReverb.flLateReverbDelay);
stream->write(mReverb.flEchoTime);
stream->write(mReverb.flEchoDepth);
stream->write(mReverb.flModulationTime);
stream->write(mReverb.flModulationDepth);
stream->write(mReverb.flAirAbsorptionGainHF);
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 )
{
mReverb.mDirect = stream->readRangedS32( -10000, 1000 );
mReverb.mDirectHF = stream->readRangedS32( -10000, 0 );
mReverb.mRoom = stream->readRangedS32( -10000, 1000 );
mReverb.mRoomHF = stream->readRangedS32( -10000, 0 );
mReverb.mObstruction = stream->readRangedS32( -10000, 0 );
mReverb.mObstructionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 );
mReverb.mOcclusion = stream->readRangedS32( -10000, 0 );
mReverb.mOcclusionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 );
mReverb.mOcclusionRoomRatio = stream->readRangedF32( 0.0, 10.0, 7 );
mReverb.mOcclusionDirectRatio = stream->readRangedF32( 0.0, 10.0, 7 );
mReverb.mExclusion = stream->readRangedS32( -10000, 0 );
mReverb.mExclusionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 );
mReverb.mOutsideVolumeHF = stream->readRangedS32( -10000, 0 );
mReverb.mDopplerFactor = stream->readRangedF32( 0.0, 10.0, 7 );
mReverb.mRolloffFactor = stream->readRangedF32( 0.0, 10.0, 7 );
mReverb.mRoomRolloffFactor = stream->readRangedF32( 0.0, 10.0, 7 );
mReverb.mAirAbsorptionFactor = stream->readRangedF32( 0.0, 10.0, 7 );
mReverb.mFlags = stream->readInt( 6 );
stream->read(&mReverb.flDensity);
stream->read(&mReverb.flDiffusion);
stream->read(&mReverb.flGain);
stream->read(&mReverb.flGainHF);
stream->read(&mReverb.flGainLF);
stream->read(&mReverb.flDecayTime);
stream->read(&mReverb.flDecayHFRatio);
stream->read(&mReverb.flDecayLFRatio);
stream->read(&mReverb.flReflectionsGain);
stream->read(&mReverb.flReflectionsDelay);
stream->read(&mReverb.flLateReverbGain);
stream->read(&mReverb.flLateReverbDelay);
stream->read(&mReverb.flEchoTime);
stream->read(&mReverb.flEchoDepth);
stream->read(&mReverb.flModulationTime);
stream->read(&mReverb.flModulationDepth);
stream->read(&mReverb.flAirAbsorptionGainHF);
stream->read(&mReverb.flHFReference);
stream->read(&mReverb.flLFReference);
stream->read(&mReverb.flRoomRolloffFactor);
stream->read(&mReverb.iDecayHFLimit);
}
}

View file

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

View file

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

View file

@ -94,6 +94,9 @@ ImplementEnumType( SFXDistanceModel,
{ SFXDistanceModelLogarithmic, "Logarithmic",
"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." },
{ 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;
ImplementEnumType( SFXChannel,
@ -473,6 +476,9 @@ bool SFXSystem::createDevice( const String& providerName, const String& deviceNa
mDevice->setDistanceModel( mDistanceModel );
mDevice->setDopplerFactor( mDopplerFactor );
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 );
// Signal system.

File diff suppressed because it is too large Load diff