![]() |
VR-Forces Developer's Guide
|
Manages a collection of ambient geographic sound channels.
DtProceduralSoundscapeManager is a per-DtDe singleton that drives looping, non-3D DtSoundComponent instances whose volume is controlled each tick by how close the current observer is to polygons in an osgEarth FeatureSource layer.
Each channel is described by a DtProceduralSoundscapeChannel:
The same addAmbientChannel() method handles all sound types (water, forest, city, etc.) - there are no type-specific registration methods.
Follows the DtSoundComponentSystem pattern:
soundFile starts with makVrv::kProceduralSoundPrefix ("ProceduralSound:") or with "ModelDefinition:". Raw file paths are no longer accepted. 
Classes | |
| struct | ChannelState |
Public Member Functions | |
| virtual | ~DtProceduralSoundscapeManager () |
| DtProceduralSoundscapeManager (const DtProceduralSoundscapeManager &)=delete | |
| DtProceduralSoundscapeManager (DtProceduralSoundscapeManager &&)=delete | |
| DtProceduralSoundscapeManager & | operator= (const DtProceduralSoundscapeManager &)=delete |
| DtProceduralSoundscapeManager & | operator= (DtProceduralSoundscapeManager &&)=delete |
| virtual void | addAmbientChannel (const DtProceduralSoundscapeChannel &channel) |
| virtual void | removeAmbientChannel (const std::string &name) |
| virtual void | clearAllAmbientChannels () |
| virtual void | startPreview (const DtProceduralSoundscapeChannel &channel) |
| virtual void | stopPreview () |
| virtual bool | isPreviewActive () const |
Public Member Functions inherited from makVrv::DtVirtualBaseClass | |
| DtVirtualBaseClass () | |
| virtual | ~DtVirtualBaseClass () |
Static Public Member Functions | |
| static DtProceduralSoundscapeManager & | instance (DtDe &de) |
| static void | registerInstance (DtDe &de, DtProceduralSoundscapeManager *mgr) |
| static const std::string & | theClassName () |
Protected Member Functions | |
| DtProceduralSoundscapeManager (DtDe &de) | |
| virtual void | slot_mapNodeFound (DtTerrainPatchObject &tpo) |
| virtual void | slot_postTick () |
| virtual void | handleDelayedSoundCreation () |
| virtual void | slot_audioEnabledChanged (bool enabled) |
| virtual void | createChannelSound (std::size_t channelIndex) |
| virtual void | slot_initImGui () |
| virtual void | slot_renderImGui () |
| virtual DtUniqueID | generateLocalUniqueId () |
| virtual void | slot_audioListenerObserverChanged (DtObserver *observer) |
| virtual void | slot_currentObserverModeChanged (int observerMode) |
| virtual void | slot_postInitializeObserver () |
| virtual void | slot_soundsChanged (const std::vector< DtProceduralSoundConfig > &sounds) |
Protected Attributes | |
| DtDe & | myDe |
| std::vector< ChannelState > | myChannels |
| std::vector< std::unique_ptr < DtProceduralSoundPlayer > > | myProceduralPlayers |
| std::unique_ptr < DtProceduralSoundscapeQuery > | myQuery |
| DtSignalConnectionManager | myConnections |
| DtSignalConnectionManager | myCurrentObserverConnection |
| DtObserver * | myCurrentObserver = nullptr |
| DtModelSetId | myCurrentModelSet = DtModelSetId::Models3D |
| double | myLastSimTime = -1.0 |
| std::unique_ptr< DtSoundComponent > | myPreviewWavSound |
| std::unique_ptr < DtProceduralSoundPlayer > | myPreviewProceduralPlayer |
|
virtual |
|
delete |
|
delete |
|
explicitprotected |
Protected constructor - use instance(DtDe&).
|
static |
Get or create the DtProceduralSoundscapeManager singleton for de. Use DtProceduralSoundscapeManager::registerInstance() to substitute a subclass.
|
static |
Register a custom instance (must be called before the first instance() call).
|
static |
Get the name used to register this class with DtDe.
|
delete |
|
delete |
|
virtual |
Register an ambient sound channel.
If the audio playback device is already initialized and the MapNode is available, the underlying DtSoundComponent is created immediately. Otherwise creation is deferred until both are ready.
Channels with the same name replace any existing channel with that name.
| channel | Channel configuration including sound file and feature layer query. |
|
virtual |
Remove the channel with the given name and stop its sound. No-op if no channel with that name exists.
|
virtual |
Remove all registered channels and stop all sounds.
|
virtual |
Start previewing a channel at full configured volume, bypassing the proximity gate. Any already-active preview is stopped first. For looping-file channels the WAV is played immediately (requires audio device to be initialised). For procedural channels the soundscape is created and ticked each frame via slot_postTick.
|
virtual |
Stop any active preview. No-op if no preview is running.
|
virtual |
Return true if a preview is currently running.
|
protectedvirtual |
Slot connected to DtTerrainPatchObjectSignaler::signal_osgEarthMapNodeFound. Stores the MapNode and creates any channels that were registered before the map loaded.
|
protectedvirtual |
Slot connected to DtDe::signal_postTick. Queries each channel's feature layer and adjusts DtSoundComponent decibel levels.
|
protectedvirtual |
Slot connected to DtAudioManager::signal_playbackDeviceInitialized. Creates DtSoundComponent instances for channels that were registered before the audio device was ready.
|
protectedvirtual |
Slot connected to DtAudioSettingsManager::signal_enableAudioChanged.
When enabled is true, resets the soundPlaying flag on all looping-file channels so that slot_postTick restarts them on the next frame. When enabled is false, this function is a no-op.
| enabled | The new audio-enabled state. |
|
protectedvirtual |
Create and start the DtSoundComponent for one channel state entry. Does nothing if the sound has already been created or the device is not ready.
|
protectedvirtual |
Slot connected to DtDe::signal_postInitialize. Defers the renderer signal connection until the renderer is ready.
|
protectedvirtual |
Slot connected to DtRenderer::signal_update. Emits the "Procedural Soundscapes Settings" ImGui debug tree node each rendered frame.
|
protectedvirtual |
Generate a unique ID for a locally-owned DtSoundComponent or DtProceduralSoundPlayer.
Uses a monotonically increasing atomic counter seeded at 0xAB000000. These IDs are never registered with the distributed object system, so collisions with networked entities are not possible.
|
protectedvirtual |
Handle observer switching – re-bind myCurrentObserverConnection. Slot connected to DtAudioManager::signal_audioListenerObserverChanged.
|
protectedvirtual |
Handle observer mode change – update myCurrentModelSet.
|
protectedvirtual |
Called once after DtDe::signal_postInitialize to safely connect observer tracking.
|
protectedvirtual |
Re-create any behavior-backed channels whose tier sources reference a ProceduralSound key that was just updated in DtProceduralSoundsSettingsManager.
|
protected |
|
protected |
All registered looping-file channels with their active sound components.
|
protected |
All registered procedural channels. Indexed in parallel with removal by name.
|
protected |
The osgEarth query helper. Null until signal_osgEarthMapNodeFound fires.
|
protected |
Signal connections (DtDe::signal_postTick, terrain signaler, audio device).
|
protected |
Signal connections scoped to the current observer's lifetime.
|
protected |
Observer whose mode determines the active model set.
|
protected |
Model set currently active for the observer. Channels disabled for this model set are silenced in slot_postTick.
|
protected |
Simulation time at the end of the previous slot_postTick, used to compute dt.
|
protected |
Preview state - at most one of these is non-null at any time.
|
protected |