pico-example-midi icon indicating copy to clipboard operation
pico-example-midi copied to clipboard

Simplification

Open emaschas opened this issue 3 years ago • 0 comments

You could avoid calculation the previous note by sending NOTE OFF before incrementing the counter, like that :

  // Send Note Off for actual note.
  tud_midi_write24(0, 0, 0x80, note_sequence[note_pos], 0);

  // Increment position
  note_pos++;

  // If we are at the end of the sequence, start over.
  if (note_pos >= sizeof(note_sequence))   note_pos = 0;

  // Send Note On for current position at full velocity (127) on channel 1.
  tud_midi_write24(0, 0, 0x90, note_sequence[note_pos], 127);

emaschas avatar Jan 30 '22 09:01 emaschas