VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
makVrv::DtSoundComponent Class Reference

Manages the lifetime of a single audio source attached to an entity or world position.

A DtSoundComponent wraps either a file-based makAudio::DtSound or a procedural sound channel and integrates it into the DtSoundComponentSystem tick loop. Callers populate a DtSoundComponentData struct, call initialize(), then call play() to start playback.

Scene object attachment can be expressed either as a raw pointer (mySceneObject) or as a unique ID (mySceneObjectId). If only mySceneObjectId is set, the pointer is resolved lazily when createAndInitializeSound() first runs. If both are set, mySceneObject takes precedence.

Classes

struct  DtSoundComponentData
 

Public Types

enum  DtSoundState { DtSoundState::STOPPED, DtSoundState::PAUSED, DtSoundState::PLAYED }
 

Public Member Functions

 DtSoundComponent (DtDe &de, DtUniqueID id)
 
virtual ~DtSoundComponent ()
 
virtual void initialize (const DtSoundComponentData &soundData)
 
virtual void initialize (const std::string &modelDefinition)
 
virtual void play ()
 
virtual void playOnce ()
 
virtual void pause ()
 
virtual void stop ()
 
virtual makAudio::DtSound * sound ()
 
virtual const makAudio::DtSound * sound () const
 
virtual void setIs3d (bool is3d)
 
virtual void setPosition (const DtVector &position)
 
virtual void setDecibel (float decibels)
 
virtual void setIsLooping (bool isLooping)
 
virtual void setSceneObjectId (DtUniqueID sceneObjectId)
 
virtual void setElementIdAndModelSet (DtElementID sceneObjectId, DtModelSetId modelSet)
 
virtual void setModelSet (DtModelSetId modelSet)
 

Static Public Member Functions

static void populateFromSoundSchema (const DtModelDefinition &definition, const DtDePathConfiguration &pathConfig, DtSoundComponentData &outData)
 

Protected Member Functions

virtual void createAndInitializeSound ()
 

Protected Attributes

DtDe & myDe
 
DtUniqueID myId
 
DtSoundComponentData mySoundData
 
DtSoundComponentSystem & mySystem
 
makAudio::DtSound * mySound
 
DtProceduralSound * myProceduralSound
 
bool myIsAddedToSystem
 

Friends

class DtSoundComponentSystem
 
class DtSoundComponentSystemImGui
 

Member Enumeration Documentation

Playback state of the sound component.

Enumerator
STOPPED 

Sound is stopped and will not play when added to the system.

PAUSED 

Sound is paused and will resume from the current position on play().

PLAYED 

Sound is playing or will begin playing when added to the system.

Constructor & Destructor Documentation

makVrv::DtSoundComponent::DtSoundComponent ( DtDe &  de,
DtUniqueID  id 
)

Constructs a DtSoundComponent owned by the given DE, identified by id.

Parameters
deThe distributed environment this component belongs to.
idUnique identifier of the owning entity.
virtual makVrv::DtSoundComponent::~DtSoundComponent ( )
virtual

Destructor. Removes the component from DtSoundComponentSystem if still registered.

Member Function Documentation

static void makVrv::DtSoundComponent::populateFromSoundSchema ( const DtModelDefinition &  definition,
const DtDePathConfiguration &  pathConfig,
DtSoundComponentData &  outData 
)
static

Populate the six audio fields of a DtSoundComponentData from a Sound-schema model definition.

Reads sound_filepath (or legacy filename, or procedural_sound_name), isLooping, sound_decibels (clamped to unity with the same one-shot warning as initialize(std::string)), min_audible_distance_m, max_audible_distance_m, and sound_priority. Writes them into outData.mySoundDescriptor.mySoundFilename / myIsLooping, outData.myAuthoredDbfs, outData.myMinAudibleDistanceM, outData.myMaxAudibleDistanceM, and outData.myPriority. Pins outData.mySoundDescriptor.myDecibels to DtAudioLevel::kDefaultSourceSplDb.

Caller-owned fields on outData (myPosition, myVelocity, mySceneObject, mySceneObjectId, myModelSet, mySoundState, myIsInteraction, myBehaviorKey, myBehaviorParams, myLocalWeatherAreaEnabled) are NOT touched.

Note
Definitions whose schema() is not "Sound" are still parsed – the schema check remains the responsibility of the caller. This matches the current behavior of DtModelSoundCreator which is triggered per-model-set regardless of schema.
Parameters
[in]definitionThe model definition to read from.
[in]pathConfigThe DE's path configuration used to resolve tokens and the MEAF fallback path for a raw filename.
[out]outDataPopulated on return. Fields not owned by the Sound schema (see above) are left untouched.
virtual void makVrv::DtSoundComponent::initialize ( const DtSoundComponentData &  soundData)
virtual

Initializes the component from a fully populated DtSoundComponentData struct.

Parameters
soundDataConfiguration bundle describing the audio source and attachment.

Has no effect if the component has already been added to the system. Must be called before play().

