Skip to content

Commit 5ef8ea3

Browse files
committed
Fix unix build and unit conversion errors
1 parent 06446b5 commit 5ef8ea3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

shared-module/audiodelays/Chorus.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void common_hal_audiodelays_chorus_construct(audiodelays_chorus_obj_t *self, uin
7272

7373
// Allocate the chorus buffer for the max possible delay, chorus is always 16-bit
7474
self->max_delay_ms = max_delay_ms;
75-
self->max_chorus_buffer_len = self->base.sample_rate / MICROPY_FLOAT_CONST(1000.0) * max_delay_ms * (self->base.channel_count * sizeof(uint16_t)); // bytes
75+
self->max_chorus_buffer_len = (uint32_t)(self->base.sample_rate / MICROPY_FLOAT_CONST(1000.0) * max_delay_ms * (self->base.channel_count * sizeof(uint16_t))); // bytes
7676
self->chorus_buffer = m_malloc(self->max_chorus_buffer_len);
7777
if (self->chorus_buffer == NULL) {
7878
common_hal_audiodelays_chorus_deinit(self);
@@ -126,10 +126,6 @@ void chorus_recalculate_delay(audiodelays_chorus_obj_t *self, mp_float_t f_delay
126126
// Calculate the current chorus buffer length in bytes
127127
uint32_t new_chorus_buffer_len = (uint32_t)(self->base.sample_rate / MICROPY_FLOAT_CONST(1000.0) * f_delay_ms) * (self->base.channel_count * sizeof(uint16_t));
128128

129-
if (new_chorus_buffer_len < 0) { // or too short!
130-
return;
131-
}
132-
133129
self->chorus_buffer_len = new_chorus_buffer_len;
134130

135131
self->current_delay_ms = f_delay_ms;
@@ -227,7 +223,7 @@ audioio_get_buffer_result_t audiodelays_chorus_get_buffer(audiodelays_chorus_obj
227223
// get the effect values we need from the BlockInput. These may change at run time so you need to do bounds checking if required
228224
shared_bindings_synthio_lfo_tick(self->base.sample_rate, n / self->base.channel_count);
229225

230-
int32_t voices = MAX(synthio_block_slot_get(&self->voices), 1.0);
226+
int32_t voices = (int32_t)MAX(synthio_block_slot_get(&self->voices), 1.0);
231227
int32_t mix_down_scale = SYNTHIO_MIX_DOWN_SCALE(voices);
232228

233229
mp_float_t f_delay_ms = synthio_block_slot_get(&self->delay_ms);

0 commit comments

Comments
 (0)