/** * Obtains a List containing installed instances of the providers for the * requested service. The returned List is immutable. * * @param serviceClass The type of providers requested. This should be one * of AudioFileReader.class, AudioFileWriter.class, * FormatConversionProvider.class, MixerProvider.class, * MidiDeviceProvider.class, MidiFileReader.class, * MidiFileWriter.class or SoundbankReader.class. * * @return A List of providers of the requested type. This List is * immutable. */ public static List<?> getProviders(final Class<?> serviceClass) { final List<?> providers; if (!MixerProvider.class.equals(serviceClass) && !FormatConversionProvider.class.equals(serviceClass) && !AudioFileReader.class.equals(serviceClass) && !AudioFileWriter.class.equals(serviceClass) && !MidiDeviceProvider.class.equals(serviceClass) && !SoundbankReader.class.equals(serviceClass) && !MidiFileWriter.class.equals(serviceClass) && !MidiFileReader.class.equals(serviceClass)) { providers = new ArrayList<>(0); } else { providers = JSSecurityManager.getProviders(serviceClass); } return Collections.unmodifiableList(providers); }
/** * Constructs a MIDI sound bank by reading it from the specified stream. The * stream must point to a valid MIDI soundbank file. In general, MIDI * soundbank providers may need to read some data from the stream before * determining whether they support it. These parsers must be able to mark * the stream, read enough data to determine whether they support the * stream, and, if not, reset the stream's read pointer to its original * position. If the input stream does not support this, this method may fail * with an {@code IOException}. * * @param stream the source of the sound bank data * @return the sound bank * @throws InvalidMidiDataException if the stream does not point to valid * MIDI soundbank data recognized by the system * @throws IOException if an I/O error occurred when loading the soundbank * @throws NullPointerException if {@code stream} is {@code null} * @see InputStream#markSupported * @see InputStream#mark */ public static Soundbank getSoundbank(final InputStream stream) throws InvalidMidiDataException, IOException { Objects.requireNonNull(stream); SoundbankReader sp = null; Soundbank s = null; List<SoundbankReader> providers = getSoundbankReaders(); for(int i = 0; i < providers.size(); i++) { sp = providers.get(i); s = sp.getSoundbank(stream); if( s!= null) { return s; } } throw new InvalidMidiDataException("cannot get soundbank from stream"); }
/** * Constructs a {@code Soundbank} by reading it from the specified URL. The * URL must point to a valid MIDI soundbank file. * * @param url the source of the sound bank data * @return the sound bank * @throws InvalidMidiDataException if the URL does not point to valid MIDI * soundbank data recognized by the system * @throws IOException if an I/O error occurred when loading the soundbank * @throws NullPointerException if {@code url} is {@code null} */ public static Soundbank getSoundbank(final URL url) throws InvalidMidiDataException, IOException { Objects.requireNonNull(url); SoundbankReader sp = null; Soundbank s = null; List<SoundbankReader> providers = getSoundbankReaders(); for(int i = 0; i < providers.size(); i++) { sp = providers.get(i); s = sp.getSoundbank(url); if( s!= null) { return s; } } throw new InvalidMidiDataException("cannot get soundbank from stream"); }
/** * Constructs a {@code Soundbank} by reading it from the specified * {@code File}. The {@code File} must point to a valid MIDI soundbank file. * * @param file the source of the sound bank data * @return the sound bank * @throws InvalidMidiDataException if the {@code File} does not point to * valid MIDI soundbank data recognized by the system * @throws IOException if an I/O error occurred when loading the soundbank * @throws NullPointerException if {@code file} is {@code null} */ public static Soundbank getSoundbank(final File file) throws InvalidMidiDataException, IOException { Objects.requireNonNull(file); SoundbankReader sp = null; Soundbank s = null; List<SoundbankReader> providers = getSoundbankReaders(); for(int i = 0; i < providers.size(); i++) { sp = providers.get(i); s = sp.getSoundbank(file); if( s!= null) { return s; } } throw new InvalidMidiDataException("cannot get soundbank from stream"); }
public static Soundbank getSoundbank(File file) throws InvalidMidiDataException, IOException { /* * obtain the list of SoundbankReaderProviders */ List<?> soundbankReaderProviders = ProviderService.getProviders(soundbankReaderPath); if (soundbankReaderProviders.size() == 0) { //FIXME /* * I don't understand what type of exception we should throw out if we haven't * appropriate providers... * Maybe here is should be MidiUnavailableException */ throw new Error(Messages.getString("sound.1D")); } /* * It's not determine what provider for this service I should to use, and so * I use the first one */ return ((SoundbankReader) soundbankReaderProviders.get(0)).getSoundbank(file); }
public static Soundbank getSoundbank(InputStream stream) throws InvalidMidiDataException, IOException { /* * obtain the list of SoundbankReaderProviders */ List<?> soundbankReaderProviders = ProviderService.getProviders(soundbankReaderPath); if (soundbankReaderProviders.size() == 0) { //FIXME /* * I don't understand what type of exception we should throw out if we haven't * appropriate providers... * Maybe here is should be MidiUnavailableException */ throw new Error(Messages.getString("sound.1D")); } /* * It's not determine what provider for this service I should to use, and so * I use the first one */ return ((SoundbankReader) soundbankReaderProviders.get(0)).getSoundbank(stream); }
public static Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException { /* * obtain the list of SoundbankReaderProviders */ List<?> soundbankReaderProviders = ProviderService.getProviders(soundbankReaderPath); if (soundbankReaderProviders.size() == 0) { //FIXME /* * I don't understand what type of exception we should throw out if we haven't * appropriate providers... * Maybe here is should be MidiUnavailableException */ throw new Error(Messages.getString("sound.1D")); } /* * It's not determine what provider for this service I should to use, and so * I use the first one */ return ((SoundbankReader) soundbankReaderProviders.get(0)).getSoundbank(url); }
/** * Read a Soundbank object from the given file. * * @param file the file from which to read the Soundbank * @return the Soundbank object * @throws InvalidMidiDataException if we were unable to read the soundbank * @throws IOException if an I/O error happened while reading */ public static Soundbank getSoundbank(File file) throws InvalidMidiDataException, IOException { Iterator<SoundbankReader> readers = ServiceFactory.lookupProviders(SoundbankReader.class); while (readers.hasNext()) { SoundbankReader sr = (SoundbankReader) readers.next(); Soundbank sb = sr.getSoundbank(file); if (sb != null) return sb; } throw new InvalidMidiDataException("Cannot read soundbank from file " + file); }
public static Soundbank getSoundbank(File file) throws InvalidMidiDataException, IOException { /* * obtain the list of SoundbankReaderProviders */ List<?> soundbankReaderProviders = ProviderService.getProviders(soundbankReaderPath); if (soundbankReaderProviders.size() == 0) { //FIXME /* * I don't understand what type of exception we should throw out if we haven't * appropriate providers... * Maybe here is should be MidiUnavailableException */ throw new Error("There is no SoundbankReaderProviders on your system!!!"); } /* * It's not determine what provider for this service I should to use, and so * I use the first one */ return ((SoundbankReader) soundbankReaderProviders.get(0)).getSoundbank(file); }
public static Soundbank getSoundbank(InputStream stream) throws InvalidMidiDataException, IOException { /* * obtain the list of SoundbankReaderProviders */ List<?> soundbankReaderProviders = ProviderService.getProviders(soundbankReaderPath); if (soundbankReaderProviders.size() == 0) { //FIXME /* * I don't understand what type of exception we should throw out if we haven't * appropriate providers... * Maybe here is should be MidiUnavailableException */ throw new Error("There is no SoundbankReaderProviders on your system!!!"); } /* * It's not determine what provider for this service I should to use, and so * I use the first one */ return ((SoundbankReader) soundbankReaderProviders.get(0)).getSoundbank(stream); }
public static Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException { /* * obtain the list of SoundbankReaderProviders */ List<?> soundbankReaderProviders = ProviderService.getProviders(soundbankReaderPath); if (soundbankReaderProviders.size() == 0) { //FIXME /* * I don't understand what type of exception we should throw out if we haven't * appropriate providers... * Maybe here is should be MidiUnavailableException */ throw new Error("There is no SoundbankReaderProviders on your system!!!"); } /* * It's not determine what provider for this service I should to use, and so * I use the first one */ return ((SoundbankReader) soundbankReaderProviders.get(0)).getSoundbank(url); }
/** * Read a Soundbank object from the given stream. * * @param stream the stream from which to read the Soundbank * @return the Soundbank object * @throws InvalidMidiDataException if we were unable to read the soundbank * @throws IOException if an I/O error happened while reading */ public static Soundbank getSoundbank(InputStream stream) throws InvalidMidiDataException, IOException { Iterator readers = ServiceFactory.lookupProviders(SoundbankReader.class); while (readers.hasNext()) { SoundbankReader sr = (SoundbankReader) readers.next(); Soundbank sb = sr.getSoundbank(stream); if (sb != null) return sb; } throw new InvalidMidiDataException("Cannot read soundbank from stream"); }
/** * Read a Soundbank object from the given url. * * @param url the url from which to read the Soundbank * @return the Soundbank object * @throws InvalidMidiDataException if we were unable to read the soundbank * @throws IOException if an I/O error happened while reading */ public static Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException { Iterator readers = ServiceFactory.lookupProviders(SoundbankReader.class); while (readers.hasNext()) { SoundbankReader sr = (SoundbankReader) readers.next(); Soundbank sb = sr.getSoundbank(url); if (sb != null) return sb; } throw new InvalidMidiDataException("Cannot read from url " + url); }
/** * Read a Soundbank object from the given file. * * @param file the file from which to read the Soundbank * @return the Soundbank object * @throws InvalidMidiDataException if we were unable to read the soundbank * @throws IOException if an I/O error happened while reading */ public static Soundbank getSoundbank(File file) throws InvalidMidiDataException, IOException { Iterator readers = ServiceFactory.lookupProviders(SoundbankReader.class); while (readers.hasNext()) { SoundbankReader sr = (SoundbankReader) readers.next(); Soundbank sb = sr.getSoundbank(file); if (sb != null) return sb; } throw new InvalidMidiDataException("Cannot read soundbank from file " + file); }
/** * Read a Soundbank object from the given stream. * * @param stream the stream from which to read the Soundbank * @return the Soundbank object * @throws InvalidMidiDataException if we were unable to read the soundbank * @throws IOException if an I/O error happened while reading */ public static Soundbank getSoundbank(InputStream stream) throws InvalidMidiDataException, IOException { Iterator<SoundbankReader> readers = ServiceFactory.lookupProviders(SoundbankReader.class); while (readers.hasNext()) { SoundbankReader sr = readers.next(); Soundbank sb = sr.getSoundbank(stream); if (sb != null) return sb; } throw new InvalidMidiDataException("Cannot read soundbank from stream"); }
/** * Read a Soundbank object from the given url. * * @param url the url from which to read the Soundbank * @return the Soundbank object * @throws InvalidMidiDataException if we were unable to read the soundbank * @throws IOException if an I/O error happened while reading */ public static Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException { Iterator<SoundbankReader> readers = ServiceFactory.lookupProviders(SoundbankReader.class); while (readers.hasNext()) { SoundbankReader sr = readers.next(); Soundbank sb = sr.getSoundbank(url); if (sb != null) return sb; } throw new InvalidMidiDataException("Cannot read from url " + url); }
private static List getSoundbankReaders() { return getProviders(SoundbankReader.class); }
public static void main(final String[] args) throws Exception { testMS(); for (final SoundbankReader sbr : load(SoundbankReader.class)) { testSBR(sbr); } }
@SuppressWarnings("unchecked") private static List<SoundbankReader> getSoundbankReaders() { return (List<SoundbankReader>) getProviders(SoundbankReader.class); }