Fix AudioStreamRandomizer.random_volume_offset_db not working

This commit is contained in:
jsjtxietian 2023-10-14 10:52:27 +08:00
parent 37ee293be8
commit 34eba41aea

View File

@ -810,7 +810,11 @@ void AudioStreamPlaybackRandomizer::tag_used_streams() {
int AudioStreamPlaybackRandomizer::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) { int AudioStreamPlaybackRandomizer::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) {
if (playing.is_valid()) { if (playing.is_valid()) {
return playing->mix(p_buffer, p_rate_scale * pitch_scale, p_frames); int mixed_samples = playing->mix(p_buffer, p_rate_scale * pitch_scale, p_frames);
for (int samp = 0; samp < mixed_samples; samp++) {
p_buffer[samp] *= volume_scale;
}
return mixed_samples;
} else { } else {
for (int i = 0; i < p_frames; i++) { for (int i = 0; i < p_frames; i++) {
p_buffer[i] = AudioFrame(0, 0); p_buffer[i] = AudioFrame(0, 0);