javax.sound.midi.spi.MidiDeviceProvider Java Examples

The following examples show how to use javax.sound.midi.spi.MidiDeviceProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MidiSystem.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
 
Example #2
Source File: MidiSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #3
Source File: MidiSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** From a List of MidiDeviceProviders, return the first appropriate
    MidiDevice.
    @param providers The List of MidiDeviceProviders to search.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice that is considered appropriate, or null
    if none is found.
 */
private static MidiDevice getFirstDevice(List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getFirstDevice(provider, deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
 
Example #4
Source File: UnsupportedInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
    for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
        for (final MidiDevice.Info info : infos) {
            if (mdp.isDeviceSupported(info)) {
                if (mdp.getDevice(info) == null) {
                    throw new RuntimeException("MidiDevice is null");
                }
            } else {
                try {
                    mdp.getDevice(info);
                    throw new RuntimeException(
                            "IllegalArgumentException expected");
                } catch (final IllegalArgumentException ignored) {
                    // expected
                }
            }
        }
    }
}
 
Example #5
Source File: MidiSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
 
Example #6
Source File: MidiSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
    @param deviceName The name of the MidiDevice to be returned.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.

    @return A MidiDevice matching the requirements, or null if none is found.
*/
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #7
Source File: MidiSystem.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a list of
    MidiDeviceProviders.
    @param deviceName The name of the MidiDevice to be returned.
    @param providers The List of MidiDeviceProviders to check for
    MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A Mixer matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getNamedDevice(deviceName, provider,
                                           deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
 
Example #8
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** From a List of MidiDeviceProviders, return the first appropriate
    MidiDevice.
    @param providers The List of MidiDeviceProviders to search.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice that is considered appropriate, or null
    if none is found.
 */
private static MidiDevice getFirstDevice(List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getFirstDevice(provider, deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
 
Example #9
Source File: JDK13Services.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
 
Example #11
Source File: MidiSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
 
Example #12
Source File: MidiSystem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #13
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
    @param deviceName The name of the MidiDevice to be returned.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.

    @return A MidiDevice matching the requirements, or null if none is found.
*/
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #14
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
 
Example #15
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #16
Source File: MidiSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
 
Example #17
Source File: MidiSystem.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * From a List of MidiDeviceProviders, return the first appropriate
 * MidiDevice.
 *
 * @param  providers The List of MidiDeviceProviders to search
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice that is considered appropriate, or null if none is
 *         found
 */
private static MidiDevice getFirstDevice(List<MidiDeviceProvider> providers,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(providers, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(providers, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #18
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #19
Source File: JDK13Services.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #20
Source File: MidiSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #21
Source File: MidiSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
 
Example #22
Source File: MidiSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
    @param deviceName The name of the MidiDevice to be returned.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.

    @return A MidiDevice matching the requirements, or null if none is found.
*/
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #23
Source File: MidiSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a MidiDevice with a given name from a given MidiDeviceProvider.
 *
 * @param  deviceName The name of the MidiDevice to be returned
 * @param  provider The MidiDeviceProvider to check for MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice matching the requirements, or null if none is found
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #24
Source File: JDK13Services.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #25
Source File: MidiSystem.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** From a List of MidiDeviceProviders, return the first appropriate
    MidiDevice.
    @param providers The List of MidiDeviceProviders to search.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice that is considered appropriate, or null
    if none is found.
 */
private static MidiDevice getFirstDevice(List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getFirstDevice(provider, deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
 
Example #26
Source File: MidiSystem.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Return a MidiDevice with a given name from a given MidiDeviceProvider.
 *
 * @param  deviceName The name of the MidiDevice to be returned
 * @param  provider The MidiDeviceProvider to check for MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice matching the requirements, or null if none is found
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #27
Source File: MidiSystem.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
 
Example #28
Source File: MidiSystem.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
    @param deviceName The name of the MidiDevice to be returned.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.

    @return A MidiDevice matching the requirements, or null if none is found.
*/
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
 
Example #29
Source File: MidiSystem.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a list of
    MidiDeviceProviders.
    @param deviceName The name of the MidiDevice to be returned.
    @param providers The List of MidiDeviceProviders to check for
    MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A Mixer matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getNamedDevice(deviceName, provider,
                                           deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
 
Example #30
Source File: MidiSystem.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}