| 383 | } |
| 384 | |
| 385 | void stopAllNotes() |
| 386 | { |
| 387 | // Some devices don't support "all notes off" - so do it manually. |
| 388 | for (s32 i = 0; i < MIDI_INSTRUMENT_COUNT; i++) |
| 389 | { |
| 390 | // Skip any instruments not being used. |
| 391 | if (!s_instrOn[i].channelMask) { continue; } |
| 392 | |
| 393 | // Look for used channels. |
| 394 | for (u32 c = 0; c < MIDI_CHANNEL_COUNT; c++) |
| 395 | { |
| 396 | const u32 channelMask = 1u << c; |
| 397 | if (s_instrOn[i].channelMask & channelMask) |
| 398 | { |
| 399 | // Turn off the note. |
| 400 | if (s_midiDevice) { s_midiDevice->message(MID_NOTE_OFF | c, i); } |
| 401 | |
| 402 | // Reset the instrument channel information. |
| 403 | s_instrOn[i].channelMask &= ~channelMask; |
| 404 | s_instrOn[i].time[c] = 0.0; |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | if (s_midiDevice) { s_midiDevice->noteAllOff(); } |
| 410 | memset(s_instrOn, 0, sizeof(Instrument) * MIDI_INSTRUMENT_COUNT); |
| 411 | s_curNoteTime = 0.0; |
| 412 | } |
| 413 | |
| 414 | void sendMessageDirect(u8 type, u8 arg1, u8 arg2) |
| 415 | { |
no test coverage detected