本文整理汇总了Java中javax.sound.midi.MidiDevice.getMaxReceivers方法的典型用法代码示例。如果您正苦于以下问题:Java MidiDevice.getMaxReceivers方法的具体用法?Java MidiDevice.getMaxReceivers怎么用?Java MidiDevice.getMaxReceivers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.midi.MidiDevice
的用法示例。
在下文中一共展示了MidiDevice.getMaxReceivers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doAll
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
private static void doAll() throws Exception {
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
for (int i=0; i < infos.length; i++) {
MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
if ((! (device instanceof Sequencer)) &&
(! (device instanceof Synthesizer)) &&
(device.getMaxReceivers() > 0 || device.getMaxReceivers() == -1)) {
System.out.println("--------------");
System.out.println("Testing MIDI device: " + infos[i]);
testDevice(device);
}
if (infos.length==0) {
System.out.println("No MIDI devices available!");
}
}
}
示例2: doTest
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
private static boolean doTest(int numIterations, boolean input) throws Exception {
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
MidiDevice outDevice = null;
MidiDevice inDevice = null;
for (int i = 0; i < infos.length; i++) {
MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
if (! (device instanceof Sequencer) &&
! (device instanceof Synthesizer)) {
if (device.getMaxReceivers() != 0) {
outDevice = device;
}
if (device.getMaxTransmitters() != 0) {
inDevice = device;
}
}
}
MidiDevice testDevice = null;
if (input) {
testDevice = inDevice;
} else {
testDevice = outDevice;
}
if (testDevice == null) {
out("Cannot test: device not available.");
return true;
}
out("Using Device: " + testDevice);
for (int i = 0; i < numIterations; i++) {
out("@@@ ITERATION: " + i);
testDevice.open();
// This sleep ensures that the thread of MidiInDevice is started.
sleep(50);
testDevice.close();
}
return true;
}
示例3: canOut
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
private static String canOut(MidiDevice dev) {
if (dev.getMaxReceivers() != 0) {
return "OUT ";
}
return " ";
}
示例4: main
import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
out("4356787: MIDI device I/O is not working (windows)");
if (System.getProperty("os.name").startsWith("Windows")) {
boolean forInput=true;
boolean forOutput=true;
int outOnlyCount=0;
int inOnlyCount=0;
out(" available MIDI devices:");
MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < aInfos.length; i++) {
try {
MidiDevice device = MidiSystem.getMidiDevice(aInfos[i]);
boolean bAllowsInput = (device.getMaxTransmitters() != 0);
boolean bAllowsOutput = (device.getMaxReceivers() != 0);
if (bAllowsInput && !bAllowsOutput) {
inOnlyCount++;
}
if (!bAllowsInput && bAllowsOutput) {
outOnlyCount++;
}
if ((bAllowsInput && forInput) || (bAllowsOutput && forOutput)) {
out(""+i+" "
+(bAllowsInput?"IN ":" ")
+(bAllowsOutput?"OUT ":" ")
+aInfos[i].getName()+", "
+aInfos[i].getVendor()+", "
+aInfos[i].getVersion()+", "
+aInfos[i].getDescription());
}
}
catch (MidiUnavailableException e) {
// device is obviously not available...
}
}
if (aInfos.length == 0) {
out("No devices available. Test should be run on systems with MIDI drivers installed.");
} else {
if (outOnlyCount>1) {
if (inOnlyCount==0) {
//throw new Exception("No input devices! test fails.");
out("System provides out devices, but no input devices. This means either");
out("a bug in Java Sound, or the drivers are not set up correctly.");
}
out("Test passed.");
} else {
out("no MIDI I/O installed. Test should be run on systems with MIDI drivers installed.");
}
}
} else {
out(" -- not on Windows. Test doesn't apply.");
}
}