src/core/preprocess/ReadMIDI.java
public Sequencer play(Sequence sequence, int playTime, boolean wait) throws MidiUnavailableException, InvalidMidiDataException {
        Sequencer sequencer = MidiSystem.getSequencer();
        sequencer.setSequence(sequence);

        stopPlaying(sequencer);

        sequencer.open();
        sequencer.start();

        if (!wait) return sequencer;

        int timeOut = 0;
        try {
            while (sequencer.isRunning() && timeOut < playTime) {
                Thread.sleep(1000);
                timeOut++;
            }
        } catch (InterruptedException exception) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(exception);
        }

        sequencer.stop();
        sequencer.close();

        return sequencer;
    }
/**
     * Plays MIDI sequence.
     *
     * @param sequence sequence
     * @param playTime play time before stopping.
     * @param wait if true waits given play time before stopping otherwise returns function after starts playing.
     * @throws MidiUnavailableException throws exception is playing fails.
     * @throws InvalidMidiDataException throws exception is playing fails.
     * @return sequencer
     */
Plays MIDI sequence.

@param sequence sequence
@param playTime play time before stopping.
@param wait if true waits given play time before stopping otherwise returns function after starts playing.
@throws MidiUnavailableException throws exception is playing fails.
@throws InvalidMidiDataException throws exception is playing fails.
@return sequencer
Plays MIDI sequence . @param sequence sequence @param playTime play time before stopping . @param wait if true waits given play time before stopping otherwise returns function after starts playing . @throws MidiUnavailableException throws exception is playing fails . @throws InvalidMidiDataException throws exception is playing fails . @return sequencer
public Sequencer play(Sequence sequence, int playTime, boolean wait) throws MidiUnavailableException, InvalidMidiDataException {
        Sequencer sequencer = MidiSystem.getSequencer();
        sequencer.setSequence(sequence);
        stopPlaying(sequencer);
        sequencer.open();
        sequencer.start();
        if (!wait) return sequencer;
        int timeOut = 0;
        try {
            while (sequencer.isRunning() && timeOut < playTime) {
                Thread.sleep(1000);
                timeOut++;
            }
        } catch (InterruptedException exception) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(exception);
        }
        sequencer.stop();
        sequencer.close();
        return sequencer;
    }
public Sequencer play ( Sequence sequence , int playTime , boolean wait ) throws MidiUnavailableException , InvalidMidiDataException { Sequencer sequencer = MidiSystem . getSequencer ( ) ; sequencer . setSequence ( sequence ) ; stopPlaying ( sequencer ) ; sequencer . open ( ) ; sequencer . start ( ) ; if ( ! wait ) return sequencer ; int timeOut = 0 ; try { while ( sequencer . isRunning ( ) && timeOut < playTime ) { Thread . sleep ( 1000 ) ; timeOut ++ ; } } catch ( InterruptedException exception ) { Thread . currentThread ( ) . interrupt ( ) ; throw new RuntimeException ( exception ) ; } sequencer . stop ( ) ; sequencer . close ( ) ; return sequencer ; }
Plays MIDI sequence.
Plays MIDI sequence .