本文整理汇总了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();
}