本文整理匯總了Java中javax.sound.midi.MidiDevice.getMaxTransmitters方法的典型用法代碼示例。如果您正苦於以下問題:Java MidiDevice.getMaxTransmitters方法的具體用法?Java MidiDevice.getMaxTransmitters怎麽用?Java MidiDevice.getMaxTransmitters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sound.midi.MidiDevice
的用法示例。
在下文中一共展示了MidiDevice.getMaxTransmitters方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
}
}
}
}
示例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: canIn
import javax.sound.midi.MidiDevice; //導入方法依賴的package包/類
private static String canIn(MidiDevice dev) {
if (dev.getMaxTransmitters() != 0) {
return "IN ";
}
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.");
}
}