本文整理匯總了Java中javax.sound.midi.Sequencer.getTransmitters方法的典型用法代碼示例。如果您正苦於以下問題:Java Sequencer.getTransmitters方法的具體用法?Java Sequencer.getTransmitters怎麽用?Java Sequencer.getTransmitters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sound.midi.Sequencer
的用法示例。
在下文中一共展示了Sequencer.getTransmitters方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConnectedDevice
import javax.sound.midi.Sequencer; //導入方法依賴的package包/類
static MidiDevice getConnectedDevice(Sequencer sequencer) {
List<Transmitter> trans = sequencer.getTransmitters();
log(" sequencer has " + trans.size() + " opened transmitters:");
for (Transmitter tr: trans) {
Receiver r = tr.getReceiver();
log(" " + getClassStr(tr) + " connected to " + getClassStr(r));
if (r instanceof MidiDeviceReceiver) {
MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
MidiDevice dev = recv.getMidiDevice();
log(" - receiver of " + getClassStr(dev));
return dev;
} else {
log(" - does NOT implement MidiDeviceReceiver");
}
}
return null;
}
示例2: doTest
import javax.sound.midi.Sequencer; //導入方法依賴的package包/類
public static void doTest(int mode) {
Sequencer seq = null;
boolean connected = false;
try {
switch (mode) {
case 1:
seq = MidiSystem.getSequencer();
connected = true;
break;
case 2:
seq = MidiSystem.getSequencer(false);
connected = false;
break;
case 3:
seq = MidiSystem.getSequencer(true);
connected = true;
break;
}
out("Testing Sequencer "+seq);
if (connected) {
out(" opened in connected mode.");
} else {
out(" opened in non-connected mode.");
}
System.out.println(" opening...");
seq.open();
} catch (MidiUnavailableException mue) {
System.err.println("MidiUnavailableException was thrown: " + mue);
System.err.println(" could not test this sequencer.");
return;
}
try {
List<Transmitter> transmitters = seq.getTransmitters();
int size = transmitters.size();
out(" transmitters.size()="+size);
if (size != 1 && connected) {
out(" should have 1 connection! Failed.");
failed = true;
}
if (size != 0 && !connected) {
out(" should have 0 connections! Failed.");
failed = true;
}
out(" closing...");
seq.close();
transmitters = seq.getTransmitters();
size = transmitters.size();
out(" transmitters.size()="+size);
if (size != 0) {
out(" should have 0 connections! Failed.");
failed = true;
}
out(" opening again...");
seq.open();
transmitters = seq.getTransmitters();
size = transmitters.size();
out(" transmitters.size()="+size);
if (size != 1 && connected) {
out(" should have 1 connection! Failed.");
failed = true;
}
if (size != 0 && !connected) {
out(" should have 0 connections! Failed.");
failed = true;
}
} catch (Exception e) {
System.err.println(" unexpectedException was thrown: " + e);
System.err.println(" causes this test to FAIL.");
failed = true;
}
seq.close();
}