示例#1
0
文件: MSound.java 项目: hoop21/metr
 {
   try {
     sq = MidiSystem.getSequencer();
   } catch (MidiUnavailableException e) {
     e.printStackTrace();
   }
 }
示例#2
0
  /**
   * Sets up the sequencer with a given sequence.
   *
   * @param sequenceToUse
   * @throws MidiUnavailableException
   */
  private void setUpSequencer() throws MidiUnavailableException {
    // First, get the system's default sequencer.
    try {
      sequencer = MidiSystem.getSequencer();
    } catch (MidiUnavailableException ex) {
      // Something went wrong.
      ex.printStackTrace();
      System.exit(1);
    }

    // If there is none, throw an exception.
    if (sequencer == null) {
      String msg = "Cannot find a sequencer";
      throw new MidiUnavailableException(msg);
    }

    // Set up the transmitter and receiver of the synth to play the song.
    linkTransmitterToReceiver();
  }