Exemplo n.º 1
14
 private void close() {
   receiver.close();
   device.close();
 }
Exemplo n.º 2
0
  /** Sends messages to turn all controllers and all notes off for all tracks (channels) */
  private void cleanup() {
    ShortMessage allControllersOff = new ShortMessage();
    ShortMessage allNotesOff = new ShortMessage();

    for (byte track = 0; track < MidiDefaults.TRACKS; track++) {
      try {
        allControllersOff.setMessage(ShortMessage.CONTROL_CHANGE, track, (byte) 121, (byte) 0);
        receiver.send(allControllersOff, -1);

        allNotesOff.setMessage(ShortMessage.CONTROL_CHANGE, track, (byte) 123, (byte) 0);
        receiver.send(allNotesOff, -1);
      } catch (InvalidMidiDataException e) {
        // Not going to happen, we're keeping a close eye on the data in the MIDI messages
      }
    }
  }