本文整理匯總了Java中javax.sound.midi.MidiSystem.getTransmitter方法的典型用法代碼示例。如果您正苦於以下問題:Java MidiSystem.getTransmitter方法的具體用法?Java MidiSystem.getTransmitter怎麽用?Java MidiSystem.getTransmitter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sound.midi.MidiSystem
的用法示例。
在下文中一共展示了MidiSystem.getTransmitter方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
/**
* Initialise the input source
*/
private boolean init() {
if (trans == null) {
try {
if (MidiSystem.getReceiver() == null) {
System.err.println("MidiSystem Receiver Unavailable");
return false;
}
MidiDevice.Info[] mdi=MidiSystem.getMidiDeviceInfo();
for(int i=0;i<mdi.length;i++){
System.out.println(mdi[i]);
}
trans = MidiSystem.getTransmitter();
trans.setReceiver(this);
}catch (MidiUnavailableException e) {
System.err.println("Midi System Unavailable:" + e);
return false;
}
}
return true;
}
示例2: getDefaultInputDevice
import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
/**
* Returns the default input MIDI device.
*
* @return the default input MIDI device or {@code null} if not found.
*/
public static MidiDevice getDefaultInputDevice() {
try {
Transmitter transmitter = MidiSystem.getTransmitter();
if (transmitter != null && transmitter instanceof MidiDeviceTransmitter) {
return ((MidiDeviceTransmitter) transmitter).getMidiDevice();
}
return null;
} catch (MidiUnavailableException e) {
throw SpongeUtils.wrapException(e);
}
}
示例3: test
import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
boolean test() {
openThread = new Thread(new Runnable() {
public void run() {
try {
log("openThread: getting transmitter...");
transmitter = MidiSystem.getTransmitter();
log("openThread: - OK: " + transmitter);
} catch (MidiUnavailableException ex) {
log("openThread: - Exception: ");
ex.printStackTrace(System.out);
log("openThread: skipping...");
}
log("openThread: exiting...");
}
});
log("starting openThread...");
openThread.start();
while (openThread.isAlive())
delay(500);
// make additional delay
delay(500);
if (transmitter == null) {
return true; // midi is not available, just ignore
}
log("closing transmitter");
transmitter.close();
log(" - OK");
return true;
}
示例4: testDevice
import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
private static boolean testDevice(MidiDevice device, Class type,
String providerClassName, String instanceName,
boolean expectedResult) {
boolean allOk = true;
try {
String propertyName = type.getName();
String propertyValue = (providerClassName != null) ? providerClassName: "" ;
propertyValue += "#" + instanceName;
out("property: " + propertyName + "="+ propertyValue);
System.setProperty(propertyName, propertyValue);
Object reference = null;
Object result = null;
if (type == SEQUENCER_CLASS) {
reference = device;
result = MidiSystem.getSequencer();
} else if (type == SYNTHESIZER_CLASS) {
reference = device;
result = MidiSystem.getSynthesizer();
} else if (type == RECEIVER_CLASS) {
reference = device.getReceiver();
result = MidiSystem.getReceiver();
} else if (type == TRANSMITTER_CLASS) {
reference = device.getTransmitter();
result = MidiSystem.getTransmitter();
}
out("result: " + result);
boolean rightDevice = (reference.getClass() == result.getClass());
if (rightDevice != expectedResult) {
out("\nERROR: type " + type + " failed:"
+ " class should" + (expectedResult ? "" : " NOT") + " be '"
+ reference.getClass()
+ "' but is '" + result.getClass() + "'!\n");
allOk = false;
}
if (expectedResult
&& reference instanceof MidiDevice
&& result instanceof MidiDevice) {
MidiDevice referenceDevice = (MidiDevice)reference;
MidiDevice resultDevice = (MidiDevice)result;
if (!referenceDevice.getDeviceInfo().getName().equals(
resultDevice.getDeviceInfo().getName())) {
out("\nERROR: type " + type + " failed: name should be '"
+ referenceDevice.getDeviceInfo().getName()
+ "' but is '"
+ resultDevice.getDeviceInfo().getName() + "'!\n");
allOk = false;
}
}
if (result instanceof Receiver) {
((Receiver)result).close();
} else if (result instanceof Transmitter) {
((Transmitter)result).close();
} else if (result instanceof Synthesizer) {
((Synthesizer)result).close();
} else if (result instanceof Sequencer) {
((Sequencer)result).close();
}
} catch (Exception e) {
out("Exception thrown; Test NOT failed.");
e.printStackTrace(System.out);
out("");
}
return allOk;
}
示例5: fetchObjectMidiSystem
import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
public void fetchObjectMidiSystem() throws MidiUnavailableException {
transmitterMidiSystem = MidiSystem.getTransmitter();
}
示例6: Launchpad
import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
/**
* This is the full configured solution if you want to receive notifications if a {@link Pad} is
* being pressed, and want to configure the midi channel (default is {@link Channel#C1}) of your
* launchpad.
*
* @param channel The {@link Channel} to send and receive data to and from.
* @param launchpadReceiver The {@link LaunchpadReceiver} implementation that will receive the
* information if a {@link Pad} is pressed.
* @throws MidiUnavailableException No midi device could be found, is your launchpad connected to
* your computer?
*/
public Launchpad(Channel channel, LaunchpadReceiver launchpadReceiver)
throws MidiUnavailableException {
this.channel = channel;
transmitter = MidiSystem.getTransmitter();
receiver = MidiSystem.getReceiver();
this.launchpadReceiver = launchpadReceiver;
transmitter.setReceiver(this);
}