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

Manages audio playback for ballistic proximity sounds.

Per-DtDe singleton created by instance(). Wires itself to DtBallisticSoundSettingsManager::signal_settingsChanged and DtDe::signal_postInitialize in its constructor. On post-initialize it connects to DtBallisticSoundProxy::signal_soundTriggers and pushes the current settings to the proxy.

Maintains a pool of DtBallisticSoundStream slots, each wrapping one streaming OpenAL voice. Rounds from the same burst share one slot (burst grouping via DtBallisticBurstRecord::myId). All slots tick() every frame to keep their OpenAL buffers pre-filled with silence, eliminating start latency on the next trigger.

All slots are called from the simulation tick thread only – no internal mutex is needed.

See Also
DtOsgBallisticManager, DtBallisticSoundProxy, DtBallisticSoundTrigger, DtBallisticSoundSettingsRecord
Inheritance diagram for makVrv::DtBallisticSoundManager:
Inheritance graph
[legend]

Public Member Functions

virtual ~DtBallisticSoundManager ()=default
 
virtual void previewGroup (const std::string &groupName)
 
- Public Member Functions inherited from makVrv::DtVirtualBaseClass
 DtVirtualBaseClass ()
 
virtual ~DtVirtualBaseClass ()
 

Static Public Member Functions

static DtBallisticSoundManager & instance (DtDe &de)
 
static void registerInstance (DtDe &de, DtBallisticSoundManager *mgr)
 
static const std::string & theClassName ()
 

Protected Member Functions

 DtBallisticSoundManager (DtDe &de)
 
virtual void slot_postTick ()
 
virtual void slot_postInitialize ()
 
virtual void slot_soundTriggers (const std::vector< DtBallisticSoundTrigger > &triggers)
 
virtual void slot_settingsChanged (const DtBallisticSoundSettingsRecord &record)
 
virtual void slot_masterAudioEnabled (bool enabled)
 
virtual void slot_playbackDeviceInitialized ()
 
virtual int32_t resolveOrAssignGroupIndex (const std::string &groupName)
 
virtual void initPool ()
 
virtual void buildPreviewStream (const std::vector< DtBallisticSoundGroup > &groups)
 
virtual void tickPool (double dt, double simTime)
 
virtual DtBallisticSoundStream * findStreamForRequest (DtUniqueID burstId)
 
virtual DtBallisticSoundStream * findFreeStream ()
 
virtual std::string resolveGroupName (int32_t groupIndex) const
 
virtual float computeDecibels (float distanceMeters) const
 

Protected Attributes

DtDe & myDe
 
const
DtBallisticSoundSettingsRecord * 
mySettings
 
std::vector< std::string > myIndexToGroup
 
std::vector
< DtBallisticSoundStream > 
myPool
 
std::unique_ptr
< DtProceduralSound > 
myPreviewStream
 
double myLastSimTime
 
bool myMasterAudioEnabled
 
std::mt19937 myRng
 
std::atomic< int > myPendingPreviewGroupIdx {-1}
 
DtSignalConnectionManager myConnections
 

Constructor & Destructor Documentation

virtual makVrv::DtBallisticSoundManager::~DtBallisticSoundManager ( )
virtualdefault

Virtual destructor.

makVrv::DtBallisticSoundManager::DtBallisticSoundManager ( DtDe &  de)
explicitprotected

Protected constructor; use instance().

Connects to DtBallisticSoundSettingsManager::signal_settingsChanged and DtDe::signal_postInitialize. No external wiring is required.

Parameters
deSimulation environment reference.

Member Function Documentation

static DtBallisticSoundManager& makVrv::DtBallisticSoundManager::instance ( DtDe &  de)
static

Returns or creates the per-DtDe singleton.

Parameters
deSimulation environment.
static void makVrv::DtBallisticSoundManager::registerInstance ( DtDe &  de,
DtBallisticSoundManager *  mgr 
)
static

Registers a custom subclass; must be called before the first instance().

Parameters
deSimulation environment.
mgrCaller-owned subclass instance.
static const std::string& makVrv::DtBallisticSoundManager::theClassName ( )
static

Returns the DtDe registration key.

virtual void makVrv::DtBallisticSoundManager::previewGroup ( const std::string &  groupName)
virtual

Trigger one preview event on groupName through the live stream pool.

Picks a free stream slot, randomizes pitch and gain within the group's configured ranges, and calls triggerGroup() with the sound source positioned at the current observer so the user hears it at the configured volume.

No-op when: groupName is not found in the current settings, the pool is empty or fully occupied, or the audio device is not ready.

Parameters
groupNameName of the DtBallisticSoundGroup to preview.
virtual void makVrv::DtBallisticSoundManager::slot_postTick ( )
protectedvirtual

Slot connected to DtDe::signal_postTick. Ticks the stream pool every frame so that OpenAL buffers stay pre-filled regardless of whether any ballistic triggers are arriving.

virtual void makVrv::DtBallisticSoundManager::slot_postInitialize ( )
protectedvirtual

Slot connected to DtDe::signal_postInitialize. Seeds pool and settings, connects to DtBallisticSoundProxy::signal_soundTriggers, and registers the group-index resolver with the proxy.

