Add sound effects, ambient music and volume mixing (0.5.0)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Denis Defolie
2026-10-11 22:57:37 +02:00
parent dbf513e686
commit 2d7001105d
40 changed files with 665 additions and 26 deletions
+44
View File
@@ -0,0 +1,44 @@
extends GutTest
## Chaque identifiant sonore pointe vers un fichier present ; un identifiant
## inconnu ne produit jamais de chemin libre.
func test_every_sfx_file_exists() -> void:
for sfx_id in SoundCatalog.SFX_IDS:
assert_true(ResourceLoader.exists(SoundCatalog.sfx_path(sfx_id)), sfx_id)
func test_every_music_file_exists() -> void:
for music_id in SoundCatalog.MUSIC_IDS:
assert_true(ResourceLoader.exists(SoundCatalog.music_path(music_id)), music_id)
func test_unknown_ids_give_no_path() -> void:
assert_eq(SoundCatalog.sfx_path("../../etc/passwd"), "")
assert_eq(SoundCatalog.music_path("inconnue"), "")
func test_music_follows_the_level() -> void:
assert_eq(SoundCatalog.music_for_level("CE1"), "forest")
assert_eq(SoundCatalog.music_for_level("CE2"), "marsh")
func test_audio_manager_plays_without_crashing_and_remembers_music() -> void:
AudioManager.play_sfx("success")
AudioManager.play_music("marsh")
assert_eq(AudioManager.current_music_id(), "marsh")
AudioManager.play_music("marsh")
AudioManager.stop_music()
assert_eq(AudioManager.current_music_id(), "")
func test_buses_exist_and_are_idempotent() -> void:
AudioBuses.ensure()
AudioBuses.ensure()
assert_ne(AudioServer.get_bus_index(AudioBuses.MUSIC), -1)
assert_ne(AudioServer.get_bus_index(AudioBuses.EFFECTS), -1)
var count := 0
for i in AudioServer.bus_count:
if AudioServer.get_bus_name(i) == AudioBuses.MUSIC:
count += 1
assert_eq(count, 1)
+1
View File
@@ -0,0 +1 @@
uid://c61j06k8itgcq
+7
View File
@@ -35,3 +35,10 @@ func test_zero_volume_is_real_silence() -> void:
assert_eq(AppSettings.volume_db(0.0), -80.0)
assert_eq(AppSettings.volume_db(1.0), 0.0)
assert_lt(AppSettings.volume_db(0.5), 0.0)
func test_music_and_effects_volumes_are_bounded() -> void:
var clean := AppSettings.sanitize({"music_volume": 3, "effects_volume": -1})
assert_eq(clean["music_volume"], 1.0)
assert_eq(clean["effects_volume"], 0.0)
assert_eq(AppSettings.sanitize({})["music_volume"], AppSettings.defaults()["music_volume"])