VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtAudioUpdater Class Reference

Detailed Description

The DtAudioUpdater plays audio sounds for the engaged entity based on the value of boolean state attributes. Each configured sound is associated with a state attribute and will play when that attribute is true. Sounds can be configured to loop, play at specific loudness levels, and be positioned in 3D space at the entity's location.

Note that entities that are destroyed will not play sounds, regardless of state attributes.

Example Lua configuration:

["sirenAudioUpdater"] = {
componentType = "DtAudioUpdater";
priority = 10;
audioPath = "$(SHARED_DATA_DIR)\\Audio\\sirens\\";
sources = {
{ audio = "siren-1-fast-loop.wav"; stateAttribute = "siren-fast"; -- [[ default values:looping = true;
gain = 1.0; decibels = 80.0; is3d = true; ]] }; { audio = "siren-1-slow-loop.wav"; stateAttribute =
"siren-slow"; -- [[ default values:looping = true; gain = 1.0; decibels = 80.0; is3d = true; ]] }; { audio
= "siren-airhorn-single.wav"; stateAttribute = "siren-horn"; looping = false; -- [[ default values:gain
= 1.0; decibels = 80.0; is3d = true;]] }; { audio = "siren-piercer-loop.wav"; stateAttribute =
"siren-piercer"; -- [[ default values:looping = true; gain = 1.0; decibels = 80.0; is3d = true;]] };
};
};
constexpr const char * audio
Definition audioUpdater.h:34
constexpr const char * looping
Definition audioUpdater.h:49
constexpr const char * is3d
Definition audioUpdater.h:46
constexpr const char * stateAttribute
Definition audioUpdater.h:55
constexpr const char * gain
Definition audioUpdater.h:43
constexpr const char * decibels
Definition audioUpdater.h:40

#include <audioUpdater.h>

Inheritance diagram for makVre::DtAudioUpdater:
[legend]

Classes

struct  Sound
 

Public Member Functions

 DtAudioUpdater ()
 
virtual ~DtAudioUpdater () override
 
virtual bool initialize (DtPlayerStation *player, DtInitTable &config) override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
virtual bool postInitialize ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Attributes

std::vector< SoundmySounds
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Additional Inherited Members

- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Constructor & Destructor Documentation

◆ DtAudioUpdater()

makVre::DtAudioUpdater::DtAudioUpdater ( )

Constructor for DtAudioUpdater.

Initializes the component with the name "DtAudioUpdater".

◆ ~DtAudioUpdater()

virtual makVre::DtAudioUpdater::~DtAudioUpdater ( )
overridevirtual

Virtual destructor for DtAudioUpdater.

Ensures proper cleanup of audio resources when the component is destroyed.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtAudioUpdater::initialize ( DtPlayerStation * player,
DtInitTable & config )
overridevirtual

Initializes the component with configuration from Lua.

Sets up audio sources based on the provided configuration. Each source is configured with its associated state attribute, looping behavior, gain, decibel level, and 3D positioning.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing initialization parameters, especially the sources table
Returns
True if initialization succeeds, false otherwise

Reimplemented from makVre::DtPlayerComponent.

References makVre::DtPlayerComponent::player().

◆ tick()

virtual void makVre::DtAudioUpdater::tick ( double dt)
overridevirtual

Updates the audio playback based on state attributes.

Called each frame to manage audio playback. For each configured sound, checks its associated state attribute and plays/stops the sound accordingly. For 3D sounds, updates their position to match the entity's current location.

For non-looping sounds, the component will automatically set the state attribute to false when the sound finishes playing.

Parameters
dtDelta time in seconds since the last tick

Implements makVre::DtPlayerComponent.

◆ shutdown()

virtual void makVre::DtAudioUpdater::shutdown ( )
overridevirtual

Shuts down the component.

Cleans up all audio resources by stopping and deleting sounds.

Reimplemented from makVre::DtPlayerComponent.

◆ type()

virtual const char * makVre::DtAudioUpdater::type ( ) const
overridevirtual

Returns the component type identifier.

Returns
The component type string

Implements makVre::DtPlayerComponent.

Member Data Documentation

◆ mySounds

std::vector<Sound> makVre::DtAudioUpdater::mySounds
protected

Collection of sounds managed by this component.


The documentation for this class was generated from the following file: