summaryrefslogtreecommitdiffstats
path: root/modules/interactive_music/audio_stream_interactive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/interactive_music/audio_stream_interactive.cpp')
-rw-r--r--modules/interactive_music/audio_stream_interactive.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/modules/interactive_music/audio_stream_interactive.cpp b/modules/interactive_music/audio_stream_interactive.cpp
index 01764d66ed..8656be988d 100644
--- a/modules/interactive_music/audio_stream_interactive.cpp
+++ b/modules/interactive_music/audio_stream_interactive.cpp
@@ -777,7 +777,7 @@ void AudioStreamPlaybackInteractive::_queue(int p_to_clip_index, bool p_is_auto_
if (stream->clips[p_to_clip_index].auto_advance == AudioStreamInteractive::AUTO_ADVANCE_ENABLED) {
int next_clip = stream->clips[p_to_clip_index].auto_advance_next_clip;
- if (next_clip >= 0 && next_clip < (int)stream->clip_count && states[next_clip].playback.is_valid() && next_clip != p_to_clip_index && next_clip != playback_current && (!transition.use_filler_clip || next_clip != transition.filler_clip)) {
+ if (next_clip >= 0 && next_clip < (int)stream->clip_count && states[next_clip].playback.is_valid() && next_clip != p_to_clip_index && (!transition.use_filler_clip || next_clip != transition.filler_clip)) {
auto_advance_to = next_clip;
}
}
@@ -858,10 +858,7 @@ int AudioStreamPlaybackInteractive::mix(AudioFrame *p_buffer, float p_rate_scale
}
if (!active) {
- for (int i = 0; i < p_frames; i++) {
- p_buffer[i] = AudioFrame(0.0, 0.0);
- }
- return p_frames;
+ return 0;
}
int todo = p_frames;
@@ -908,7 +905,9 @@ void AudioStreamPlaybackInteractive::_mix_internal_state(int p_state_idx, int p_
// time to start!
from_frame = state.fade_wait * mix_rate;
state.fade_wait = 0;
- queue_next = state.auto_advance;
+ if (state.fade_speed == 0.0) {
+ queue_next = state.auto_advance;
+ }
playback_current = p_state_idx;
state.first_mix = false;
} else {
@@ -922,7 +921,6 @@ void AudioStreamPlaybackInteractive::_mix_internal_state(int p_state_idx, int p_
state.playback->mix(temp_buffer + from_frame, 1.0, p_frames - from_frame);
double frame_fade_inc = state.fade_speed * frame_inc;
-
for (int i = from_frame; i < p_frames; i++) {
if (state.fade_wait) {
// This is for fade out of existing stream;
@@ -936,6 +934,7 @@ void AudioStreamPlaybackInteractive::_mix_internal_state(int p_state_idx, int p_
state.fade_speed = 0.0;
frame_fade_inc = 0.0;
state.fade_volume = 1.0;
+ queue_next = state.auto_advance;
}
} else if (frame_fade_inc < 0.0) {
state.fade_volume += frame_fade_inc;
@@ -976,6 +975,8 @@ void AudioStreamPlaybackInteractive::switch_to_clip_by_name(const StringName &p_
return;
}
+ ERR_FAIL_COND_MSG(stream.is_null(), "Attempted to switch while not playing back any stream.");
+
for (int i = 0; i < stream->get_clip_count(); i++) {
if (stream->get_clip_name(i) == p_name) {
switch_request = i;