synthio: fix crash on synthesizer.press((float,))

This commit is contained in:
Jeff Epler 2023-05-12 11:49:08 -05:00
parent 0a3faf8c9d
commit 522c5a9a11
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE

View File

@ -110,11 +110,12 @@ void common_hal_synthio_synthesizer_press(synthio_synthesizer_obj_t *self, mp_ob
mp_obj_t iterable = mp_getiter(to_press, &iter_buf); mp_obj_t iterable = mp_getiter(to_press, &iter_buf);
mp_obj_t note_obj; mp_obj_t note_obj;
while ((note_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { while ((note_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
note_obj = validate_note(note_obj);
if (!mp_obj_is_small_int(note_obj)) { if (!mp_obj_is_small_int(note_obj)) {
synthio_note_obj_t *note = MP_OBJ_TO_PTR(note_obj); synthio_note_obj_t *note = MP_OBJ_TO_PTR(note_obj);
synthio_note_start(note, self->synth.sample_rate); synthio_note_start(note, self->synth.sample_rate);
} }
synthio_span_change_note(&self->synth, SYNTHIO_SILENCE, validate_note(note_obj)); synthio_span_change_note(&self->synth, SYNTHIO_SILENCE, note_obj);
} }
} }