本文整理汇总了Java中javax.sound.midi.MidiDevice.Info方法的典型用法代码示例。如果您正苦于以下问题:Java MidiDevice.Info方法的具体用法?Java MidiDevice.Info怎么用?Java MidiDevice.Info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.midi.MidiDevice
的用法示例。
在下文中一共展示了MidiDevice.Info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.sound.midi.MidiDevice; //导入方法依赖的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
}
}
}
}
}
示例2: getDevice
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
public final MidiDevice getDevice(MidiDevice.Info info) {
if (info instanceof Info) {
readDeviceInfos();
MidiDevice[] devices = getDeviceCache();
Info[] infos = getInfoCache();
Info thisInfo = (Info) info;
int index = thisInfo.getIndex();
if (index >= 0 && index < devices.length && infos[index] == info) {
if (devices[index] == null) {
devices[index] = createDevice(thisInfo);
}
if (devices[index] != null) {
return devices[index];
}
}
}
throw new IllegalArgumentException("MidiDevice " + info.toString()
+ " not supported by this provider.");
}
示例3: getDevice
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
@Override
public final MidiDevice getDevice(final MidiDevice.Info info) {
Objects.requireNonNull(info);
if (info instanceof Info) {
readDeviceInfos();
MidiDevice[] devices = getDeviceCache();
Info[] infos = getInfoCache();
Info thisInfo = (Info) info;
int index = thisInfo.getIndex();
if (index >= 0 && index < devices.length && infos[index] == info) {
if (devices[index] == null) {
devices[index] = createDevice(thisInfo);
}
if (devices[index] != null) {
return devices[index];
}
}
}
throw MidiUtils.unsupportedDevice(info);
}
示例4: isMidiInstalled
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
/**
* Returns true if at least one MIDI (port) device is correctly installed on
* the system.
*/
public static boolean isMidiInstalled() {
boolean result = false;
MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < devices.length; i++) {
try {
MidiDevice device = MidiSystem.getMidiDevice(devices[i]);
result = ! (device instanceof Sequencer) && ! (device instanceof Synthesizer);
} catch (Exception e1) {
System.err.println(e1);
}
if (result)
break;
}
return result;
}
示例5: update
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
@Override
public void update() throws Exception
{
this.transmitterLoop++;
if (this.transmitterLoop % 600 == 0)
{
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < infos.length; i++)
{
MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
if (NMOConfiguration.INSTANCE.integrations.midiTransmitter.transmitters.contains(device.getDeviceInfo().getName()))
{
if (!device.isOpen() && device.getMaxTransmitters() != 0)
{
final String name = device.getDeviceInfo().getName() + "/" + device.getDeviceInfo().getDescription() + "/" + device.getDeviceInfo().getVendor();
log.info("Connected MIDI device: " + name);
device.getTransmitter().setReceiver(new Receiver()
{
@Override
public void send(MidiMessage message, long timeStamp)
{
MainDialog.resetActivityTimer(MIDI_TRANSMITTER);
}
@Override
public void close()
{
log.info("Disconnected MIDI device: " + name);
}
});
device.open();
}
}
}
}
}
示例6: getDevice
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
@Override
public MidiDevice getDevice(final MidiDevice.Info info) {
Objects.requireNonNull(info);
if (SoftSynthesizer.info.equals(info)) {
return new SoftSynthesizer();
}
throw MidiUtils.unsupportedDevice(info);
}
示例7: getDeviceMap
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
/**
* Returns the map of all available MIDI devices.
*
* @return the map of all available MIDI devices.
*/
public static Map<MidiDevice.Info, MidiDevice> getDeviceMap() {
Map<MidiDevice.Info, MidiDevice> result = new LinkedHashMap<>();
try {
for (Info info : MidiSystem.getMidiDeviceInfo()) {
result.put(info, MidiSystem.getMidiDevice(info));
}
} catch (MidiUnavailableException e) {
throw SpongeUtils.wrapException(e);
}
return result;
}
示例8: getDeviceInfo
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
public final MidiDevice.Info[] getDeviceInfo() {
readDeviceInfos();
Info[] infos = getInfoCache();
MidiDevice.Info[] localArray = new MidiDevice.Info[infos.length];
System.arraycopy(infos, 0, localArray, 0, infos.length);
return localArray;
}
示例9: getDeviceInfo
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
@Override
public final MidiDevice.Info[] getDeviceInfo() {
readDeviceInfos();
Info[] infos = getInfoCache();
MidiDevice.Info[] localArray = new MidiDevice.Info[infos.length];
System.arraycopy(infos, 0, localArray, 0, infos.length);
return localArray;
}
示例10: isDeviceSupported
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
/**
* Indicates whether the device provider supports the device represented by
* the specified device info object.
*
* @param info an info object that describes the device for which support
* is queried
* @return {@code true} if the specified device is supported, otherwise
* {@code false}
*/
public boolean isDeviceSupported(MidiDevice.Info info) {
MidiDevice.Info infos[] = getDeviceInfo();
for(int i=0; i<infos.length; i++) {
if( info.equals( infos[i] ) ) {
return true;
}
}
return false;
}
示例11: AbstractMidiDevice
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
/**
* Constructs an AbstractMidiDevice with the specified info object.
* @param info the description of the device
*/
/*
* The initial mode and only supported mode default to OMNI_ON_POLY.
*/
protected AbstractMidiDevice(MidiDevice.Info info) {
if(Printer.trace) Printer.trace(">> AbstractMidiDevice CONSTRUCTOR");
this.info = info;
openRefCount = 0;
if(Printer.trace) Printer.trace("<< AbstractMidiDevice CONSTRUCTOR completed");
}
示例12: getDeviceInfo
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
public MidiDevice.Info[] getDeviceInfo() {
MidiDevice.Info[] localArray = { RealTimeSequencer.info };
return localArray;
}
示例13: getDevice
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
public MidiDevice getDevice(MidiDevice.Info info) {
if (info == softinfo) {
return new SoftSynthesizer();
}
return null;
}
示例14: getDeviceInfo
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
@Override
public MidiDevice.Info[] getDeviceInfo() {
return new MidiDevice.Info[]{RealTimeSequencer.info};
}
示例15: testDevices
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
private static boolean testDevices(MidiDevice.Info[] infos,
String providerClassName) {
boolean allOk = true;
for (int i = 0; i < infos.length; i++) {
MidiDevice device = null;
try {
device = MidiSystem.getMidiDevice(infos[i]);
} catch (MidiUnavailableException e) {
out("Exception thrown; Test NOT failed.");
e.printStackTrace(System.out);
out("");
}
out("\nTesting device: " + device);
if (device instanceof Sequencer) {
allOk &= testDevice(device, SEQUENCER_CLASS, providerClassName, true, true);
// incorrect cases
allOk &= testDevice(device, SYNTHESIZER_CLASS, providerClassName, false, false);
allOk &= testDevice(device, RECEIVER_CLASS, providerClassName, false, false);
allOk &= testDevice(device, TRANSMITTER_CLASS, providerClassName, false, false);
}
if (device instanceof Synthesizer) {
allOk &= testDevice(device, SYNTHESIZER_CLASS, providerClassName, true, true);
allOk &= testDevice(device, RECEIVER_CLASS, providerClassName, false, true);
// incorrect cases
allOk &= testDevice(device, TRANSMITTER_CLASS, providerClassName, false, false);
allOk &= testDevice(device, SEQUENCER_CLASS, providerClassName, false, false);
}
if (device instanceof Receiver) {
allOk &= testDevice(device, RECEIVER_CLASS, providerClassName, true, true);
// incorrect cases
allOk &= testDevice(device, TRANSMITTER_CLASS, providerClassName, false, false);
allOk &= testDevice(device, SYNTHESIZER_CLASS, providerClassName, false, false);
allOk &= testDevice(device, SEQUENCER_CLASS, providerClassName, false, false);
}
if (device instanceof Transmitter) {
allOk &= testDevice(device, TRANSMITTER_CLASS, providerClassName, true, true);
// incorrect cases
allOk &= testDevice(device, RECEIVER_CLASS, providerClassName, false, false);
allOk &= testDevice(device, SYNTHESIZER_CLASS, providerClassName, false, false);
allOk &= testDevice(device, SEQUENCER_CLASS, providerClassName, false, false);
}
}
return allOk;
}