///////////////////////////////////////////////////////////////////////////// // This function plays all "off" events // Should be called on sequencer reset/restart/pause to avoid hanging notes ///////////////////////////////////////////////////////////////////////////// static s32 SEQ_PlayOffEvents(void) { // play "off events" SEQ_MIDI_OUT_FlushQueue(); // here you could send additional events, e.g. "All Notes Off" CC return 0; // no error }
void MClock_Reset(void) { SEQ_MIDI_OUT_FlushQueue(); // flush the SEQ_MIDI queues which should be empty anyways midiclockcounter = 0; // reset the counter reset_Req = 0; // we just did that mClock.ticked = 0; // and we need to reset this too SEQ_BPM_TickSet(0); // reset BPM tick SEQ_BPM_Timestamp = mod_Tick_Timestamp = 0; // we'll force this to zero in case it's already advanced mClock.status.reset_req = 1; // Set global reset flag Mod_PreProcess(DEAD_NODEID); // preprocess all modules, so they can catch the reset mClock.status.reset_req = 0; // Clear the flag }
///////////////////////////////////////////////////////////////////////////// // This function plays all "off" events // Should be called on sequencer reset/restart/pause to avoid hanging notes ///////////////////////////////////////////////////////////////////////////// static s32 SEQ_PlayOffEvents(void) { // play "off events" SEQ_MIDI_OUT_FlushQueue(); // send Note Off to all channels // TODO: howto handle different ports? // TODO: should we also send Note Off events? Or should we trace Note On events and send Off if required? int chn; mios32_midi_package_t midi_package; midi_package.type = CC; midi_package.event = CC; midi_package.evnt2 = 0; for(chn=0; chn<16; ++chn) { midi_package.chn = chn; midi_package.evnt1 = 123; // All Notes Off MIOS32_MIDI_SendPackage(DEFAULT, midi_package); midi_package.evnt1 = 121; // Controller Reset MIOS32_MIDI_SendPackage(DEFAULT, midi_package); } return 0; // no error }
void MClock_Stop(void) { mClock.status.run = 0; // clear the bit SEQ_MIDI_OUT_FlushQueue(); // and flush the queues }