71 |
*/ |
*/ |
72 |
public static MidiDevice.Info[] getMidiDeviceInfo() |
public static MidiDevice.Info[] getMidiDeviceInfo() |
73 |
{ |
{ |
74 |
Iterator deviceProviders = ServiceFactory.lookupProviders(MidiDeviceProvider.class); |
Iterator deviceProviders = |
75 |
|
ServiceFactory.lookupProviders(MidiDeviceProvider.class); |
76 |
List infoList = new ArrayList(); |
List infoList = new ArrayList(); |
77 |
|
|
78 |
while (deviceProviders.hasNext()) |
while (deviceProviders.hasNext()) |
83 |
infoList.add(infos[--i]); |
infoList.add(infos[--i]); |
84 |
} |
} |
85 |
|
|
86 |
return (MidiDevice.Info[]) infoList.toArray(new MidiDevice.Info[infoList.size()]); |
return (MidiDevice.Info[]) |
87 |
|
infoList.toArray(new MidiDevice.Info[infoList.size()]); |
88 |
} |
} |
89 |
|
|
90 |
/** |
/** |
96 |
* @throws IllegalArgumentException if the device described by info is not found |
* @throws IllegalArgumentException if the device described by info is not found |
97 |
*/ |
*/ |
98 |
public static MidiDevice getMidiDevice(MidiDevice.Info info) |
public static MidiDevice getMidiDevice(MidiDevice.Info info) |
99 |
throws MidiUnavailableException, IllegalArgumentException |
throws MidiUnavailableException |
100 |
{ |
{ |
101 |
Iterator deviceProviders = ServiceFactory.lookupProviders(MidiDeviceProvider.class); |
Iterator deviceProviders = |
102 |
|
ServiceFactory.lookupProviders(MidiDeviceProvider.class); |
103 |
|
|
104 |
if (! deviceProviders.hasNext()) |
if (! deviceProviders.hasNext()) |
105 |
throw new MidiUnavailableException("No MIDI device providers available."); |
throw new MidiUnavailableException("No MIDI device providers available."); |
112 |
return provider.getDevice(info); |
return provider.getDevice(info); |
113 |
} while (deviceProviders.hasNext()); |
} while (deviceProviders.hasNext()); |
114 |
|
|
115 |
throw new IllegalArgumentException("MIDI device " + info + " not available."); |
throw new IllegalArgumentException("MIDI device " |
116 |
|
+ info + " not available."); |
117 |
} |
} |
118 |
|
|
119 |
/** |
/** |
263 |
if (sb != null) |
if (sb != null) |
264 |
return sb; |
return sb; |
265 |
} |
} |
266 |
throw new InvalidMidiDataException("Cannot read soundbank from file " + file); |
throw new InvalidMidiDataException("Cannot read soundbank from file " |
267 |
|
+ file); |
268 |
} |
} |
269 |
|
|
270 |
/** |
/** |
286 |
if (sb != null) |
if (sb != null) |
287 |
return sb; |
return sb; |
288 |
} |
} |
289 |
throw new InvalidMidiDataException("Cannot read MidiFileFormat from stream"); |
throw new InvalidMidiDataException("Can't read MidiFileFormat from stream"); |
290 |
} |
} |
291 |
|
|
292 |
/** |
/** |
330 |
if (sb != null) |
if (sb != null) |
331 |
return sb; |
return sb; |
332 |
} |
} |
333 |
throw new InvalidMidiDataException("Cannot read MidiFileFormat from file " + file); |
throw new InvalidMidiDataException("Can't read MidiFileFormat from file " |
334 |
|
+ file); |
335 |
} |
} |
336 |
|
|
337 |
|
|
458 |
* @throws IllegalArgumentException if fileType is not supported for in |
* @throws IllegalArgumentException if fileType is not supported for in |
459 |
*/ |
*/ |
460 |
public static int write(Sequence in, int fileType, OutputStream out) |
public static int write(Sequence in, int fileType, OutputStream out) |
461 |
throws IOException, IllegalArgumentException |
throws IOException |
462 |
{ |
{ |
463 |
Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class); |
Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class); |
464 |
while (writers.hasNext()) |
while (writers.hasNext()) |
468 |
if (fw.isFileTypeSupported(fileType, in)) |
if (fw.isFileTypeSupported(fileType, in)) |
469 |
return fw.write(in, fileType, out); |
return fw.write(in, fileType, out); |
470 |
} |
} |
471 |
throw new IllegalArgumentException("File type " + fileType + " is not supported"); |
throw new IllegalArgumentException("File type " |
472 |
|
+ fileType + " is not supported"); |
473 |
} |
} |
474 |
|
|
475 |
/** |
/** |
483 |
* @throws IllegalArgumentException if fileType is not supported for in |
* @throws IllegalArgumentException if fileType is not supported for in |
484 |
*/ |
*/ |
485 |
public static int write(Sequence in, int fileType, File out) |
public static int write(Sequence in, int fileType, File out) |
486 |
throws IOException, IllegalArgumentException |
throws IOException |
487 |
{ |
{ |
488 |
Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class); |
Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class); |
489 |
while (writers.hasNext()) |
while (writers.hasNext()) |
493 |
if (fw.isFileTypeSupported(fileType, in)) |
if (fw.isFileTypeSupported(fileType, in)) |
494 |
return fw.write(in, fileType, out); |
return fw.write(in, fileType, out); |
495 |
} |
} |
496 |
throw new IllegalArgumentException("File type " + fileType + " is not supported"); |
throw new IllegalArgumentException("File type " |
497 |
|
+ fileType + " is not supported"); |
498 |
} |
} |
499 |
} |
} |
500 |
|
|