From f8ea6ebf0d330b36686d15bc66b6829f8d5534fa Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 3 Apr 2022 01:56:32 +0200 Subject: [PATCH] :wrench: Mute music below a certain threshold --- project.godot | 4 ++++ src/default_bus_layout.tres | 9 +++++++++ src/levels/Game.tscn | 6 +++--- src/levels/PhaseOneMusic.gd | 6 +++++- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/default_bus_layout.tres diff --git a/project.godot b/project.godot index 12e1679..a7ad8fb 100644 --- a/project.godot +++ b/project.godot @@ -13,6 +13,10 @@ config_version=4 config/name="LD50" run/main_scene="res://src/levels/Game.tscn" +[audio] + +default_bus_layout="res://src/default_bus_layout.tres" + [display] window/size/width=1280 diff --git a/src/default_bus_layout.tres b/src/default_bus_layout.tres new file mode 100644 index 0000000..16e8f40 --- /dev/null +++ b/src/default_bus_layout.tres @@ -0,0 +1,9 @@ +[gd_resource type="AudioBusLayout" format=2] + +[resource] +bus/1/name = "Mute" +bus/1/solo = false +bus/1/mute = true +bus/1/bypass_fx = false +bus/1/volume_db = -80.0 +bus/1/send = "Master" diff --git a/src/levels/Game.tscn b/src/levels/Game.tscn index 2a29094..bc971ef 100644 --- a/src/levels/Game.tscn +++ b/src/levels/Game.tscn @@ -24,17 +24,17 @@ fire_path = NodePath("../PhaseOneContainer/Fire") [node name="Bell" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"] stream = ExtResource( 10 ) -volume_db = -60.0 +volume_db = -80.0 autoplay = true [node name="Choir" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"] stream = ExtResource( 8 ) -volume_db = -60.0 +volume_db = -80.0 autoplay = true [node name="Drum" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"] stream = ExtResource( 9 ) -volume_db = -60.0 +volume_db = -80.0 autoplay = true [node name="PhaseOneContainer" type="Node2D" parent="PhaseOne"] diff --git a/src/levels/PhaseOneMusic.gd b/src/levels/PhaseOneMusic.gd index 31c9c28..e2746b4 100644 --- a/src/levels/PhaseOneMusic.gd +++ b/src/levels/PhaseOneMusic.gd @@ -17,6 +17,10 @@ func _ready(): func _on_fire_intensity_changed(value): $Choir.volume_db = (smoothstep(choir_min, choir_max, value) - 1) * 60 + $Choir.bus = "Master" if $Choir.volume_db > -60 else "Mute" + $Bell.volume_db = (smoothstep(bell_min, bell_max, value) - 1) * 60 + $Bell.bus = "Master" if $Choir.volume_db > -60 else "Mute" + $Drum.volume_db = (smoothstep(drum_min, drum_max, value) - 1) * 60 - pass + $Drum.bus = "Master" if $Choir.volume_db > -60 else "Mute"