VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtSoundComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2026 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvAudio/vrvAudio.h>
13 #include <vrvAudio/DtAudioLevel.h>
14 #include <vrvCore/DtUniqueID.h>
16 
17 #include <matrix/vlVector.h>
18 
19 #include <makAudio/sound.h>
20 
21 #include <map>
22 #include <string>
23 
24 namespace makAudio
25 {
26  class DtSound;
27 }
28 
29 namespace makVrv
30 {
31  class DtDePathConfiguration;
32  class DtModelDefinition;
33  class DtProceduralSound;
34  class DtSceneObject;
35  class DtSoundComponentSystem;
36 
49  {
50  friend class DtSoundComponentSystem;
52 
53  public:
55  enum class DtSoundState
56  {
57  STOPPED,
58  PAUSED,
59  PLAYED
60  };
61 
70  {
78  {
79  mySoundDescriptor.myDecibels = DtAudioLevel::kDefaultSourceSplDb;
80  }
81 
92  makAudio::DtSoundDescriptor mySoundDescriptor;
93 
99  float myAuthoredDbfs = 0.0f;
100 
105  float myMinAudibleDistanceM = DtAudioLevel::kUseDefaultDistance;
106 
111  float myMaxAudibleDistanceM = DtAudioLevel::kUseDefaultDistance;
112 
116  makAudio::DtAbstractAudio::Priority myPriority
117  = makAudio::DtAbstractAudio::BACKGROUND_FX;
118 
121  DtVector myPosition;
122 
124  DtVector myVelocity;
125 
129  DtSceneObject* mySceneObject = nullptr;
130 
134  DtUniqueID mySceneObjectId = 0;
135 
138 
140  DtSoundState mySoundState = DtSoundState::STOPPED;
141 
144  bool myIsInteraction = false;
145 
152  std::string myBehaviorKey;
153 
159  std::map<std::string, std::string> myBehaviorParams;
160 
165  bool myLocalWeatherAreaEnabled = false;
166  };
167 
168  public:
169 
199  static void populateFromSoundSchema(
200  const DtModelDefinition& definition,
201  const DtDePathConfiguration& pathConfig,
202  DtSoundComponentData& outData);
203 
208 
210  virtual ~DtSoundComponent();
211 
213  DtSoundComponent() = delete;
214  DtSoundComponent(const DtSoundComponent&) = delete;
215  DtSoundComponent& operator=(const DtSoundComponent&) = delete;
217 
218  public:
224  virtual void initialize(const DtSoundComponentData& soundData);
225 
231  virtual void initialize(const std::string& modelDefinition);
232 
238  virtual void play();
239 
246  virtual void playOnce();
247 
249  virtual void pause();
250 
252  virtual void stop();
253 
256  virtual makAudio::DtSound* sound();
257 
260  virtual const makAudio::DtSound* sound() const;
261 
264  virtual void setIs3d(bool is3d);
265 
271  virtual void setPosition(const DtVector& position);
272 
275  virtual void setDecibel(float decibels);
276 
281  virtual void setIsLooping(bool isLooping);
282 
289  virtual void setSceneObjectId(DtUniqueID sceneObjectId);
290 
294  virtual void setElementIdAndModelSet(DtElementID sceneObjectId, DtModelSetId modelSet);
295 
298  virtual void setModelSet(DtModelSetId modelSet);
299 
300  protected:
306  virtual void createAndInitializeSound();
307 
308  protected:
311 
314 
317 
320 
322  makAudio::DtSound* mySound;
323 
328 
331  };
332 }
DtProceduralSound * myProceduralSound
Non-owning pointer to the procedural sound, set by DtSoundComponentSystem when mySoundDescriptor.mySoundFilename begins with kProceduralSoundPrefix. Null for regular file-based sounds.
Definition: DtSoundComponent.h:327
Manages the lifetime of a single audio source attached to an entity or world position.
Definition: DtSoundComponent.h:48
DtVector myPosition
Local-space offset applied to the sound&#39;s world position when attached to a scene object...
Definition: DtSoundComponent.h:121
makAudio::DtSoundDescriptor mySoundDescriptor
Descriptor for the underlying audio asset (filename, looping flag, 3D flag, gain).
Definition: DtSoundComponent.h:92
std::string myBehaviorKey
Optional behavior factory key (e.g. &quot;Visibility&quot;, &quot;Wind&quot;, &quot;Rain&quot;).
Definition: DtSoundComponent.h:152
DtUniqueID myId
Unique identifier of the owning entity.
Definition: DtSoundComponent.h:313
DtSoundComponentSystem manages the active sounds in the scene.
Definition: DtSoundComponentSystem.h:49
static constexpr float kDefaultSourceSplDb
Default sound pressure level for a newly authored source, in dB SPL at 1 m.
Definition: DtAudioLevel.h:111
Input data bundle passed to initialize(const DtSoundComponentData&amp;).
Definition: DtSoundComponent.h:69
The DtDePathConfiguration contains paths to various files, and can resolve the path macros ...
Definition: DtDePathConfiguration.h:23
Contains the DLL export macro for vrvAudio classes.
DtUniqueID DtElementID
The ElementID is a specific type of unique ID used to represent VR-Vantage uniquely defined elements...
Definition: DtUniqueID.h:23
A model definition Interaction any number of named parameters, and also can be used to store cached d...
Definition: DtModelDefinition.h:44
Composes multiple DtProceduralSoundLayer pools into one streaming ambient sound.
Definition: DtProceduralSound.h:61
DtModelSetId myModelSet
Model set used to resolve the correct LOD instance when no scene object is set.
Definition: DtSoundComponent.h:137
DtSoundState
Playback state of the sound component.
Definition: DtSoundComponent.h:55
DtSoundComponentSystem & mySystem
Reference to the singleton sound component system that drives this component each frame...
Definition: DtSoundComponent.h:319
DtVector myVelocity
Velocity vector used for Doppler calculations when no scene object is attached.
Definition: DtSoundComponent.h:124
static constexpr float kUseDefaultDistance
Sentinel value meaning &quot;leave this distance at the underlying audio engine&#39;s default&quot;...
Definition: DtAudioLevel.h:107
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
DtSoundComponentData mySoundData
Current configuration and state for this audio source.
Definition: DtSoundComponent.h:316
A DtSceneObject represents an object that can be positioned in the scene by (possibly) attaching it t...
Definition: DtSceneObject.h:44
std::map< std::string, std::string > myBehaviorParams
Key-value params forwarded to the behavior creator.
Definition: DtSoundComponent.h:159
Contains makVrv::DtUniqueID type.
#define DT_DLL_VRVAUDIO
Definition: vrvAudio.h:20
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
Contains the DtAudioLevel utility class.
makAudio::DtSound * mySound
Owning pointer to the underlying audio object. Null until createAndInitializeSound() runs...
Definition: DtSoundComponent.h:322
DtDe & myDe
The distributed environment this component belongs to.
Definition: DtSoundComponent.h:310
DtModelSetId
Definition: DtModelSetEnums.h:19
bool myIsAddedToSystem
True once this component has been registered with DtSoundComponentSystem.
Definition: DtSoundComponent.h:330
DtSoundComponentData()
Default constructor. Pins mySoundDescriptor.myDecibels to DtAudioLevel::kDefaultSourceSplDb – the phy...
Definition: DtSoundComponent.h:77
Contains various enum classes relating to model sets.
ImGui debug panel renderer for DtSoundComponentSystem.
Definition: DtSoundComponentSystemImGui.h:35

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)