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;
}
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);
}
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;
}
Aggregations