@@ -194,6 +194,7 @@ audioio_get_buffer_result_t audiodelays_chorus_get_buffer(audiodelays_chorus_obj
194
194
// The chorus buffer is always stored as a 16-bit value internally
195
195
int16_t * chorus_buffer = (int16_t * )self -> chorus_buffer ;
196
196
uint32_t chorus_buf_len = self -> chorus_buffer_len / sizeof (uint16_t );
197
+ uint32_t max_chorus_buf_len = self -> max_chorus_buffer_len / sizeof (uint16_t );
197
198
198
199
// Loop over the entire length of our buffer to fill it, this may require several calls to get data from the sample
199
200
while (length != 0 ) {
@@ -227,6 +228,7 @@ audioio_get_buffer_result_t audiodelays_chorus_get_buffer(audiodelays_chorus_obj
227
228
shared_bindings_synthio_lfo_tick (self -> base .sample_rate , n / self -> base .channel_count );
228
229
229
230
int32_t voices = MAX (synthio_block_slot_get (& self -> voices ), 1.0 );
231
+ int32_t mix_down_scale = SYNTHIO_MIX_DOWN_SCALE (voices );
230
232
231
233
mp_float_t f_delay_ms = synthio_block_slot_get (& self -> delay_ms );
232
234
if (MICROPY_FLOAT_C_FUN (fabs )(self -> current_delay_ms - f_delay_ms ) >= self -> sample_ms ) {
@@ -275,15 +277,18 @@ audioio_get_buffer_result_t audiodelays_chorus_get_buffer(audiodelays_chorus_obj
275
277
276
278
for (int32_t v = 0 ; v < voices ; v ++ ) {
277
279
if (c_pos < 0 ) {
278
- c_pos += chorus_buf_len ;
280
+ c_pos += max_chorus_buf_len ;
279
281
}
280
282
word += chorus_buffer [c_pos ];
281
283
282
284
c_pos -= step ;
283
285
}
284
- word = word / voices ;
285
286
286
- word = synthio_mix_down_sample (word , SYNTHIO_MIX_DOWN_SCALE (2 ));
287
+ // Dividing would get an average but does not sound as good
288
+ // Leaving this here in case someone wants to try an average instead
289
+ // word = word / voices;
290
+
291
+ word = synthio_mix_down_sample (word , mix_down_scale );
287
292
}
288
293
289
294
if (MP_LIKELY (self -> base .bits_per_sample == 16 )) {
@@ -300,7 +305,7 @@ audioio_get_buffer_result_t audiodelays_chorus_get_buffer(audiodelays_chorus_obj
300
305
}
301
306
}
302
307
303
- if (self -> chorus_buffer_pos >= chorus_buf_len ) {
308
+ if (self -> chorus_buffer_pos >= max_chorus_buf_len ) {
304
309
self -> chorus_buffer_pos = 0 ;
305
310
}
306
311
}
0 commit comments