From 49b6067aba3d3720293626ecbe9a277e59cac3a6 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 7 Aug 2023 17:33:07 +0200 Subject: [PATCH] Use StringName consistently to refer to the Master audio bus name --- scene/2d/area_2d.cpp | 2 +- scene/2d/audio_stream_player_2d.cpp | 6 +++--- scene/2d/audio_stream_player_2d.h | 3 ++- scene/3d/area_3d.cpp | 4 ++-- scene/3d/area_3d.h | 5 +++-- scene/3d/audio_stream_player_3d.cpp | 3 ++- scene/audio/audio_stream_player.cpp | 2 +- scene/audio/audio_stream_player.h | 3 ++- scene/gui/video_stream_player.cpp | 2 +- scene/scene_string_names.cpp | 3 +++ scene/scene_string_names.h | 2 ++ servers/audio_server.cpp | 7 ++++--- 12 files changed, 26 insertions(+), 16 deletions(-) diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 2ea7a8d6aef..3aa2a71a2cd 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -510,7 +510,7 @@ StringName Area2D::get_audio_bus_name() const { return audio_bus; } } - return "Master"; + return SceneStringNames::get_singleton()->Master; } void Area2D::_validate_property(PropertyInfo &p_property) const { diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 343dd82b876..dac31058bd9 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -116,10 +116,10 @@ StringName AudioStreamPlayer2D::_get_actual_bus() { //check if any area is diverting sound into a bus Ref world_2d = get_world_2d(); - ERR_FAIL_COND_V(world_2d.is_null(), SNAME("Master")); + ERR_FAIL_COND_V(world_2d.is_null(), SceneStringNames::get_singleton()->Master); PhysicsDirectSpaceState2D *space_state = PhysicsServer2D::get_singleton()->space_get_direct_state(world_2d->get_space()); - ERR_FAIL_COND_V(space_state == nullptr, SNAME("Master")); + ERR_FAIL_COND_V(space_state == nullptr, SceneStringNames::get_singleton()->Master); PhysicsDirectSpaceState2D::ShapeResult sr[MAX_INTERSECT_AREAS]; PhysicsDirectSpaceState2D::PointParameters point_params; @@ -316,7 +316,7 @@ StringName AudioStreamPlayer2D::get_bus() const { return default_bus; } } - return SNAME("Master"); + return SceneStringNames::get_singleton()->Master; } void AudioStreamPlayer2D::set_autoplay(bool p_enable) { diff --git a/scene/2d/audio_stream_player_2d.h b/scene/2d/audio_stream_player_2d.h index 9b23fd39435..a4677bef36d 100644 --- a/scene/2d/audio_stream_player_2d.h +++ b/scene/2d/audio_stream_player_2d.h @@ -32,6 +32,7 @@ #define AUDIO_STREAM_PLAYER_2D_H #include "scene/2d/node_2d.h" +#include "scene/scene_string_names.h" #include "servers/audio/audio_stream.h" #include "servers/audio_server.h" @@ -66,7 +67,7 @@ private: float volume_db = 0.0; float pitch_scale = 1.0; bool autoplay = false; - StringName default_bus = SNAME("Master"); + StringName default_bus = SceneStringNames::get_singleton()->Master; int max_polyphony = 1; void _set_playing(bool p_enable); diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp index 29d151b7263..beb6892435a 100644 --- a/scene/3d/area_3d.cpp +++ b/scene/3d/area_3d.cpp @@ -573,7 +573,7 @@ StringName Area3D::get_audio_bus_name() const { return audio_bus; } } - return "Master"; + return SceneStringNames::get_singleton()->Master; } void Area3D::set_use_reverb_bus(bool p_enable) { @@ -594,7 +594,7 @@ StringName Area3D::get_reverb_bus_name() const { return reverb_bus; } } - return "Master"; + return SceneStringNames::get_singleton()->Master; } void Area3D::set_reverb_amount(float p_amount) { diff --git a/scene/3d/area_3d.h b/scene/3d/area_3d.h index 454c8c29606..86602d3192d 100644 --- a/scene/3d/area_3d.h +++ b/scene/3d/area_3d.h @@ -33,6 +33,7 @@ #include "core/templates/vset.h" #include "scene/3d/collision_object_3d.h" +#include "scene/scene_string_names.h" class Area3D : public CollisionObject3D { GDCLASS(Area3D, CollisionObject3D); @@ -134,10 +135,10 @@ private: void _clear_monitoring(); bool audio_bus_override = false; - StringName audio_bus = "Master"; + StringName audio_bus = SceneStringNames::get_singleton()->Master; bool use_reverb_bus = false; - StringName reverb_bus = "Master"; + StringName reverb_bus = SceneStringNames::get_singleton()->Master; float reverb_amount = 0.0; float reverb_uniformity = 0.0; diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index ac626d0d2a5..8147521a01b 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -35,6 +35,7 @@ #include "scene/3d/audio_listener_3d.h" #include "scene/3d/camera_3d.h" #include "scene/main/viewport.h" +#include "scene/scene_string_names.h" // Based on "A Novel Multichannel Panning Method for Standard and Arbitrary Loudspeaker Configurations" by Ramy Sadek and Chris Kyriakakis (2004) // Speaker-Placement Correction Amplitude Panning (SPCAP) @@ -635,7 +636,7 @@ StringName AudioStreamPlayer3D::get_bus() const { return bus; } } - return SNAME("Master"); + return SceneStringNames::get_singleton()->Master; } void AudioStreamPlayer3D::set_autoplay(bool p_enable) { diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 6c37d6f81d4..ae68bd719bf 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -200,7 +200,7 @@ StringName AudioStreamPlayer::get_bus() const { return bus; } } - return SNAME("Master"); + return SceneStringNames::get_singleton()->Master; } void AudioStreamPlayer::set_autoplay(bool p_enable) { diff --git a/scene/audio/audio_stream_player.h b/scene/audio/audio_stream_player.h index d1f6fca2eef..c0c25aa9837 100644 --- a/scene/audio/audio_stream_player.h +++ b/scene/audio/audio_stream_player.h @@ -33,6 +33,7 @@ #include "core/templates/safe_refcount.h" #include "scene/main/node.h" +#include "scene/scene_string_names.h" #include "servers/audio/audio_stream.h" class AudioStreamPlayer : public Node { @@ -54,7 +55,7 @@ private: float pitch_scale = 1.0; float volume_db = 0.0; bool autoplay = false; - StringName bus = SNAME("Master"); + StringName bus = SceneStringNames::get_singleton()->Master; int max_polyphony = 1; MixTarget mix_target = MIX_TARGET_STEREO; diff --git a/scene/gui/video_stream_player.cpp b/scene/gui/video_stream_player.cpp index f6e558fe577..ac098441280 100644 --- a/scene/gui/video_stream_player.cpp +++ b/scene/gui/video_stream_player.cpp @@ -451,7 +451,7 @@ StringName VideoStreamPlayer::get_bus() const { return bus; } } - return "Master"; + return SceneStringNames::get_singleton()->Master; } void VideoStreamPlayer::_validate_property(PropertyInfo &p_property) const { diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index f0971f1a340..cf8ece0d4c7 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -193,6 +193,9 @@ SceneStringNames::SceneStringNames() { path_pp = NodePath(".."); + // Audio bus name. + Master = StaticCString::create("Master"); + _default = StaticCString::create("default"); _window_group = StaticCString::create("_window_group"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index f31cf7b8816..10b71e2a2a1 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -204,6 +204,8 @@ public: StringName output; + StringName Master; + StringName parameters_base_path; StringName _window_group; diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 49991e41d33..2308fcca9eb 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -40,6 +40,7 @@ #include "core/string/string_name.h" #include "core/templates/pair.h" #include "scene/resources/audio_stream_wav.h" +#include "scene/scene_string_names.h" #include "servers/audio/audio_driver_dummy.h" #include "servers/audio/effects/audio_effect_compressor.h" @@ -747,7 +748,7 @@ void AudioServer::set_bus_count(int p_count) { buses[i]->bypass = false; buses[i]->volume_db = 0; if (i > 0) { - buses[i]->send = "Master"; + buses[i]->send = SceneStringNames::get_singleton()->Master; } bus_map[attempt] = buses[i]; @@ -1582,7 +1583,7 @@ void AudioServer::set_bus_layout(const Ref &p_bus_layout) { for (int i = 0; i < p_bus_layout->buses.size(); i++) { Bus *bus = memnew(Bus); if (i == 0) { - bus->name = "Master"; + bus->name = SceneStringNames::get_singleton()->Master; } else { bus->name = p_bus_layout->buses[i].name; bus->send = p_bus_layout->buses[i].send; @@ -1891,5 +1892,5 @@ void AudioBusLayout::_get_property_list(List *p_list) const { AudioBusLayout::AudioBusLayout() { buses.resize(1); - buses.write[0].name = "Master"; + buses.write[0].name = SceneStringNames::get_singleton()->Master; }