< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 36,46 ****
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.Sequence;
import javax.sound.midi.Track;
- import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException;
--- 36,45 ----
*** 54,67 ****
private static final Type MIDI = new Type("MIDI", "mid");
private static final AudioFormat format = new AudioFormat(44100, 16, 2,
true, false);
! private static AudioFileFormat getAudioFileFormat(final Sequence seq) {
long totallen = seq.getMicrosecondLength() / 1000000;
long len = (long) (format.getFrameRate() * (totallen + 4));
! return new AudioFileFormat(MIDI, format, (int) len);
}
private AudioInputStream getAudioInputStream(final Sequence seq)
throws InvalidMidiDataException {
AudioSynthesizer synth = (AudioSynthesizer) new SoftSynthesizer();
--- 53,66 ----
private static final Type MIDI = new Type("MIDI", "mid");
private static final AudioFormat format = new AudioFormat(44100, 16, 2,
true, false);
! private static StandardFileFormat getAudioFileFormat(final Sequence seq) {
long totallen = seq.getMicrosecondLength() / 1000000;
long len = (long) (format.getFrameRate() * (totallen + 4));
! return new StandardFileFormat(MIDI, format, len);
}
private AudioInputStream getAudioInputStream(final Sequence seq)
throws InvalidMidiDataException {
AudioSynthesizer synth = (AudioSynthesizer) new SoftSynthesizer();
*** 138,148 ****
throw new UnsupportedAudioFileException();
}
}
@Override
! AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
throws UnsupportedAudioFileException, IOException {
try {
return getAudioFileFormat(MidiSystem.getSequence(stream));
} catch (final InvalidMidiDataException ignored) {
throw new UnsupportedAudioFileException();
--- 137,147 ----
throw new UnsupportedAudioFileException();
}
}
@Override
! StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
throws UnsupportedAudioFileException, IOException {
try {
return getAudioFileFormat(MidiSystem.getSequence(stream));
} catch (final InvalidMidiDataException ignored) {
throw new UnsupportedAudioFileException();
< prev index next >