virtual void makVrv::DtSoundComponent::initialize ( const std::string &  modelDefinition)
virtual

Initializes the component by looking up a named model definition.

Parameters
modelDefinitionName of a model definition that uses the Sound schema.

Has no effect if the component has already been added to the system. The definition must contain a "filename" or "proceduralSoundscapeKey" parameter.

virtual void makVrv::DtSoundComponent::play ( )
virtual

Starts or resumes playback.

If the component has not yet been added to the DtSoundComponentSystem, it is added now. Audio creation for a 3D scene-object-attached component is deferred until the scene object has completed an update.

virtual void makVrv::DtSoundComponent::playOnce ( )
virtual

Plays the sound once as a non-looping interaction, then stops.

For world-position sounds (no scene object), the sound is played immediately via the audio manager as a one-shot effect. For scene-object-attached sounds the component is added to the system with myIsInteraction set. Not supported for procedural sounds; use play() instead.

virtual void makVrv::DtSoundComponent::pause ( )
virtual

Pauses playback without resetting the playback position.

virtual void makVrv::DtSoundComponent::stop ( )
virtual

Stops playback and resets the playback position.

virtual makAudio::DtSound* makVrv::DtSoundComponent::sound ( )
virtual

Returns a non-owning pointer to the underlying makAudio::DtSound, or null if not yet created or if this is a procedural sound.

virtual const makAudio::DtSound* makVrv::DtSoundComponent::sound ( ) const
virtual

Returns a const non-owning pointer to the underlying makAudio::DtSound.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void makVrv::DtSoundComponent::setIs3d ( bool  is3d)
virtual

Sets whether the sound is spatialized in 3D.

Parameters
is3dTrue for 3D (positional) audio, false for 2D (screen-space) audio.
virtual void makVrv::DtSoundComponent::setPosition ( const DtVector &  position)
virtual

Sets the local-space or world-space position of the sound.

Parameters
positionWorld position (no scene object) or local offset from the scene object.

Has no effect while a scene object is attached; position is derived from the object each frame in that case.

virtual void makVrv::DtSoundComponent::setDecibel ( float  decibels)
virtual

Sets the volume level in decibels.

Parameters
decibelsVolume in dB relative to full scale (0 dB = full scale).
virtual void makVrv::DtSoundComponent::setIsLooping ( bool  isLooping)
virtual

Sets whether the sound loops continuously.

Parameters
isLoopingTrue to loop; false to play once and stop.

Looping cannot be changed at runtime for procedural sounds.

virtual void makVrv::DtSoundComponent::setSceneObjectId ( DtUniqueID  sceneObjectId)
virtual

Attaches the sound to a scene object identified by unique ID.

Parameters
sceneObjectIdUnique ID of the scene object to track.

Resolves the ID to a DtSceneObject pointer immediately via the agent manager. Prefer setting DtSoundComponentData::mySceneObjectId before initialize() when lazy resolution is acceptable.

virtual void makVrv::DtSoundComponent::setElementIdAndModelSet ( DtElementID  sceneObjectId,
DtModelSetId  modelSet 
)
virtual

Attaches the sound to a scene object looked up by element ID and model set.

Parameters
sceneObjectIdElement ID of the owning entity.
modelSetModel set used to resolve the correct scene object instance.
virtual void makVrv::DtSoundComponent::setModelSet ( DtModelSetId  modelSet)
virtual

Overrides the model set used for scene object resolution.

Parameters
modelSetThe new model set ID.
virtual void makVrv::DtSoundComponent::createAndInitializeSound ( )
protectedvirtual

Creates and initializes the underlying audio resource.

Called by DtSoundComponentSystem during its tick. Resolves mySceneObjectId to a pointer if mySceneObject is not already set, creates the makAudio::DtSound, positions it, and begins playback according to mySoundState.

Friends And Related Function Documentation

friend class DtSoundComponentSystem
friend
friend class DtSoundComponentSystemImGui
friend

Member Data Documentation

DtDe& makVrv::DtSoundComponent::myDe
protected

The distributed environment this component belongs to.

DtUniqueID makVrv::DtSoundComponent::myId
protected

Unique identifier of the owning entity.

DtSoundComponentData makVrv::DtSoundComponent::mySoundData
protected

Current configuration and state for this audio source.

DtSoundComponentSystem& makVrv::DtSoundComponent::mySystem
protected

Reference to the singleton sound component system that drives this component each frame.

makAudio::DtSound* makVrv::DtSoundComponent::mySound
protected

Owning pointer to the underlying audio object. Null until createAndInitializeSound() runs.

DtProceduralSound* makVrv::DtSoundComponent::myProceduralSound
protected

Non-owning pointer to the procedural sound, set by DtSoundComponentSystem when mySoundDescriptor.mySoundFilename begins with kProceduralSoundPrefix. Null for regular file-based sounds.

bool makVrv::DtSoundComponent::myIsAddedToSystem
protected

True once this component has been registered with DtSoundComponentSystem.


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

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)