extends SceneTree var failures := 0 func _initialize() -> void: call_deferred("_run") func _check(ok: bool, detail: String) -> void: if not ok: failures += 1 printerr("FAIL: " + detail) func _run() -> void: _check(AssetRoot.pack_ready(), "40250 pack unavailable") var driver: Node = preload("res://audio_driver.gd").new() root.add_child(driver) var sound := "sound/ambience/waterfall.wav" var path: String = driver._find_sound(sound) _check(path == "pack://" + sound, "sound must resolve through 40250 pack") var stream: AudioStream = driver._load_stream(path) _check(stream != null, "packed WAV must decode") if stream != null: driver.set_sound_volume(0.5) driver.play_sound_2d(sound, 0.5) var player: AudioStreamPlayer = driver._ui_pool[0] _check(absf(player.volume_db - linear_to_db(0.5)) < 0.01, "sound volume was applied more than once") driver.play_sound_3d(sound, Vector3.ZERO, 0.5) _check(driver._all_3d.size() == 1, "3D sound not tracked") driver.stop_all_sound_3d() _check(driver._all_3d.is_empty(), "StopAllSound3D left a player running") driver.free() print("PASS: audio_driver_test" if failures == 0 else "FAIL: audio_driver_test") quit(0 if failures == 0 else 1)