33#include <OgreVector3.h>
34#include <OgreString.h>
37 #include <OpenAL/al.h>
38 #include <OpenAL/alc.h>
39 #include <OpenAL/alext.h>
40 #include <OpenAL/efx-presets.h>
45 #include <AL/efx-presets.h>
87 void Update(
const float dt);
114 void SetListener(Ogre::Vector3 position, Ogre::Vector3 direction, Ogre::Vector3 up, Ogre::Vector3 velocity);
144 void SetSpeedOfSound(
const float speed_of_sound)
const { alSpeedOfSound(speed_of_sound); }
155 void SetDopplerFactor(
const float doppler_factor)
const { alDopplerFactor(doppler_factor); }
163 void SetDopplerFactor(
const ALuint hardware_source,
const float doppler_factor)
const;
195 const EFXEAXREVERBPROPERTIES*
GetEfxProperties(
const std::string& efx_preset_name)
const;
232 void recomputeSource(
int source_index,
int reason,
float vfl, Ogre::Vector3 *vvec);
246 void assign(
int source_index,
int hardware_index);
252 void retire(
int source_index);
254 bool loadWAVFile(Ogre::String filename, ALuint buffer, Ogre::String resource_group_name =
"");
316 ALuint
CreateAlEffect(
const EFXEAXREVERBPROPERTIES* efx_properties)
const;
386 bool UpdateOcclusionFilter(
const int hardware_index,
const ALuint effect_slot_id,
const EFXEAXREVERBPROPERTIES* reference_efx_reverb_properties)
const;
404 const Ogre::Vector3& cone_direction,
405 const float cone_inner_angle,
406 const float cone_outer_angle,
407 const float cone_outer_gain,
408 const float cone_outer_gain_hf
Central state/object manager and communications hub.
Game state manager and message-queue provider.
void SetDopplerFactor(const float doppler_factor) const
Updates the global Doppler factor in OpenAL with the provided value.
static const float MAX_DISTANCE
Ogre::Vector3 GetListenerPosition() const
Returns the position vector of the listener.
void UpdateConeProperties(const ALuint source, const Ogre::Vector3 &cone_direction, const float cone_inner_angle, const float cone_outer_angle, const float cone_outer_gain, const float cone_outer_gain_hf) const
Updates the Cone properties for the hardware source.
void Update(const float dt)
Does the per-frame update of sounds and listener environment.
std::map< ALuint, ALuint > m_efx_effect_id_map
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti
void recomputeSource(int source_index, int reason, float vfl, Ogre::Vector3 *vvec)
Computes audibility of an audio source and retires it if it is inaudible.
int getNumHardwareSources()
Returns the number of currently used hardware sources.
void PrepopulateEfxPropertiesMap()
Helper function that fills the m_efx_properties_map with presets provided by OpenAL's efx-presets....
ALuint audio_buffers[MAX_AUDIO_BUFFERS]
ALuint m_efx_outdoor_obstruction_lowpass_filter_id
float m_air_absorption_factor
SoundPtr audio_sources[MAX_AUDIO_BUFFERS]
void UpdateGlobalDopplerFactor() const
Updates the global Doppler factor based on CVar settings and the state of the physics simulation.
void pauseAllSounds()
Unlike the name suggests, this sets the listener's gain to 0, essentially muting all sounds.
bool loadWAVFile(Ogre::String filename, ALuint buffer, Ogre::String resource_group_name="")
bool UpdateOcclusionFilter(const int hardware_index, const ALuint effect_slot_id, const EFXEAXREVERBPROPERTIES *reference_efx_reverb_properties) const
Applies an occlusion filter to the provided source if certain conditions apply.
void UpdateListenerEnvironment()
Determines several properties of the environment of the listener and updates OpenAL to use them.
static const unsigned int MAX_AUDIO_BUFFERS
ALuint m_efx_occlusion_wet_path_lowpass_filter_id
ALuint getHardwareSource(int hardware_index)
Returns the AL handle for the hardware source with the provided index.
LPALDELETEFILTERS alDeleteFilters
SoundPtr createSound(Ogre::String filename, Ogre::String resource_group_name="")
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv
ALuint CreateAlEffect(const EFXEAXREVERBPROPERTIES *efx_properties) const
Creates an OpenAL effect based on the parameters of an efx/eax reverb preset.
Ogre::String audio_buffer_file_name[MAX_AUDIO_BUFFERS]
int hardware_sources_in_use_count
void assign(int source_index, int hardware_index)
Adds an audio source to hardware source.
Ogre::Vector3 m_listener_direction
EfxReverbEngine m_efx_reverb_engine
std::map< std::string, EFXEAXREVERBPROPERTIES > m_efx_properties_map
const EFXEAXREVERBPROPERTIES * m_listener_efx_reverb_properties
int hardware_sources_map[MAX_HARDWARE_SOURCES]
maps from the index of a hardware source to the index of the audio source currently assigned to the c...
void SetAirAbsorptionFactor(const float air_absorption_factor)
Sets the air absorptions factor for the direct path of all sounds.
void UpdateObstructionFilter(const int hardware_index, const bool enable_obstruction_filter) const
Applies an obstruction filter to the provided hardware source.
ALuint hardware_sources[MAX_HARDWARE_SOURCES]
void setMasterVolume(float v)
Updates both CVar audio_master_volume and the listener's gain to the provided value.
void UpdateEfxSpecificProperties(const float dt)
Updates properties of OpenAL facilities that are only available with EFX.
void UpdateSourceFilters(const int hardware_index) const
Helper function to call several other functions to update source filters.
static const float REFERENCE_DISTANCE
Ogre::Vector3 m_listener_position
int hardware_sources_num
total number of allocated hardware sources (<= MAX_HARDWARE_SOURCES)
LPALGENEFFECTS alGenEffects
void SetSpeedOfSound(const float speed_of_sound) const
Updates the speed of sound in OpenAL with the provided value.
static const float ROLLOFF_FACTOR
std::pair< int, float > audio_sources_most_audible[MAX_AUDIO_BUFFERS]
bool ListenerIsUnderwater() const
void DeleteAlEffect(const ALuint efx_effect_id) const
Deletes an OpenAL effect.
void UpdateDirectedSounds() const
Updates AL Cones for sources of directed sound emissions (exhausts, turboprops and turbojets).
ALuint m_efx_occlusion_wet_path_send_id
Ogre::Vector3 m_listener_up
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots
void resumeAllSounds()
Unlike the name suggests, this sets the listener's gain to the value of the CVar audio_master_volume.
void UpdateSourceSpecificDopplerFactor(const int hardware_index) const
Identifies the actor to which the sound corresponding to a hardware source belongs and updates the Do...
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots
const std::map< std::string, EFXEAXREVERBPROPERTIES > & getEfxPropertiesMap() const
Returns currently registered EFX presets.
bool m_listener_is_underwater
Ogre::Vector3 m_listener_velocity
int audio_buffers_in_use_count
bool IsHardwareSourceObstructed(const int hardware_index) const
Performs various checks against the environment of the listener to determine whether the sound belong...
float GetSpeedOfSound() const
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf
void SetListener(Ogre::Vector3 position, Ogre::Vector3 direction, Ogre::Vector3 up, Ogre::Vector3 velocity)
Sets position and speed of the listener.
float GetAirAbsorptionFactor() const
LPALDELETEEFFECTS alDeleteEffects
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot
std::tuple< Ogre::Vector3, float, float > ComputeEarlyReflectionsProperties() const
Detects surfaces close to the listener and calculates a user-relative (as opposed to listener-relativ...
void recomputeAllSources()
const EFXEAXREVERBPROPERTIES * GetReverbPresetAt(Ogre::Vector3 position) const
Determines which reverb preset corresponds to the provided position and returns its properties.
static const unsigned int MAX_HARDWARE_SOURCES
ALCcontext * sound_context
void retire(int source_index)
Stops and the removes an audio source from hardware source.
void UpdateListenerEffectSlot(const float dt)
Dynamically adjusts some parameters of the currently active reverb preset based on the current enviro...
float GetDopplerFactor() const
void SmoothlyUpdateAlAuxiliaryEffectSlot(const float dt, const ALuint slot_id, const EFXEAXREVERBPROPERTIES *target_efx_properties)
This performs a smooth update of the efx properties of an OpenAL Auxiliary Effect slot using linear i...
LPALGENFILTERS alGenFilters
void CleanUp()
Cleans up various objects that should be reset when returning from a terrain to the main menu.
int m_audio_sources_in_use_count
void UpdateAlListener()
Updates the listener's position, orientation and velocity vectors in OpenAL.
const EFXEAXREVERBPROPERTIES * GetEfxProperties(const std::string &efx_preset_name) const
Returns a pointer to properties of an EFX preset stored in the EFX properties map.