Skip to content

Commit

Permalink
WIP audio stream fade
Browse files Browse the repository at this point in the history
  • Loading branch information
Valla-Chan committed Oct 1, 2023
1 parent 94e5dbe commit 5ec2046
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scene/audio/audio_stream_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,20 @@ Ref<AudioStream> AudioStreamPlayer::get_stream() const {
return stream;
}

void AudioStreamPlayer::set_fade_in_time(float p_time) {
fade_in_time = p_time;
}
float AudioStreamPlayer::get_fade_in_time() const {
return fade_in_time;
}

void AudioStreamPlayer::set_fade_out_time(float p_time) {
fade_out_time = p_time;
}
float AudioStreamPlayer::get_fade_out_time() const {
return fade_out_time;
}

void AudioStreamPlayer::set_volume_db(float p_volume) {
volume_db = p_volume;
}
Expand Down Expand Up @@ -420,6 +434,9 @@ AudioStreamPlayer::AudioStreamPlayer() {
fadeout_buffer.resize(512);
use_fadeout = false;

fade_in_time = 0.0;
fade_out_time = 0.0;

AudioServer::get_singleton()->connect("bus_layout_changed", this, "_bus_layout_changed");
}

Expand Down
9 changes: 9 additions & 0 deletions scene/audio/audio_stream_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class AudioStreamPlayer : public Node {
SafeFlag setstop;
SafeFlag stop_has_priority;

float fade_in_time;
float fade_out_time;

float mix_volume_db;
float pitch_scale;
float volume_db;
Expand Down Expand Up @@ -86,6 +89,12 @@ class AudioStreamPlayer : public Node {
void set_stream(Ref<AudioStream> p_stream);
Ref<AudioStream> get_stream() const;

void set_fade_in_time(float p_time);
float get_fade_in_time() const;

void set_fade_out_time(float p_time);
float get_fade_out_time() const;

void set_volume_db(float p_volume);
float get_volume_db() const;

Expand Down

0 comments on commit 5ec2046

Please sign in to comment.