diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index 343a107db2..66f28409d9 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -158,6 +158,10 @@ void synthio_miditrack_reset_buffer(synthio_miditrack_obj_t *self, audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { + if (common_hal_synthio_miditrack_deinited(self)) { + *buffer_length = 0; + return GET_BUFFER_ERROR; + } synthio_synth_synthesize(&self->synth, buffer, buffer_length, single_channel_output ? 0 : channel); if (self->synth.span.dur == 0) { diff --git a/shared-module/synthio/Synthesizer.c b/shared-module/synthio/Synthesizer.c index 02d98a521e..e7fb324d25 100644 --- a/shared-module/synthio/Synthesizer.c +++ b/shared-module/synthio/Synthesizer.c @@ -62,6 +62,10 @@ void synthio_synthesizer_reset_buffer(synthio_synthesizer_obj_t *self, audioio_get_buffer_result_t synthio_synthesizer_get_buffer(synthio_synthesizer_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { + if (common_hal_synthio_synthesizer_deinited(self)) { + *buffer_length = 0; + return GET_BUFFER_ERROR; + } self->synth.span.dur = SYNTHIO_MAX_DUR; synthio_synth_synthesize(&self->synth, buffer, buffer_length, single_channel_output ? channel : 0); return GET_BUFFER_MORE_DATA;