本文整理汇总了Java中javax.sound.midi.MidiSystem.getReceiver方法的典型用法代码示例。如果您正苦于以下问题:Java MidiSystem.getReceiver方法的具体用法?Java MidiSystem.getReceiver怎么用?Java MidiSystem.getReceiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.midi.MidiSystem
的用法示例。
在下文中一共展示了MidiSystem.getReceiver方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReceiverSend
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
/**
* Execute Receiver.send() and expect that there is no exception.
*/
private static boolean testReceiverSend() {
boolean result = true;
Receiver receiver;
ShortMessage shMsg = new ShortMessage();
try {
receiver = MidiSystem.getReceiver();
shMsg.setMessage(ShortMessage.NOTE_ON, 0,60, 93);
try {
receiver.send( shMsg, -1 );
} catch(IllegalStateException ilEx) {
ilEx.printStackTrace(System.out);
out("IllegalStateException was thrown incorrectly!");
result = false;
}
receiver.close();
} catch(MidiUnavailableException e) {
out("Midi unavailable, cannot test.");
} catch(InvalidMidiDataException ine) {
out("InvalidMidiDataException, cannot test.");
}
return result;
}
示例2: 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;
}
示例3: main
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public static void main(final String[] argv) {
try {
MidiSystem.getReceiver();
Toolkit.getDefaultToolkit();
} catch (final MidiUnavailableException ignored) {
// the test is not applicable
}
}
示例4: SoundCache
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public SoundCache() {
try {
midiSequencer = MidiSystem.getSequencer(false);
midiReceiver = MidiSystem.getReceiver();
midiAvailable = true;
logger.info("MIDI is available on this system.");
} catch (MidiUnavailableException error) {
logger.warn("MIDI is unsupported on this system.", error);
midiAvailable = false;
}
setVolume(0.5);
}
示例5: MidiModule
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public MidiModule() {
Receiver tempReceiver = null;
if (Property.MIDI.isTrue()) {
try {
tempReceiver = MidiSystem.getReceiver();
log.info("Midi module loaded");
} catch (MidiUnavailableException e) {
log.error("Midi module failed to load {}", e);
}
}
receiver = tempReceiver;
}
示例6: main
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public static void main(final String[] argv) throws Exception {
MidiSystem.getReceiver();
Toolkit.getDefaultToolkit();
}
示例7: 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;
}
示例8: fetchObjectMidiSystem
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public void fetchObjectMidiSystem() throws MidiUnavailableException {
receiverMidiSystem = MidiSystem.getReceiver();
}
示例9: createReceiver
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
@Override protected Receiver createReceiver() throws MidiUnavailableException
{
return (lotroSynth != null) ? lotroSynth.getReceiver() : MidiSystem.getReceiver();
}
示例10: createReceiver
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
protected Receiver createReceiver() throws MidiUnavailableException
{
return MidiSystem.getReceiver();
}
示例11: 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);
}