![]() |
VR-Forces Developer's Guide
|
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.

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 |
|
virtualdefault |
Virtual destructor.
|
explicitprotected |
Protected constructor; use instance().
Connects to DtBallisticSoundSettingsManager::signal_settingsChanged and DtDe::signal_postInitialize. No external wiring is required.
| de | Simulation environment reference. |
|
static |
Returns or creates the per-DtDe singleton.
| de | Simulation environment. |
|
static |
Registers a custom subclass; must be called before the first instance().
| de | Simulation environment. |
| mgr | Caller-owned subclass instance. |
|
static |
Returns the DtDe registration key.
|
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.
| groupName | Name of the DtBallisticSoundGroup to preview. |
|
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.
|
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.
|
protectedvirtual |
Slot connected to DtBallisticSoundProxy::signal_soundTriggers. Ticks the pool, then dispatches each trigger to a stream slot.
|
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.
|
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.
|
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.
|
protectedvirtual |
Resolves groupName to a stable 0-based index, assigning one if new. Returns -1 when the name is empty (unmapped/silent).
|
protectedvirtual |
Initializes myPool with mySettings->myMaxResults stream slots. Each slot is pre-loaded with all groups and started immediately.
|
protectedvirtual |
Rebuilds myPreviewStream from groups as a non-3D procedural sound. Called by slot_settingsChanged() after initPool().
| groups | Group definitions to load as layers. |
|
protectedvirtual |
Advances all pool slots by one tick.
| dt | Elapsed simulation time in seconds. |
| simTime | Absolute simulation time in seconds. |
|
protectedvirtual |
Find the pool slot already assigned to burstId, or nullptr.
|
protectedvirtual |
Find any free pool slot, or nullptr if all are in use.
|
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.
|
protectedvirtual |
Convert an observer-distance and base dB level to a per-trigger dB.
|
protected |
Reference to the simulation environment.
|
protected |
Non-owning pointer to the settings manager's record; stable for manager lifetime. Set during slot_postInitialize(); kept current by slot_settingsChanged().
|
protected |
Maps stable 0-based GPU index to group name. Append-only; indices are never reassigned so in-flight bullets remain valid.
|
protected |
Stream pool; one slot per allowed concurrent burst.
|
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.
|
protected |
Absolute simulation time recorded at the start of each tick.
|
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.
|
protected |
Random number generator for per-event pitch and gain variance.
|
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.
|
protected |
Manages signal/slot lifetime connections.