@@ -57,17 +57,17 @@ void common_hal_audiodelays_echo_construct(audiodelays_echo_obj_t *self, uint32_
5757
5858 // If we did not receive a BlockInput we need to create a default float value
5959 if (decay == MP_OBJ_NULL ) {
60- decay = mp_obj_new_float (0.7 );
60+ decay = mp_obj_new_float (MICROPY_FLOAT_CONST ( 0.7 ) );
6161 }
6262 synthio_block_assign_slot (decay , & self -> decay , MP_QSTR_decay );
6363
6464 if (delay_ms == MP_OBJ_NULL ) {
65- delay_ms = mp_obj_new_float (250.0 );
65+ delay_ms = mp_obj_new_float (MICROPY_FLOAT_CONST ( 250.0 ) );
6666 }
6767 synthio_block_assign_slot (delay_ms , & self -> delay_ms , MP_QSTR_delay_ms );
6868
6969 if (mix == MP_OBJ_NULL ) {
70- mix = mp_obj_new_float (0.5 );
70+ mix = mp_obj_new_float (MICROPY_FLOAT_CONST ( 0.5 ) );
7171 }
7272 synthio_block_assign_slot (mix , & self -> mix , MP_QSTR_mix );
7373
@@ -77,7 +77,7 @@ void common_hal_audiodelays_echo_construct(audiodelays_echo_obj_t *self, uint32_
7777
7878 // Allocate the echo buffer for the max possible delay, echo is always 16-bit
7979 self -> max_delay_ms = max_delay_ms ;
80- self -> max_echo_buffer_len = (uint32_t )(self -> sample_rate / 1000.0f * max_delay_ms ) * (self -> channel_count * sizeof (uint16_t )); // bytes
80+ self -> max_echo_buffer_len = (uint32_t )(self -> sample_rate / MICROPY_FLOAT_CONST ( 1000.0 ) * max_delay_ms ) * (self -> channel_count * sizeof (uint16_t )); // bytes
8181 self -> echo_buffer = m_malloc (self -> max_echo_buffer_len );
8282 if (self -> echo_buffer == NULL ) {
8383 common_hal_audiodelays_echo_deinit (self );
@@ -285,8 +285,8 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t *
285285 }
286286
287287 // get the effect values we need from the BlockInput. These may change at run time so you need to do bounds checking if required
288- mp_float_t mix = MIN ( 1.0 , MAX ( synthio_block_slot_get ( & self -> mix ), 0 .0 ));
289- mp_float_t decay = MIN ( 1.0 , MAX ( synthio_block_slot_get ( & self -> decay ), 0 .0 ));
288+ mp_float_t mix = synthio_block_slot_get_limited ( & self -> mix , MICROPY_FLOAT_CONST ( 0.0 ), MICROPY_FLOAT_CONST ( 1 .0 ));
289+ mp_float_t decay = synthio_block_slot_get_limited ( & self -> decay , MICROPY_FLOAT_CONST ( 0.0 ), MICROPY_FLOAT_CONST ( 1 .0 ));
290290
291291 uint32_t delay_ms = (uint32_t )synthio_block_slot_get (& self -> delay_ms );
292292 if (self -> current_delay_ms != delay_ms ) {
@@ -336,7 +336,7 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t *
336336
337337 // If we have no sample keep the echo echoing
338338 if (self -> sample == NULL ) {
339- if (mix <= 0.01 ) { // Mix of 0 is pure sample sound. We have no sample so no sound
339+ if (mix <= MICROPY_FLOAT_CONST ( 0.01 ) ) { // Mix of 0 is pure sample sound. We have no sample so no sound
340340 if (self -> samples_signed ) {
341341 memset (word_buffer , 0 , length * (self -> bits_per_sample / 8 ));
342342 } else {
@@ -406,7 +406,7 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t *
406406 int16_t * sample_src = (int16_t * )self -> sample_remaining_buffer ; // for 16-bit samples
407407 int8_t * sample_hsrc = (int8_t * )self -> sample_remaining_buffer ; // for 8-bit samples
408408
409- if (mix <= 0.01 ) { // if mix is zero pure sample only
409+ if (mix <= MICROPY_FLOAT_CONST ( 0.01 ) ) { // if mix is zero pure sample only
410410 for (uint32_t i = 0 ; i < n ; i ++ ) {
411411 if (MP_LIKELY (self -> bits_per_sample == 16 )) {
412412 word_buffer [i ] = sample_src [i ];
@@ -467,12 +467,12 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t *
467467 word = echo + sample_word ;
468468
469469 if (MP_LIKELY (self -> bits_per_sample == 16 )) {
470- word_buffer [i ] = (int16_t )((sample_word * (1.0 - mix )) + (word * mix ));
470+ word_buffer [i ] = (int16_t )((sample_word * (MICROPY_FLOAT_CONST ( 1.0 ) - mix )) + (word * mix ));
471471 if (!self -> samples_signed ) {
472472 word_buffer [i ] ^= 0x8000 ;
473473 }
474474 } else {
475- int8_t mixed = (int16_t )((sample_word * (1.0 - mix )) + (word * mix ));
475+ int8_t mixed = (int16_t )((sample_word * (MICROPY_FLOAT_CONST ( 1.0 ) - mix )) + (word * mix ));
476476 if (self -> samples_signed ) {
477477 hword_buffer [i ] = mixed ;
478478 } else {
0 commit comments