diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index 4a72dab28d..6c1ba1973e 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -143,19 +143,17 @@ static inline uint32_t pack8(uint32_t val) { static void mix_down_one_voice(audiomixer_mixer_obj_t* self, audiomixer_mixervoice_obj_t* voice, bool voices_active, uint32_t* word_buffer, uint32_t length) { - bool voice_done = voice->sample == NULL; - while (!voice_done && length != 0) { + while (length != 0) { if (voice->buffer_length == 0) { if (!voice->more_data) { if (voice->loop) { audiosample_reset_buffer(voice->sample, false, 0); } else { voice->sample = NULL; - voice_done = true; break; } } - if (!voice_done) { + if (voice->sample) { // Load another buffer audioio_get_buffer_result_t result = audiosample_get_buffer(voice->sample, false, 0, (uint8_t**) &voice->remaining_buffer, &voice->buffer_length); // Track length in terms of words. @@ -230,10 +228,8 @@ static void mix_down_one_voice(audiomixer_mixer_obj_t* self, } if (length && !voices_active) { - uint32_t sample_value = self->bits_per_sample == 8 - ? 0x80808080 : 0x80008000; for (uint32_t i = 0; ivoice_count; v++) { audiomixer_mixervoice_obj_t* voice = MP_OBJ_TO_PTR(self->voice[v]); + if(voice->sample) { + mix_down_one_voice(self, voice, voices_active, word_buffer, length); + voices_active = true; + } + } - mix_down_one_voice(self, voice, voices_active, word_buffer, length); - voices_active = true; + if (!voices_active) { + for (uint32_t i = 0; isamples_signed) {