@@ -208,10 +208,6 @@ static mp_float_t db_to_linear(mp_float_t value) {
208208audioio_get_buffer_result_t audiofilters_distortion_get_buffer (audiofilters_distortion_obj_t * self , bool single_channel_output , uint8_t channel ,
209209 uint8_t * * buffer , uint32_t * buffer_length ) {
210210
211- if (!single_channel_output ) {
212- channel = 0 ;
213- }
214-
215211 // get the effect values we need from the BlockInput. These may change at run time so you need to do bounds checking if required
216212 mp_float_t drive = synthio_block_slot_get_limited (& self -> drive , MICROPY_FLOAT_CONST (0.0 ), MICROPY_FLOAT_CONST (1.0 ));
217213 mp_float_t pre_gain = db_to_linear (synthio_block_slot_get_limited (& self -> pre_gain , MICROPY_FLOAT_CONST (-60.0 ), MICROPY_FLOAT_CONST (60.0 )));
@@ -300,7 +296,7 @@ audioio_get_buffer_result_t audiofilters_distortion_get_buffer(audiofilters_dist
300296 }
301297
302298 // Apply pre-gain
303- int32_t word = sample_word * pre_gain ;
299+ int32_t word = ( int32_t )( sample_word * pre_gain ) ;
304300
305301 // Apply bit mask before converting to float
306302 if (self -> mode == DISTORTION_MODE_LOFI ) {
@@ -345,10 +341,10 @@ audioio_get_buffer_result_t audiofilters_distortion_get_buffer(audiofilters_dist
345341 }
346342
347343 // Convert sample back to signed integer
348- word = wordf * MICROPY_FLOAT_CONST (32767.0 );
344+ word = ( int32_t )( wordf * MICROPY_FLOAT_CONST (32767.0 ) );
349345 } else {
350346 // Apply post-gain
351- word = word * post_gain ;
347+ word = ( int32_t )( word * post_gain ) ;
352348 }
353349
354350 // Hard clip
@@ -357,12 +353,12 @@ audioio_get_buffer_result_t audiofilters_distortion_get_buffer(audiofilters_dist
357353 }
358354
359355 if (MP_LIKELY (self -> bits_per_sample == 16 )) {
360- word_buffer [i ] = (sample_word * (MICROPY_FLOAT_CONST (1.0 ) - mix )) + (word * mix );
356+ word_buffer [i ] = (int16_t )(( sample_word * (MICROPY_FLOAT_CONST (1.0 ) - mix )) + (word * mix ) );
361357 if (!self -> samples_signed ) {
362358 word_buffer [i ] ^= 0x8000 ;
363359 }
364360 } else {
365- int8_t mixed = (sample_word * (MICROPY_FLOAT_CONST (1.0 ) - mix )) + (word * mix );
361+ int8_t mixed = (int8_t )(( sample_word * (MICROPY_FLOAT_CONST (1.0 ) - mix )) + (word * mix ) );
366362 if (self -> samples_signed ) {
367363 hword_buffer [i ] = mixed ;
368364 } else {
0 commit comments