Initial commit: dynamic music & FX players

Continuous music players (DynamicSoundPlayer, 2D, 3D) with intensity-blended
layers, playlist queue, Loop, fade in/out, pause/resume. One-shot SFX players
(DynamicSoundFXPlayer, 2D, 3D) for overlapping triggers. All variants share
RefCounted core classes via duck-typed property access.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Samson
2026-04-29 14:46:48 +01:00
co-authored by Claude Opus 4.7
commit cb47d89377
28 changed files with 737 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
@tool
@icon("res://addons/gd-dynamic-sound/icon.svg")
class_name DynamicSoundFXPlayer2D
## 2D positional variant of [DynamicSoundFXPlayer].
##
## Each [method play_fx] call triggers a fresh play of the assigned
## [DynamicSound], layered with any plays still in flight, distance-attenuated
## from a 2D position relative to the listener.
extends AudioStreamPlayer2D
## The [DynamicSound] to trigger. Each [method play_fx] call plays a fresh instance.
@export var Sound : DynamicSound;
## Volume mix between intensity layers. Only blended when all three layers are set.
@export_range(0, 1) var Intensity : float = 0;
var _core : DynamicSoundFXPlayerCore;
func _enter_tree() -> void:
if Engine.is_editor_hint() and stream == null:
stream = AudioStreamPolyphonic.new();
func _ready() -> void:
_core = DynamicSoundFXPlayerCore.new(self);
_core.ready();
## Trigger a one-shot of [member Sound]. Layers with any in-flight triggers.
func play_fx() -> void:
if _core: _core.play_fx();