File tree 1 file changed +3
-7
lines changed
libraries/Bluefruit52Lib/examples/Peripheral/blemidi
1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ BLEMidi blemidi;
28
28
MIDI_CREATE_BLE_INSTANCE (blemidi);
29
29
30
30
// Variable that holds the current position in the sequence.
31
- int position = 0 ;
31
+ unsigned int position = 0 ;
32
32
33
33
// Store example melody as an array of note values
34
34
byte note_sequence[] = {
@@ -137,14 +137,10 @@ void loop()
137
137
138
138
// Setup variables for the current and previous
139
139
// positions in the note sequence.
140
- int current = position;
141
- int previous = position - 1 ;
142
-
140
+ unsigned int current = position;
143
141
// If we currently are at position 0, set the
144
142
// previous position to the last note in the sequence.
145
- if (previous < 0 ) {
146
- previous = sizeof (note_sequence) - 1 ;
147
- }
143
+ unsigned int previous = (current == 0 ) ? (sizeof (note_sequence)-1 ) : current - 1 ;
148
144
149
145
// Send Note On for current position at full velocity (127) on channel 1.
150
146
MIDI.sendNoteOn (note_sequence[current], 127 , 1 );
You can’t perform that action at this time.
0 commit comments