When switching midi devices, first send all notes off, all sound off on every channel just so it doesn't leave phantom notes playing.

This commit is contained in:
badvision 2017-02-19 22:26:06 -06:00
parent b57d3e06e0
commit 3b9d6a232e

View File

@ -572,6 +572,20 @@ public class PassportMidiInterface extends Card {
private void suspendACIA() { private void suspendACIA() {
// TODO: Stop ACIA thread... // TODO: Stop ACIA thread...
if (midiOut != null) { if (midiOut != null) {
currentMessage = new ShortMessage();
// Send a note-off on every channel
for (int channel = 0; channel < 16; channel++) {
try {
// All Notes Off
currentMessage.setMessage(0x0B0 | channel, 123, 0);
midiOut.send(currentMessage, 0);
// All Oscillators Off
currentMessage.setMessage(0x0B0 | channel, 120, 0);
midiOut.send(currentMessage, 0);
} catch (InvalidMidiDataException ex) {
Logger.getLogger(PassportMidiInterface.class.getName()).log(Level.SEVERE, null, ex);
}
}
midiOut.close(); midiOut.close();
midiOut = null; midiOut = null;
} }