From 3a372994432cf7d65bfcd216573a33cea16abe48 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Mon, 9 Feb 2026 16:27:16 -0800 Subject: [PATCH] Add fountain positional ambient sounds Implemented fountain sounds as positional audio emitters: Technical details: - Added fountainSounds_ library (FountainSmallMediumLoop.wav) - Fountain type already existed in AmbientType enum but was unused - 6 second loop interval for fountain sounds - Volume at 0.8x water volume for gentle bubbling effect - Max distance: 35 units (same as other water sources) - Counted in activeWaterCount limit (max 3 water sources at once) - Spatial 3D audio based on fountain position - Can be placed via addEmitter(position, AmbientType::FOUNTAIN) --- include/audio/ambient_sound_manager.hpp | 1 + src/audio/ambient_sound_manager.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/audio/ambient_sound_manager.hpp b/include/audio/ambient_sound_manager.hpp index c55d53df..6b4c7469 100644 --- a/include/audio/ambient_sound_manager.hpp +++ b/include/audio/ambient_sound_manager.hpp @@ -106,6 +106,7 @@ private: std::vector waterSounds_; std::vector riverSounds_; std::vector waterfallSounds_; + std::vector fountainSounds_; std::vector windSounds_; std::vector tavernSounds_; std::vector blacksmithSounds_; diff --git a/src/audio/ambient_sound_manager.cpp b/src/audio/ambient_sound_manager.cpp index a75514f5..d0131bbb 100644 --- a/src/audio/ambient_sound_manager.cpp +++ b/src/audio/ambient_sound_manager.cpp @@ -66,6 +66,10 @@ bool AmbientSoundManager::initialize(pipeline::AssetManager* assets) { waterfallSounds_.resize(1); loadSound("Sound\\Doodad\\WaterFallSmall.wav", waterfallSounds_[0], assets); + // Load fountain sounds + fountainSounds_.resize(1); + loadSound("Sound\\Doodad\\FountainSmallMediumLoop.wav", fountainSounds_[0], assets); + // Load wind/ambience sounds windSounds_.resize(1); bool windLoaded = loadSound("Sound\\Ambience\\ZoneAmbience\\ForestNormalDay.wav", windSounds_[0], assets); @@ -304,7 +308,8 @@ void AmbientSoundManager::updatePositionalEmitters(float deltaTime, const glm::v isFire = true; } else if (emitter.type == AmbientType::WATER_SURFACE || emitter.type == AmbientType::RIVER || - emitter.type == AmbientType::WATERFALL) { + emitter.type == AmbientType::WATERFALL || + emitter.type == AmbientType::FOUNTAIN) { maxDist = MAX_WATER_DISTANCE; isWater = true; } @@ -379,6 +384,14 @@ void AmbientSoundManager::updatePositionalEmitters(float deltaTime, const glm::v } break; + case AmbientType::FOUNTAIN: + if (emitter.lastPlayTime >= 6.0f && !fountainSounds_.empty() && fountainSounds_[0].loaded) { + float volume = WATER_VOLUME * 0.8f * volumeScale_ * (1.0f - (distance / maxDist)); + AudioEngine::instance().playSound3D(fountainSounds_[0].data, emitter.position, volume); + emitter.lastPlayTime = 0.0f; + } + break; + default: break; }