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

Detailed Description

The DtEngineAudioUpdater provides realistic audio simulation for vehicle engines. It dynamically modulates sound pitch and volume based on engine RPM or speed values, applies smoothing to prevent jitter, and positions sounds in 3D space based on the entity's location.

The component supports multiple engine sounds with different characteristics and can tie sound playback to an engine on/off state attribute.

#include <engineAudioUpdater.h>

Inheritance diagram for makVre::DtEngineAudioUpdater:
[legend]

Classes

struct  EngineSound
 

Public Member Functions

 DtEngineAudioUpdater ()
 
virtual ~DtEngineAudioUpdater () 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::string myEngineOnAttributeName
 
std::vector< EngineSoundmyEngineSounds
 
- 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

◆ DtEngineAudioUpdater()

makVre::DtEngineAudioUpdater::DtEngineAudioUpdater ( )

Constructor for DtEngineAudioUpdater.

Initializes the component with the name "DtEngineAudioUpdater".

◆ ~DtEngineAudioUpdater()

virtual makVre::DtEngineAudioUpdater::~DtEngineAudioUpdater ( )
overridevirtual

Virtual destructor for DtEngineAudioUpdater.

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

Member Function Documentation

◆ initialize()

virtual bool makVre::DtEngineAudioUpdater::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 RPM attribute, maximum RPM value, pitch range, smoothing factor, gain, and decibel level.

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::DtEngineAudioUpdater::tick ( double dt)
overridevirtual

Updates the audio playback based on RPM state attributes.

Called each frame to manage audio playback. For each configured sound:

  • Reads the associated RPM attribute value
  • Normalizes the value based on the maximum RPM
  • Applies smoothing to reduce jitter
  • Calculates and sets pitch and gain values
  • Updates the sound position to match the entity's location
Parameters
dtDelta time in seconds since the last tick

Implements makVre::DtPlayerComponent.

◆ shutdown()

virtual void makVre::DtEngineAudioUpdater::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::DtEngineAudioUpdater::type ( ) const
overridevirtual

Returns the type identifier for this component.

Returns
The type string for DtEngineAudioUpdater

Implements makVre::DtPlayerComponent.

Member Data Documentation

◆ myEngineOnAttributeName

std::string makVre::DtEngineAudioUpdater::myEngineOnAttributeName
protected

Name of the state attribute that indicates if the engine is on.

This attribute controls whether engine sounds are played at all. Default is "engine-on" but can be changed via configuration.

◆ myEngineSounds

std::vector<EngineSound> makVre::DtEngineAudioUpdater::myEngineSounds
protected

Collection of engine sounds managed by this component.


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