Search in sources :

Example 6 with Sequence

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

the class SMFParser method getSequence.

public Sequence getSequence(URL url) throws InvalidMidiDataException, IOException {
    // throws IOException
    InputStream is = url.openStream();
    is = new BufferedInputStream(is, bisBufferSize);
    Sequence seq = null;
    try {
        seq = getSequence(is);
    } finally {
        is.close();
    }
    return seq;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) DataInputStream(java.io.DataInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Sequence(javax.sound.midi.Sequence)

Example 7 with Sequence

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

the class SoftMidiAudioFileReader method getAudioFileFormat.

public AudioFileFormat getAudioFileFormat(InputStream inputstream) throws UnsupportedAudioFileException, IOException {
    inputstream.mark(200);
    Sequence seq;
    try {
        seq = MidiSystem.getSequence(inputstream);
    } catch (InvalidMidiDataException e) {
        inputstream.reset();
        throw new UnsupportedAudioFileException();
    } catch (IOException e) {
        inputstream.reset();
        throw new UnsupportedAudioFileException();
    }
    return getAudioFileFormat(seq);
}
Also used : InvalidMidiDataException(javax.sound.midi.InvalidMidiDataException) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) Sequence(javax.sound.midi.Sequence) IOException(java.io.IOException)

Example 8 with Sequence

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

the class SMPTESequence method test.

static boolean test(float divisionType) {
    boolean result = false;
    try {
        log("Testing divisionType == " + divisionType);
        Sequence sequence = new Sequence(divisionType, 16, 1);
        float div1 = sequence.getDivisionType();
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        MidiSystem.write(sequence, 1, outStream);
        InputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
        sequence = MidiSystem.getSequence(inStream);
        float div2 = sequence.getDivisionType();
        log("After write/read got divisionType == " + div2);
        if (Math.abs(div2 - div1) < 0.001f) {
            result = true;
        }
    } catch (InvalidMidiDataException ex) {
        log(ex);
    } catch (IOException ex) {
        log(ex);
    } catch (IllegalArgumentException ex) {
        log(ex);
    }
    if (result) {
        log("OK");
    } else {
        log("FAIL");
        failed++;
    }
    return result;
}
Also used : InvalidMidiDataException(javax.sound.midi.InvalidMidiDataException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Sequence(javax.sound.midi.Sequence) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

Sequence (javax.sound.midi.Sequence)8 InvalidMidiDataException (javax.sound.midi.InvalidMidiDataException)5 BufferedInputStream (java.io.BufferedInputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 DataInputStream (java.io.DataInputStream)2 FileInputStream (java.io.FileInputStream)2 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 MetaMessage (javax.sound.midi.MetaMessage)1 MidiFileFormat (javax.sound.midi.MidiFileFormat)1 MidiMessage (javax.sound.midi.MidiMessage)1 Patch (javax.sound.midi.Patch)1 Track (javax.sound.midi.Track)1 XHTMLContentHandler (org.apache.tika.sax.XHTMLContentHandler)1