From 39a90751dc342c81e76a1c443e2e1eb83cf329f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Douglas=20Le=C3=A3o?= <60024671+DeeJayLSP@users.noreply.github.com> Date: Sun, 10 Oct 2021 13:20:56 -0300 Subject: Allow AudioStreamPlayer(2D) to provide `pitch_scale` on playback --- scene/2d/audio_stream_player_2d.cpp | 2 +- scene/3d/audio_stream_player_3d.cpp | 2 +- scene/audio/audio_stream_player.cpp | 2 +- servers/audio_server.cpp | 6 +++--- servers/audio_server.h | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index bddc342c1a..18a50ae098 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -68,7 +68,7 @@ void AudioStreamPlayer2D::_notification(int p_what) { active.set(); Ref new_playback = stream->instance_playback(); ERR_FAIL_COND_MSG(new_playback.is_null(), "Failed to instantiate playback."); - AudioServer::get_singleton()->start_playback_stream(new_playback, _get_actual_bus(), volume_vector, setplay.get()); + AudioServer::get_singleton()->start_playback_stream(new_playback, _get_actual_bus(), volume_vector, setplay.get(), pitch_scale); stream_playbacks.push_back(new_playback); setplay.set(-1); } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index a54b10ba70..c422070480 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -282,7 +282,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { ERR_FAIL_COND_MSG(new_playback.is_null(), "Failed to instantiate playback."); Map> bus_map; bus_map[_get_actual_bus()] = volume_vector; - AudioServer::get_singleton()->start_playback_stream(new_playback, bus_map, setplay.get(), linear_attenuation, attenuation_filter_cutoff_hz, actual_pitch_scale); + AudioServer::get_singleton()->start_playback_stream(new_playback, bus_map, setplay.get(), actual_pitch_scale, linear_attenuation, attenuation_filter_cutoff_hz); stream_playbacks.push_back(new_playback); setplay.set(-1); } diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 0334ba667b..d2fd65d3d9 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -135,7 +135,7 @@ void AudioStreamPlayer::play(float p_from_pos) { Ref stream_playback = stream->instance_playback(); ERR_FAIL_COND_MSG(stream_playback.is_null(), "Failed to instantiate playback."); - AudioServer::get_singleton()->start_playback_stream(stream_playback, bus, _get_volume_vector(), p_from_pos); + AudioServer::get_singleton()->start_playback_stream(stream_playback, bus, _get_volume_vector(), p_from_pos, pitch_scale); stream_playbacks.push_back(stream_playback); active.set(); set_process_internal(true); diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index ac1569c15d..a420134626 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -1112,16 +1112,16 @@ float AudioServer::get_playback_speed_scale() const { return playback_speed_scale; } -void AudioServer::start_playback_stream(Ref p_playback, StringName p_bus, Vector p_volume_db_vector, float p_start_time) { +void AudioServer::start_playback_stream(Ref p_playback, StringName p_bus, Vector p_volume_db_vector, float p_start_time, float p_pitch_scale) { ERR_FAIL_COND(p_playback.is_null()); Map> map; map[p_bus] = p_volume_db_vector; - start_playback_stream(p_playback, map, p_start_time); + start_playback_stream(p_playback, map, p_start_time, p_pitch_scale); } -void AudioServer::start_playback_stream(Ref p_playback, Map> p_bus_volumes, float p_start_time, float p_highshelf_gain, float p_attenuation_cutoff_hz, float p_pitch_scale) { +void AudioServer::start_playback_stream(Ref p_playback, Map> p_bus_volumes, float p_start_time, float p_pitch_scale, float p_highshelf_gain, float p_attenuation_cutoff_hz) { ERR_FAIL_COND(p_playback.is_null()); AudioStreamPlaybackListNode *playback_node = new AudioStreamPlaybackListNode(); diff --git a/servers/audio_server.h b/servers/audio_server.h index a60d4ae4c4..46873845dc 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -368,9 +368,9 @@ public: float get_playback_speed_scale() const; // Convenience method. - void start_playback_stream(Ref p_playback, StringName p_bus, Vector p_volume_db_vector, float p_start_time = 0); + void start_playback_stream(Ref p_playback, StringName p_bus, Vector p_volume_db_vector, float p_start_time = 0, float p_pitch_scale = 1); // Expose all parameters. - void start_playback_stream(Ref p_playback, Map> p_bus_volumes, float p_start_time = 0, float p_highshelf_gain = 0, float p_attenuation_cutoff_hz = 0, float p_pitch_scale = 1); + void start_playback_stream(Ref p_playback, Map> p_bus_volumes, float p_start_time = 0, float p_pitch_scale = 1, float p_highshelf_gain = 0, float p_attenuation_cutoff_hz = 0); void stop_playback_stream(Ref p_playback); void set_playback_bus_exclusive(Ref p_playback, StringName p_bus, Vector p_volumes); -- cgit v1.2.3