331 |
return sb; |
return sb; |
332 |
} |
} |
333 |
throw new InvalidMidiDataException("Can't read MidiFileFormat from file " |
throw new InvalidMidiDataException("Can't read MidiFileFormat from file " |
334 |
+ file); |
+ file); |
335 |
} |
} |
336 |
|
|
337 |
|
/** |
338 |
|
* Read a Sequence object from the given stream. |
339 |
|
* |
340 |
|
* @param stream the stream from which to read the Sequence |
341 |
|
* @return the Sequence object |
342 |
|
* @throws InvalidMidiDataException if we were unable to read the Sequence |
343 |
|
* @throws IOException if an I/O error happened while reading |
344 |
|
*/ |
345 |
|
public static Sequence getSequence(InputStream stream) |
346 |
|
throws InvalidMidiDataException, IOException |
347 |
|
{ |
348 |
|
Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class); |
349 |
|
while (readers.hasNext()) |
350 |
|
{ |
351 |
|
MidiFileReader sr = (MidiFileReader) readers.next(); |
352 |
|
Sequence sq = sr.getSequence(stream); |
353 |
|
if (sq != null) |
354 |
|
return sq; |
355 |
|
} |
356 |
|
throw new InvalidMidiDataException("Can't read Sequence from stream"); |
357 |
|
} |
358 |
|
|
359 |
|
/** |
360 |
|
* Read a Sequence object from the given url. |
361 |
|
* |
362 |
|
* @param url the url from which to read the Sequence |
363 |
|
* @return the Sequence object |
364 |
|
* @throws InvalidMidiDataException if we were unable to read the Sequence |
365 |
|
* @throws IOException if an I/O error happened while reading |
366 |
|
*/ |
367 |
|
public static Sequence getSequence(URL url) |
368 |
|
throws InvalidMidiDataException, IOException |
369 |
|
{ |
370 |
|
Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class); |
371 |
|
while (readers.hasNext()) |
372 |
|
{ |
373 |
|
MidiFileReader sr = (MidiFileReader) readers.next(); |
374 |
|
Sequence sq = sr.getSequence(url); |
375 |
|
if (sq != null) |
376 |
|
return sq; |
377 |
|
} |
378 |
|
throw new InvalidMidiDataException("Cannot read from url " + url); |
379 |
|
} |
380 |
|
|
381 |
|
/** |
382 |
|
* Read a Sequence object from the given file. |
383 |
|
* |
384 |
|
* @param file the file from which to read the Sequence |
385 |
|
* @return the Sequence object |
386 |
|
* @throws InvalidMidiDataException if we were unable to read the Sequence |
387 |
|
* @throws IOException if an I/O error happened while reading |
388 |
|
*/ |
389 |
|
public static Sequence getSequence(File file) |
390 |
|
throws InvalidMidiDataException, IOException |
391 |
|
{ |
392 |
|
Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class); |
393 |
|
while (readers.hasNext()) |
394 |
|
{ |
395 |
|
MidiFileReader sr = (MidiFileReader) readers.next(); |
396 |
|
Sequence sq = sr.getSequence(file); |
397 |
|
if (sq != null) |
398 |
|
return sq; |
399 |
|
} |
400 |
|
throw new InvalidMidiDataException("Can't read Sequence from file " |
401 |
|
+ file); |
402 |
|
} |
403 |
|
|
404 |
/** |
/** |
405 |
* Return an array of supported MIDI file types on this system. |
* Return an array of supported MIDI file types on this system. |