28
28
#include "shared-bindings/synthio/MidiTrack.h"
29
29
30
30
31
- STATIC void print_midi_stream_error (synthio_miditrack_obj_t * self ) {
31
+ STATIC void record_midi_stream_error (synthio_miditrack_obj_t * self ) {
32
32
self -> error_location = self -> pos ;
33
33
self -> pos = self -> track .len ;
34
34
}
@@ -37,11 +37,11 @@ STATIC mp_obj_t parse_note(synthio_miditrack_obj_t *self) {
37
37
uint8_t * buffer = self -> track .buf ;
38
38
size_t len = self -> track .len ;
39
39
if (self -> pos + 1 >= len ) {
40
- print_midi_stream_error (self );
40
+ record_midi_stream_error (self );
41
41
}
42
42
uint8_t note = buffer [(self -> pos )++ ];
43
43
if (note > 127 || buffer [(self -> pos )++ ] > 127 ) {
44
- print_midi_stream_error (self );
44
+ record_midi_stream_error (self );
45
45
}
46
46
return MP_OBJ_NEW_SMALL_INT (note );
47
47
}
@@ -60,7 +60,7 @@ static int decode_duration(synthio_miditrack_obj_t *self) {
60
60
// errors cannot be raised from the background task, so simply end the track.
61
61
if (c & 0x80 ) {
62
62
self -> pos = self -> track .len ;
63
- print_midi_stream_error (self );
63
+ record_midi_stream_error (self );
64
64
}
65
65
return delta * self -> synth .sample_rate / self -> tempo ;
66
66
}
@@ -89,14 +89,14 @@ static void decode_until_pause(synthio_miditrack_obj_t *self) {
89
89
case 12 :
90
90
case 13 : // one data byte to ignore
91
91
if (self -> pos >= len || buffer [self -> pos ++ ] > 127 ) {
92
- print_midi_stream_error (self );
92
+ record_midi_stream_error (self );
93
93
}
94
94
break ;
95
95
case 15 : // the full syntax is too complicated, just assume it's "End of Track" event
96
96
self -> pos = len ;
97
97
break ;
98
98
default : // invalid event
99
- print_midi_stream_error (self );
99
+ record_midi_stream_error (self );
100
100
}
101
101
if (self -> pos < len ) {
102
102
self -> synth .span .dur = decode_duration (self );
0 commit comments