public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException { FileInputStream fis = new FileInputStream(file); // throws IOException BufferedInputStream bis = new BufferedInputStream(fis, bisBufferSize); // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length long length = file.length(); if (length > Integer.MAX_VALUE) { length = MidiFileFormat.UNKNOWN_LENGTH; } MidiFileFormat fileFormat = null; try { fileFormat = getMidiFileFormatFromStream(bis, (int) length, null); } finally { bis.close(); } return fileFormat; }
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException { SMFParser smfParser = new SMFParser(); MidiFileFormat format = getMidiFileFormatFromStream(stream, MidiFileFormat.UNKNOWN_LENGTH, smfParser); // must be MIDI Type 0 or Type 1 if ((format.getType() != 0) && (format.getType() != 1)) { throw new InvalidMidiDataException("Invalid or unsupported file type: " + format.getType()); } // construct the sequence object Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution()); // for each track, go to the beginning and read the track events for (int i = 0; i < smfParser.tracks; i++) { if (smfParser.nextTrack()) { smfParser.readTrack(sequence.createTrack()); } else { break; } } return sequence; }
@Override public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException { FileInputStream fis = new FileInputStream(file); // throws IOException BufferedInputStream bis = new BufferedInputStream(fis, bisBufferSize); // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length long length = file.length(); if (length > Integer.MAX_VALUE) { length = MidiFileFormat.UNKNOWN_LENGTH; } MidiFileFormat fileFormat = null; try { fileFormat = getMidiFileFormatFromStream(bis, (int) length, null); } finally { bis.close(); } return fileFormat; }
@Override public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException { SMFParser smfParser = new SMFParser(); MidiFileFormat format = getMidiFileFormatFromStream(stream, MidiFileFormat.UNKNOWN_LENGTH, smfParser); // must be MIDI Type 0 or Type 1 if ((format.getType() != 0) && (format.getType() != 1)) { throw new InvalidMidiDataException("Invalid or unsupported file type: " + format.getType()); } // construct the sequence object Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution()); // for each track, go to the beginning and read the track events for (int i = 0; i < smfParser.tracks; i++) { if (smfParser.nextTrack()) { smfParser.readTrack(sequence.createTrack()); } else { break; } } return sequence; }
public JavaSoundAudioClip(InputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.<init>"); BufferedInputStream bis = new BufferedInputStream(in, STREAM_BUFFER_SIZE); bis.mark(STREAM_BUFFER_SIZE); boolean success = false; try { AudioInputStream as = AudioSystem.getAudioInputStream(bis); // load the stream data into memory success = loadAudioData(as); if (success) { success = false; if (loadedAudioByteLength < CLIP_THRESHOLD) { success = createClip(); } if (!success) { success = createSourceDataLine(); } } } catch (UnsupportedAudioFileException e) { // not an audio file try { MidiFileFormat mff = MidiSystem.getMidiFileFormat(bis); success = createSequencer(bis); } catch (InvalidMidiDataException e1) { success = false; } } if (!success) { throw new IOException("Unable to create AudioClip from input stream"); } }
public MidiFileFormat getMidiFileFormat(URL url) throws InvalidMidiDataException, IOException { InputStream urlStream = url.openStream(); // throws IOException BufferedInputStream bis = new BufferedInputStream( urlStream, bisBufferSize ); MidiFileFormat fileFormat = null; try { fileFormat = getMidiFileFormat( bis ); // throws InvalidMidiDataException } finally { bis.close(); } return fileFormat; }
@Override public MidiFileFormat getMidiFileFormat(URL url) throws InvalidMidiDataException, IOException { InputStream urlStream = url.openStream(); // throws IOException BufferedInputStream bis = new BufferedInputStream( urlStream, bisBufferSize ); MidiFileFormat fileFormat = null; try { fileFormat = getMidiFileFormat( bis ); // throws InvalidMidiDataException } finally { bis.close(); } return fileFormat; }
public MidiFileFormat getMidiFileFormat(URL url) throws InvalidMidiDataException, IOException { InputStream is = url.openStream(); try { return getMidiFileFormat(is); } finally { is.close(); } }
public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException { InputStream is = new FileInputStream(file); try { return getMidiFileFormat(is); } finally { is.close(); } }