virtual void makVrv::DtBallisticSoundManager::slot_soundTriggers ( const std::vector< DtBallisticSoundTrigger > &  triggers)
protectedvirtual

Slot connected to DtBallisticSoundProxy::signal_soundTriggers. Ticks the pool, then dispatches each trigger to a stream slot.

virtual void makVrv::DtBallisticSoundManager::slot_settingsChanged ( const DtBallisticSoundSettingsRecord &  record)
protectedvirtual

Slot connected to DtBallisticSoundSettingsManager::signal_settingsChanged. Rebuilds the stream pool when groups or myMaxResults change; pushes enabled/radius/maxResults to the ballistic manager proxy when available.

virtual void makVrv::DtBallisticSoundManager::slot_masterAudioEnabled ( bool  enabled)
protectedvirtual

Slot connected to DtAudioSettingsManager::signal_enableAudioChanged. Propagates the master audio enabled state to the GPU sound query so that the compute dispatch stops when audio is globally disabled.

virtual void makVrv::DtBallisticSoundManager::slot_playbackDeviceInitialized ( )
protectedvirtual

Slot connected to DtAudioManager::signal_playbackDeviceInitialized. Rebuilds myPreviewStream once the OpenAL device is ready, so the first preview click does not have to wait for slot_postTick's lazy retry.

virtual int32_t makVrv::DtBallisticSoundManager::resolveOrAssignGroupIndex ( const std::string &  groupName)
protectedvirtual

Resolves groupName to a stable 0-based index, assigning one if new. Returns -1 when the name is empty (unmapped/silent).

virtual void makVrv::DtBallisticSoundManager::initPool ( )
protectedvirtual

Initializes myPool with mySettings->myMaxResults stream slots. Each slot is pre-loaded with all groups and started immediately.

virtual void makVrv::DtBallisticSoundManager::buildPreviewStream ( const std::vector< DtBallisticSoundGroup > &  groups)
protectedvirtual

Rebuilds myPreviewStream from groups as a non-3D procedural sound. Called by slot_settingsChanged() after initPool().

Parameters
groupsGroup definitions to load as layers.
virtual void makVrv::DtBallisticSoundManager::tickPool ( double  dt,
double  simTime 
)
protectedvirtual

Advances all pool slots by one tick.

Parameters
dtElapsed simulation time in seconds.
simTimeAbsolute simulation time in seconds.
virtual DtBallisticSoundStream* makVrv::DtBallisticSoundManager::findStreamForRequest ( DtUniqueID  burstId)
protectedvirtual

Find the pool slot already assigned to burstId, or nullptr.

virtual DtBallisticSoundStream* makVrv::DtBallisticSoundManager::findFreeStream ( )
protectedvirtual

Find any free pool slot, or nullptr if all are in use.

virtual std::string makVrv::DtBallisticSoundManager::resolveGroupName ( int32_t  groupIndex) const
protectedvirtual

Resolve group index to a group name from the current settings. Returns an empty string (no sound) if the index is -1 or out of range.

virtual float makVrv::DtBallisticSoundManager::computeDecibels ( float  distanceMeters) const
protectedvirtual

Convert an observer-distance and base dB level to a per-trigger dB.

Member Data Documentation

DtDe& makVrv::DtBallisticSoundManager::myDe
protected

Reference to the simulation environment.

const DtBallisticSoundSettingsRecord* makVrv::DtBallisticSoundManager::mySettings
protected

Non-owning pointer to the settings manager's record; stable for manager lifetime. Set during slot_postInitialize(); kept current by slot_settingsChanged().

std::vector<std::string> makVrv::DtBallisticSoundManager::myIndexToGroup
protected

Maps stable 0-based GPU index to group name. Append-only; indices are never reassigned so in-flight bullets remain valid.

std::vector<DtBallisticSoundStream> makVrv::DtBallisticSoundManager::myPool
protected

Stream pool; one slot per allowed concurrent burst.

std::unique_ptr<DtProceduralSound> makVrv::DtBallisticSoundManager::myPreviewStream
protected

Non-3D procedural sound used exclusively for settings-page preview.

Non-3D so it plays at full volume without requiring a valid observer position. Rebuilt by slot_settingsChanged() whenever groups change. Ticked by slot_postTick(). Null until the first slot_settingsChanged() call.

double makVrv::DtBallisticSoundManager::myLastSimTime
protected

Absolute simulation time recorded at the start of each tick.

bool makVrv::DtBallisticSoundManager::myMasterAudioEnabled
protected

Mirrors DtAudioSettingsManager::audioEnabled(); updated by slot_masterAudioEnabled(). Gates the GPU sound query and slot_soundTriggers so that no compute work or playback calls are made while audio is globally off.

std::mt19937 makVrv::DtBallisticSoundManager::myRng
protected

Random number generator for per-event pitch and gain variance.

std::atomic<int> makVrv::DtBallisticSoundManager::myPendingPreviewGroupIdx {-1}
protected

Index (into mySettings->myGroups) of a preview trigger posted by the UI thread via previewGroup(). -1 means no trigger is pending. Read and cleared by slot_postTick() on the sim thread so that triggerEvent() is never called from the Qt UI thread.

DtSignalConnectionManager makVrv::DtBallisticSoundManager::myConnections
protected

Manages signal/slot lifetime connections.


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)