当前位置: 首页>>代码示例>>Java>>正文


Java MidiDeviceProvider.getDevice方法代码示例

本文整理汇总了Java中javax.sound.midi.spi.MidiDeviceProvider.getDevice方法的典型用法代码示例。如果您正苦于以下问题:Java MidiDeviceProvider.getDevice方法的具体用法?Java MidiDeviceProvider.getDevice怎么用?Java MidiDeviceProvider.getDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.midi.spi.MidiDeviceProvider的用法示例。


在下文中一共展示了MidiDeviceProvider.getDevice方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNamedDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/** 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:MidiSystem.java

示例2: main

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
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
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:UnsupportedInfo.java

示例3: getNamedDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:27,代码来源:MidiSystem.java

示例4: getMidiDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
 * Get the specified MIDI device.
 *
 * @param info a description of the device we're looking for
 * @return the requested MIDI device
 * @throws MidiUnavailableException if no MIDI devices are configured or found
 * @throws IllegalArgumentException if the device described by info is not found
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info)
  throws MidiUnavailableException
{
  Iterator deviceProviders =
      ServiceFactory.lookupProviders(MidiDeviceProvider.class);

  if (! deviceProviders.hasNext())
    throw new MidiUnavailableException("No MIDI device providers available.");

  do
  {
    MidiDeviceProvider provider =
      (MidiDeviceProvider) deviceProviders.next();
    if (provider.isDeviceSupported(info))
      return provider.getDevice(info);
  } while (deviceProviders.hasNext());

  throw new IllegalArgumentException("MIDI device "
                                     + info + " not available.");
}
 
开发者ID:vilie,项目名称:javify,代码行数:29,代码来源:MidiSystem.java

示例5: getMidiDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
  * Get the specified MIDI device.
  * 
  * @param info a description of the device we're looking for
  * @return the requested MIDI device
  * @throws MidiUnavailableException if no MIDI devices are configured or found
  * @throws IllegalArgumentException if the device described by info is not found
  */
 public static MidiDevice getMidiDevice(MidiDevice.Info info) 
   throws MidiUnavailableException
 {
   Iterator deviceProviders = 
ServiceFactory.lookupProviders(MidiDeviceProvider.class);
   
   if (! deviceProviders.hasNext())
     throw new MidiUnavailableException("No MIDI device providers available.");
   
   do
   {
     MidiDeviceProvider provider = 
       (MidiDeviceProvider) deviceProviders.next();
     if (provider.isDeviceSupported(info))
       return provider.getDevice(info);
   } while (deviceProviders.hasNext());
   
   throw new IllegalArgumentException("MIDI device " 
			       + info + " not available.");
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:29,代码来源:MidiSystem.java

示例6: getMidiDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
 * Get the specified MIDI device.
 *
 * @param info a description of the device we're looking for
 * @return the requested MIDI device
 * @throws MidiUnavailableException if no MIDI devices are configured or found
 * @throws IllegalArgumentException if the device described by info is not found
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info)
  throws MidiUnavailableException
{
  Iterator<MidiDeviceProvider> deviceProviders =
      ServiceFactory.lookupProviders(MidiDeviceProvider.class);

  if (! deviceProviders.hasNext())
    throw new MidiUnavailableException("No MIDI device providers available.");

  do
  {
    MidiDeviceProvider provider =
      (MidiDeviceProvider) deviceProviders.next();
    if (provider.isDeviceSupported(info))
      return provider.getDevice(info);
  } while (deviceProviders.hasNext());

  throw new IllegalArgumentException("MIDI device "
                                     + info + " not available.");
}
 
开发者ID:cfriedt,项目名称:classpath,代码行数:29,代码来源:MidiSystem.java

示例7: getMidiDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:MidiSystem.java

示例8: getFirstDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/** 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,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int j = 0; j < infos.length; j++) {
        MidiDevice device = provider.getDevice(infos[j]);
        if (isAppropriateDevice(device, deviceClass,
                                allowSynthesizer, allowSequencer)) {
            return device;
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:MidiSystem.java

示例9: getFirstDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
 * 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,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int j = 0; j < infos.length; j++) {
        MidiDevice device = provider.getDevice(infos[j]);
        if (isAppropriateDevice(device, deviceClass,
                                allowSynthesizer, allowSequencer)) {
            return device;
        }
    }
    return null;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:24,代码来源:MidiSystem.java

示例10: getNamedDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
 * 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
 * @param  allowSynthesizer if true, Synthesizers are considered
 *         appropriate. Otherwise only pure MidiDevices are considered
 *         appropriate (unless allowSequencer is true). This flag only has
 *         an effect for deviceClass Receiver and Transmitter. For other
 *         device classes (Sequencer and Synthesizer), this flag has no
 *         effect.
 * @param  allowSequencer if true, Sequencers are considered appropriate.
 *         Otherwise only pure MidiDevices are considered appropriate
 *         (unless allowSynthesizer is true). This flag only has an effect
 *         for deviceClass Receiver and Transmitter. For other device
 *         classes (Sequencer and Synthesizer), this flag has no effect.
 * @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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:MidiSystem.java

示例11: getMidiDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
 * Obtains the requested MIDI device.
 *
 * @param  info a device information object representing the desired device
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 *         due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent a
 *         MIDI device installed on the system
 * @throws NullPointerException if {@code info} is {@code null}
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(final MidiDevice.Info info)
        throws MidiUnavailableException {
    Objects.requireNonNull(info);
    for (final MidiDeviceProvider provider : getMidiDeviceProviders()) {
        if (provider.isDeviceSupported(info)) {
            return provider.getDevice(info);
        }
    }
    throw new IllegalArgumentException(String.format(
            "Requested device not installed: %s", info));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:MidiSystem.java

示例12: getFirstDevice

import javax.sound.midi.spi.MidiDeviceProvider; //导入方法依赖的package包/类
/**
 * 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
 * @param  allowSynthesizer if true, Synthesizers are considered
 *         appropriate. Otherwise only pure MidiDevices are considered
 *         appropriate (unless allowSequencer is true). This flag only has
 *         an effect for deviceClass Receiver and Transmitter. For other
 *         device classes (Sequencer and Synthesizer), this flag has no
 *         effect.
 * @param  allowSequencer if true, Sequencers are considered appropriate.
 *         Otherwise only pure MidiDevices are considered appropriate
 *         (unless allowSynthesizer is true). This flag only has an effect
 *         for deviceClass Receiver and Transmitter. For other device
 *         classes (Sequencer and Synthesizer), this flag has no effect.
 * @return A MidiDevice is considered appropriate, or null if no appropriate
 *         device is found
 */
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class<?> deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int j = 0; j < infos.length; j++) {
        MidiDevice device = provider.getDevice(infos[j]);
        if (isAppropriateDevice(device, deviceClass,
                                allowSynthesizer, allowSequencer)) {
            return device;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:MidiSystem.java


注:本文中的javax.sound.midi.spi.MidiDeviceProvider.getDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。