@SuppressWarnings("unchecked")
  private static void printUsageAndExit() {
    List infos = MidiIn.getDeviceList();
    List ainfos = SoundcardSink.getDeviceList();
    System.out.println("Usage:");
    System.out.println("java Main [-m <MIDI dev>] [-a <audio dev>] [-l <latency>] [-h]");
    System.out.println(
        "-m: allow MIDI input. <MIDI dev> is a number for the MIDI "
            + "device from the following list:");
    if (infos.size() > 0) {
      for (int i = 0; i < infos.size(); i++) {
        System.out.println("   " + i + ": " + infos.get(i));
      }
    } else {
      System.out.println("    (no MIDI IN devices available)");
    }

    System.out.println(
        "-a: specify the audio output device (otherwise the default device will be used)");
    System.out.println(
        "    <audio dev> is a number for the audio " + "device from the following list:");
    if (ainfos.size() > 0) {
      for (int i = 0; i < ainfos.size(); i++) {
        System.out.println("   " + i + ": " + ainfos.get(i));
      }
    } else {
      System.out.println("    (no audio output devices available)");
    }
    System.out.println("-l: specify the buffer size in milliseconds");

    System.exit(1);
  }
 /** Checks the input lines of the mixer and removes the ones that aren't needed anymore */
 private static void serviceMixer(AudioMixer mixer) {
   List<AudioInput> ais = mixer.getAudioStreams();
   for (int i = ais.size() - 1; i >= 0; i--) {
     AudioInput ai = ais.get(i);
     if (ai.done()) {
       mixer.removeAudioStream(ai);
     }
   }
 }