@@ -143,19 +143,17 @@ static inline uint32_t pack8(uint32_t val) {
143
143
static void mix_down_one_voice (audiomixer_mixer_obj_t * self ,
144
144
audiomixer_mixervoice_obj_t * voice , bool voices_active ,
145
145
uint32_t * word_buffer , uint32_t length ) {
146
- bool voice_done = voice -> sample == NULL ;
147
- while (!voice_done && length != 0 ) {
146
+ while (length != 0 ) {
148
147
if (voice -> buffer_length == 0 ) {
149
148
if (!voice -> more_data ) {
150
149
if (voice -> loop ) {
151
150
audiosample_reset_buffer (voice -> sample , false, 0 );
152
151
} else {
153
152
voice -> sample = NULL ;
154
- voice_done = true;
155
153
break ;
156
154
}
157
155
}
158
- if (! voice_done ) {
156
+ if (voice -> sample ) {
159
157
// Load another buffer
160
158
audioio_get_buffer_result_t result = audiosample_get_buffer (voice -> sample , false, 0 , (uint8_t * * ) & voice -> remaining_buffer , & voice -> buffer_length );
161
159
// Track length in terms of words.
@@ -230,10 +228,8 @@ static void mix_down_one_voice(audiomixer_mixer_obj_t* self,
230
228
}
231
229
232
230
if (length && !voices_active ) {
233
- uint32_t sample_value = self -> bits_per_sample == 8
234
- ? 0x80808080 : 0x80008000 ;
235
231
for (uint32_t i = 0 ; i < length ; i ++ ) {
236
- word_buffer [i ] = sample_value ;
232
+ word_buffer [i ] = 0 ;
237
233
}
238
234
}
239
235
}
@@ -269,9 +265,16 @@ audioio_get_buffer_result_t audiomixer_mixer_get_buffer(audiomixer_mixer_obj_t*
269
265
270
266
for (int32_t v = 0 ; v < self -> voice_count ; v ++ ) {
271
267
audiomixer_mixervoice_obj_t * voice = MP_OBJ_TO_PTR (self -> voice [v ]);
268
+ if (voice -> sample ) {
269
+ mix_down_one_voice (self , voice , voices_active , word_buffer , length );
270
+ voices_active = true;
271
+ }
272
+ }
272
273
273
- mix_down_one_voice (self , voice , voices_active , word_buffer , length );
274
- voices_active = true;
274
+ if (!voices_active ) {
275
+ for (uint32_t i = 0 ; i < length ; i ++ ) {
276
+ word_buffer [i ] = 0 ;
277
+ }
275
278
}
276
279
277
280
if (!self -> samples_signed ) {
0 commit comments