VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
- Audio

Table of Contents

VR-Vantage provides a comprehensive audio system covering model-attached sounds, dBFS-calibrated level control, global playback configuration, ambient soundscapes, custom sound behaviors, and listener positioning.

This chapter shows how a toolkit developer authors and controls all of those layers: attaching sounds to individual models, expressing audio levels in dBFS, enabling or muting the audio system at runtime, authoring ambient soundscapes, writing a custom sound behavior, and pinning or directing the audio listener.

The chapter covers the authoring and extension surface only. The internal streaming, voice-pool, and audio-thread scheduling machinery is described in the class documentation and is not required to use the API.

\vrv_audio.1 - Core Concepts

\vrv_audio.2 - Attaching Sounds to Models

A model-attached sound is authored through the model definition's Sound schema. The parser reads the following fields:

Behavior-related fields – sound_behavior_key, sound_behavior_param_*, sound_local_weather_area_enabled, and sound_positional_offset – are read on top of the base schema and route the sound through a named behavior (see .6 - Writing a Custom Sound Behavior). At runtime DtModelSoundCreator attaches and manages the resulting DtSoundComponent for each model instance.

\vrv_audio.3 - Audio Levels in dBFS

All authored levels use decibels relative to full scale. 0 dBFS is the full-scale reference; authored positive values boost a sound up to a fixed ceiling. The DtAudioLevel utility centralizes the scale so that every part of the pipeline agrees:

Author and store levels in dBFS; convert to linear gain only at the point of playback with linearGainFromDbfs().

\vrv_audio.4 - Global Playback Controls

The audio system exposes a set of application-wide knobs that govern playback for the entire session. Each knob is accessible through two authoring paths: DtAudioSettingsManager for persistent, GUI-driven configuration that survives across runs, and DtAudioManager for immediate runtime overrides that apply only to the current session.

Authoring-path duality. DtAudioSettingsManager is the persistent layer. Its signal_*Changed signals are subscribed to by the corresponding DtAudioManager slots (slot_AudioEnabledUpdated, slot_VolumeUpdated, slot_playbackDeviceUpdated, slot_SpeedOfSoundUpdated, slot_MaxVoicesUpdated, slot_EnvironmentalProcessingEnabledUpdated). Writing through DtAudioSettingsManager propagates the value to the runtime immediately via those slots and also persists it so that the application starts with the same value on the next run. DtAudioManager direct setters (setEnabled, setSoundVolume, setSpeedOfSound, setMaxVoices, setEnvironmentalProcessingEnabled) apply immediately to the runtime without touching settings persistence. Use the direct setters for runtime-only overrides such as test harnesses, scripted scenarios, or transient mutes. Rule of thumb: for persistent user-facing changes, go through DtAudioSettingsManager; for runtime-only overrides, go through DtAudioManager directly.

Master mute / enable. DtAudioManager::setEnabled() / isEnabled() silence or restore the entire audio subsystem at runtime. The corresponding persistent path is DtAudioSettingsManager::signal_enableAudioChanged, which triggers the slot_AudioEnabledUpdated slot.

Master volume. DtAudioManager::setSoundVolume() / soundVolume() set the application-wide output gain expressed in dBFS (see .3 - Audio Levels in dBFS). The persistent path is DtAudioSettingsManager::setVolume().

Playback and capture device selection. DtAudioSettingsManager::setAudioPlaybackDevice() and setAudioCaptureDevice() select the output and input hardware devices by name. The available names are enumerated at runtime via DtAudioManager::playbackDeviceList() and captureDeviceList().

Speed of sound. DtAudioManager::setSpeedOfSound() adjusts the propagation speed used for Doppler calculations, expressed in metres per second. The persistent path is DtAudioSettingsManager::setSpeedOfSound().

Max simultaneous voices. DtAudioManager::setMaxVoices() caps the number of concurrently active audio voices. Sources beyond the cap are culled by priority (see sound_priority in .2 - Attaching Sounds to Models). The persistent path is DtAudioSettingsManager::setMaxVoices().

Environmental processing. DtAudioManager::setEnvironmentalProcessingEnabled() enables or disables environmental audio effects (reverb, occlusion). Query hardware support first with DtAudioManager::environmentalProcessingAvailable(). The persistent path is DtAudioSettingsManager::setEnvironmentalProcessingEnabled().

The following snippet shows one persistent change routed through the settings manager and one runtime-only override applied directly to the audio manager:

using namespace makVrv;
// Persistent: raises master volume for this and all future runs.
settings.setVolume(6.0f);
// Runtime-only: mute audio for the duration of an automated test run.
audio.setEnabled(false);
// ... run tests ...
audio.setEnabled(true);

\vrv_audio.5 - Authoring Soundscapes

Ambient soundscapes are authored as a set of channels and then pushed to the runtime. DtProceduralSoundscapesSettingsManager holds the persistent channel set; DtProceduralSoundscapeManager owns the live, playing channels.

using namespace makVrv;
// Author a channel and select the behavior that drives it.
channel.setBehaviorKey("Rain");
settings.addChannel(channel);
// Push the authored channel set to the live runtime.
settings.pushSoundscapesToRuntime();

Each DtProceduralSoundscapeChannel names the behavior that drives it through its behaviorKey. The runtime manager also supports a preview mode (startPreview() / stopPreview()) and direct channel manipulation (addAmbientChannel(), removeAmbientChannel(), clearAllAmbientChannels()) for editors that need immediate feedback.

