Java Code Examples for javax.sound.midi.spi.MidiDeviceProvider

The following examples show how to use javax.sound.midi.spi.MidiDeviceProvider. These examples are extracted from open source projects. 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 Project: jdk8u_jdk   Source File: MidiSystem.java    License: 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 2
Source Project: Java8CN   Source File: MidiSystem.java    License: 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,
                                         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 3
Source Project: jdk8u-dev-jdk   Source File: MidiSystem.java    License: 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 Project: jdk8u-jdk   Source File: MidiSystem.java    License: 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 5
Source Project: jdk1.8-source-analysis   Source File: MidiSystem.java    License: Apache License 2.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 6
/**
 * 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 7
Source Project: jdk8u-jdk   Source File: MidiSystem.java    License: 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 Project: openjdk-8-source   Source File: MidiSystem.java    License: 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 9
Source Project: hottub   Source File: MidiSystem.java    License: 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 10
Source Project: dragonwell8_jdk   Source File: MidiSystem.java    License: 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 11
Source Project: dragonwell8_jdk   Source File: MidiSystem.java    License: 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 12
Source Project: TencentKona-8   Source File: JDK13Services.java    License: 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 13
Source Project: jdk8u_jdk   Source File: MidiSystem.java    License: 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 14
Source Project: jdk8u-jdk   Source File: MidiSystem.java    License: 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 15
Source Project: TencentKona-8   Source File: MidiSystem.java    License: 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 16
Source Project: TencentKona-8   Source File: MidiSystem.java    License: 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 Project: hottub   Source File: MidiSystem.java    License: 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 18
Source Project: openjdk-jdk9   Source File: UnsupportedInfo.java    License: 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 19
Source Project: jdk8u60   Source File: MidiSystem.java    License: 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 20
Source Project: jdk8u60   Source File: MidiSystem.java    License: 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 21
Source Project: Bytecoder   Source File: MidiSystem.java    License: 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 22
Source Project: jdk8u60   Source File: MidiSystem.java    License: 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 23
Source Project: jdk8u-jdk   Source File: JDK13Services.java    License: 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 24
Source Project: openjdk-jdk9   Source File: MidiSystem.java    License: 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 25
Source Project: JDKSourceCode1.8   Source File: MidiSystem.java    License: 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 26
Source Project: JDKSourceCode1.8   Source File: MidiSystem.java    License: 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 27
Source Project: JDKSourceCode1.8   Source File: MidiSystem.java    License: 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 28
Source Project: openjdk-jdk8u   Source File: JDK13Services.java    License: 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 29
Source Project: openjdk-8   Source File: MidiSystem.java    License: 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 30
Source Project: Bytecoder   Source File: MidiSystem.java    License: 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;
}