How to really stop the playback of MIDI data?


#1

Hi, all.

void MidiPlayer::stopMidiPlayback()
{
  if (midiOutput != nullptr)
  {
    midiOutput->clearAllPendingMessages();
    midiOutput->stopBackgroundThread();
  }
}

After call this function, MIDI output device has not received individual note’s “note-off” event, a lot of sounds has continued, and all of MIDI controller events has not reset.

The MidiOutput class has a function: reset () which In JUCE 1.5X, , I guess it used to reset the MIDI output device, then achieve ‘really’ stop such as “Panic” function. But, in JUCE 2.0, this function is gone. There is a substitute?

Any help or suggestions would be very grateful.

Thanks.


#2

Brute-force and fool proof way: send a note off message to the device for channels 1 through 16, notes 0 through to 127.


#3

Thanks jrlanglois.

I also thoughted this way, but the controllers still can’t be reset.

Is there an easier way?


#4

Haven’t really looked at MIDI for a while but isn’t there a send all note off message & reset controllers message? Have a look at the MIDI spec here and messages 79 & 7B about 2/3rds of the way down.


#5

Thanks dave.

I got it! :slight_smile:
A bunch of static functions in MidiMessage class… :smiley:


#6

I remember that some plug-ins that use delay and other effects used to behave strange upon sending an allNotesOff message,
I ended up holding an array of pressed notes and sending note off message to the pressed keys only.