\vrv_audio.6 - Writing a Custom Sound Behavior

To drive a channel with your own logic, subclass DtProceduralSoundBehavior, provide a matching DtProceduralSoundBehaviorCreator, and register the creator under a key with DtProceduralSoundBehaviorFactory. Channels and model definitions then reference that key (via behaviorKey or sound_behavior_key).

using namespace makVrv;
// 1. The behavior: configure clips in setupSound(), react in update().
class DtSurfBehavior : public DtProceduralSoundBehavior
{
public:
void setupSound(DtProceduralSound& sound, DtDe& de) override;
void update(DtDe& de) override;
};
// 2. The creator that constructs it.
class DtSurfBehaviorCreator : public DtProceduralSoundBehaviorCreator
{
public:
DtDe& /*de*/,
const std::map<std::string, std::string>& /*params*/) override
{
return new DtSurfBehavior();
}
};
// 3. Register under a key (typically in your plugin's init).
"Surf", new DtSurfBehaviorCreator());

The factory takes ownership of the creator. The built-in Rain, Wind, and Visibility behaviors are registered the same way during vrvAudio initialization, so "Rain", "Wind", and "Visibility" are available keys out of the box.

Threading note. setupSound() and update() run on the main simulation thread; the clip-selection and gain/pitch methods run on the audio thread. Communicate simulation state between them with std::atomic members written in update(), and do not touch DtDe or other non-thread-safe data from the audio-thread methods. See the DtProceduralSoundBehavior class documentation for the full contract.

\vrv_audio.7 - Controlling the Audio Listener

The audio listener is the point in the scene from which all positional audio is perceived. DtAudioManager::setListenerLocationType() selects the source of listener position and orientation by setting one of three modes on the ListenerLocationType enum.

ObserverListener (default). The listener tracks whichever observer currently holds input focus, as reported by DtInputDriver::currentObserver(). This is the standard camera-follows- input-focus mode. Within this mode the listener can optionally be pinned to a specific named observer regardless of input focus; see the subsection below.

EntityListener. The listener tracks a specific simulation entity, set with DtAudioManager::setEntityListener(). Pass the DtElementID of the entity to track. This mode is useful for camera-follow-entity scenarios or when the audio perspective should stay locked to a specific platform regardless of where the user's observer is.

ExplicitListener. The caller supplies listener state directly each tick using DtAudioManager::setListenerLocation(), DtAudioManager::setListenerVelocity(), DtAudioManager::setListenerFront(), and DtAudioManager::setListenerUp(). Use this mode for external navigation systems, recorded playback drivers, or any tool that maintains its own kinematic state independent of the simulation observer or entity model.

The internal per-tick feeders kinStateFromObserver() and kinStateFromEntity() run automatically when the corresponding mode is active; ExplicitListener mode bypasses both feeders.

Fixing the listener to a specific observer. When using ObserverListener mode, you can pin the listener to a named observer so it stays at that observer regardless of which observer currently holds input focus. This is useful in playback tools, automated test harnesses, and multi-observer simulations where the audio perspective should remain fixed while the user navigates between viewpoints.

Call DtAudioManager::setFixedListenerObserverName() with the observer name to activate the pin. The pin is stored by name so it survives observer add/remove and can be set before the target observer exists:

using namespace makVrv;
// Pin the listener to a named observer.
audio.setFixedListenerObserverName("Observation Post Alpha");
// Check whether the pin resolved to a live observer.
bool active = audio.isFixedListenerObserverActive();
// Release the pin; the listener reverts to following input focus.
audio.clearFixedListenerObserver();

setFixedListenerObserver(DtObserver*) is a convenience overload that forwards the observer's name; passing nullptr clears the pin.

Resolved-observer contract. All vrvAudio subsystems that need the listener position call DtAudioManager::resolvedListenerObserver() rather than querying the input driver directly. That method applies the following fallback chain: (1) the pinned observer if its name resolves to a live observer, (2) DtInputDriver::currentObserver(), (3) the first observer in the driver's list, (4) nullptr. When no pin is active the behavior is identical to pre-3.3. When a pin is active the method short-circuits at step 1 and the input driver's current-observer state is bypassed entirely.

Listener-change signal. DtAudioManager::signal_audioListenerObserverChanged fires at the end of each tick() when resolvedListenerObserver() returns a different observer than the previous tick. Any audio-aware code that needs to react to listener transitions should subscribe to this signal rather than to DtInputDriverSignaler::signal_currentObserverChanged, because the former reflects pin state correctly while the latter does not. The first tick silently seeds the cached value and does not fire, so there is no spurious notification at startup.

See DtAudioManager -- Fixed Listener Observer in the 3.3 release notes for the full API listing.

Picking the right approach. Prefer the fixed-observer pin (within ObserverListener mode) when the target is an observer that already exists or will exist as a first-class DtObserver – it requires the least setup and handles observer add/remove automatically. Prefer EntityListener when the target is a simulation entity tracked by DtElementID. Prefer ExplicitListener when the audio client maintains its own kinematic state, such as an external camera rig or a recorded-playback driver that supplies positions directly.

\vrv_audio.8 - Complete Example

There is no standalone example driver dedicated to procedural soundscapes yet. The snippets above show the full authoring and extension flow; for a live reference to model-attached audio wiring, see the audio setup in the exampleBallistics driver, which configures ballistic proximity sound through the same DtSoundComponent path described in .2 - Attaching Sounds to Models.

\vrv_audio.9 - Related Reference


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)