/** @param outDeviceName String, name of the Output to open */
 public MidiOut getMidiOut(final int midiChannel, final String outDeviceName) {
   for (int i = 0; i < numberOfOutputDevices(); i++) {
     MidiOutDevice midiOutDevice = (MidiOutDevice) midiOutDevices.get(i);
     if (midiOutDevice.getName().equals(outDeviceName)) {
       return getMidiOut(midiChannel, i);
     }
   }
   throw new UnavailablePortException("There is no output with the name " + outDeviceName + ".");
 }
 /**
  * @invisible
  * @param outputName String, name of the Output to close
  */
 public void closeOutput(String outputName) {
   for (int i = 0; i < numberOfOutputDevices(); i++) {
     MidiOutDevice outDevice = (MidiOutDevice) midiOutDevices.get(i);
     if (outDevice.getName().equals(outputName)) {
       closeOutput(i);
       return;
     }
   }
   throw new UnavailablePortException("There is no output with the name " + outputName + ".");
 }
 /**
  * Use this Methode to close an output. You can close it with its number or name. There is no need
  * of closing the ports, as promidi closes them when the applet is closed.
  *
  * @invisible
  * @param outputNumber int, number of the output to close
  */
 public void closeOutput(int outputNumber) {
   try {
     MidiOutDevice outDevice = (MidiOutDevice) midiOutDevices.get(outputNumber);
     outDevice.close();
   } catch (ArrayIndexOutOfBoundsException e) {
     throw new UnavailablePortException(
         "You wanted to close the unavailable output "
             + outputNumber
             + ". The available outputs are 0 - "
             + (midiOutDevices.size() - 1)
             + ".");
   }
 }
 /**
  * Use this Methode to open an output. You can open an output with its number or with its name.
  * Once the output is opened it is reserved for your program. All opened ports are closed by
  * promidi when you close your applet. You can also close opened Ports on your own.
  *
  * @param outDeviceNumber int, number of the output to open
  * @shortdesc Use this Methode to open an output.
  * @example promidi
  * @related openInput ( )
  */
 public MidiOut getMidiOut(final int midiChannel, final int outDeviceNumber) {
   checkMidiChannel(midiChannel);
   try {
     final String key = midiChannel + "_" + outDeviceNumber;
     if (!openMidiOuts.containsKey(key)) {
       MidiOutDevice midiOutDevice = (MidiOutDevice) midiOutDevices.get(outDeviceNumber);
       midiOutDevice.open();
       final MidiOut midiOut = new MidiOut(midiChannel, midiOutDevice);
       openMidiOuts.put(key, midiOut);
     }
     return (MidiOut) openMidiOuts.get(key);
   } catch (RuntimeException e) {
     e.printStackTrace();
     throw new RuntimeException(
         "You wanted to open the unavailable output "
             + outDeviceNumber
             + ". The available outputs are 0 - "
             + (numberOfOutputDevices() - 1)
             + ".");
   }
 }