Search in sources :

Example 1 with Sequencer

use of javax.sound.midi.Sequencer in project jdk8u_jdk by JetBrains.

the class SequencerImplicitSynthOpen method main.

public static void main(String[] args) {
    try {
        log("getting sequencer...");
        Sequencer sequencer = MidiSystem.getSequencer();
        log("  - got " + getDeviceStr(sequencer));
        // obtain connected device (usually synthesizer)
        MidiDevice synth = getConnectedDevice(sequencer);
        if (synth == null) {
            log("could not get connected device, returning");
            return;
        }
        log("connected device: " + getDeviceStr(synth));
        int success = 0;
        for (int i = 0; i < TEST_COUNT; i++) {
            if (test(sequencer)) {
                success++;
            }
        }
        if (success != TEST_COUNT) {
            throw new RuntimeException("test FAILS");
        }
    } catch (MidiUnavailableException ex) {
        // this is not a failure
        log("Could not get Sequencer");
    }
    log("test PASSED.");
}
Also used : Sequencer(javax.sound.midi.Sequencer) MidiUnavailableException(javax.sound.midi.MidiUnavailableException) MidiDevice(javax.sound.midi.MidiDevice)

Example 2 with Sequencer

use of javax.sound.midi.Sequencer in project Denizen-For-Bukkit by DenizenScript.

the class MidiUtil method startSequencer.

public static void startSequencer(File file, float tempo, NoteBlockReceiver receiver) throws InvalidMidiDataException, IOException, MidiUnavailableException {
    Sequencer sequencer = MidiSystem.getSequencer(false);
    sequencer.setSequence(MidiSystem.getSequence(file));
    sequencer.open();
    receiver.setSequencer(sequencer);
    // Set desired tempo
    sequencer.setTempoFactor(tempo);
    sequencer.getTransmitter().setReceiver(receiver);
    sequencer.start();
}
Also used : Sequencer(javax.sound.midi.Sequencer)

Aggregations

Sequencer (javax.sound.midi.Sequencer)2 MidiDevice (javax.sound.midi.MidiDevice)1 MidiUnavailableException (javax.sound.midi.MidiUnavailableException)1