本文整理汇总了Java中javax.sound.midi.Transmitter类的典型用法代码示例。如果您正苦于以下问题:Java Transmitter类的具体用法?Java Transmitter怎么用?Java Transmitter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transmitter类属于javax.sound.midi包,在下文中一共展示了Transmitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMidiInput
import javax.sound.midi.Transmitter; //导入依赖的package包/类
/**
* Capture midi input events, dispatching them to given Receiver.
* The MidiDevice returned is the device providing the input, and
* should be closed when input events are no longer needed.
* Note that this method returns the first MidiDevice which
* has at least one transmitter.
*
* @param receiver the Receiver to which midi input events should be dispatched
* @return the MidiDevice providing the input events
* @throws MidiUnavailableException if midi input can't be found
*/
public static MidiDevice getMidiInput(Receiver receiver) throws MidiUnavailableException {
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
for (MidiDevice.Info info : infos) {
MidiDevice device;
device = MidiSystem.getMidiDevice(info);
if (DEBUG) {
System.out.println("Found: " + device);
}
int maxTransmitters = device.getMaxTransmitters();
if (DEBUG) {
System.out.println(" Max transmitters: " + maxTransmitters);
}
if (maxTransmitters == -1 || maxTransmitters > 0) {
Transmitter transmitter = device.getTransmitter();
transmitter.setReceiver(receiver);
device.open();
return device;
}
}
throw new MidiUnavailableException("Could not find any midi input sources");
}
示例2: getDefaultProvider
import javax.sound.midi.Transmitter; //导入依赖的package包/类
/** Obtain the value of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
Clip.class or Port.class.
@return The complete value of the property, if available.
If the property is not set, null is returned.
*/
private static synchronized String getDefaultProvider(Class typeClass) {
if (!SourceDataLine.class.equals(typeClass)
&& !TargetDataLine.class.equals(typeClass)
&& !Clip.class.equals(typeClass)
&& !Port.class.equals(typeClass)
&& !Receiver.class.equals(typeClass)
&& !Transmitter.class.equals(typeClass)
&& !Synthesizer.class.equals(typeClass)
&& !Sequencer.class.equals(typeClass)) {
return null;
}
String name = typeClass.getName();
String value = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty(name));
if (value == null) {
value = getProperties().getProperty(name);
}
if ("".equals(value)) {
value = null;
}
return value;
}
示例3: getConnectedDevice
import javax.sound.midi.Transmitter; //导入依赖的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;
}
示例4: getDefaultProvider
import javax.sound.midi.Transmitter; //导入依赖的package包/类
/** Obtain the value of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
Clip.class or Port.class.
@return The complete value of the property, if available.
If the property is not set, null is returned.
*/
private static synchronized String getDefaultProvider(Class<?> typeClass) {
if (!SourceDataLine.class.equals(typeClass)
&& !TargetDataLine.class.equals(typeClass)
&& !Clip.class.equals(typeClass)
&& !Port.class.equals(typeClass)
&& !Receiver.class.equals(typeClass)
&& !Transmitter.class.equals(typeClass)
&& !Synthesizer.class.equals(typeClass)
&& !Sequencer.class.equals(typeClass)) {
return null;
}
String name = typeClass.getName();
String value = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty(name));
if (value == null) {
value = getProperties().getProperty(name);
}
if ("".equals(value)) {
value = null;
}
return value;
}
示例5: openInput
import javax.sound.midi.Transmitter; //导入依赖的package包/类
public static void openInput() throws Exception {
setup();
if (bUseDefaultSynthesizer) {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();
r = synth.getReceiver();
try {
Transmitter t = launchpad_s_plus.Launchpad.getInputDevice()
.getTransmitter();
t.setReceiver(r);
} catch (MidiUnavailableException e) {
out("wasn't able to connect the device's Transmitter to the default Synthesizer:");
out(e);
launchpad_s_plus.Launchpad.getInputDevice().close();
System.exit(1);
}
}
out("\nNow taking input.");
}
示例6: listenStart
import javax.sound.midi.Transmitter; //导入依赖的package包/类
public static void listenStart(){
close();
openedDevices.clear();
MidiDevice device;
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < infos.length; i++) {
try {
device = MidiSystem.getMidiDevice(infos[i]);
System.out.println(infos[i] +" -- "+ infos[i].getDescription());
java.util.List<Transmitter> transmitters = device.getTransmitters();
for(int j = 0; j<transmitters.size();j++) {
transmitters.get(j).setReceiver(receiver);
}
Transmitter trans = device.getTransmitter();
trans.setReceiver(receiver);
device.open();
openedDevices.add(device);
System.out.println(device.getDeviceInfo()+" Was Opened");
} catch (MidiUnavailableException e) {
// e.printStackTrace();
}
}
}
示例7: getDefaultProvider
import javax.sound.midi.Transmitter; //导入依赖的package包/类
/** Obtain the value of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
Clip.class or Port.class.
@return The complete value of the property, if available.
If the property is not set, null is returned.
*/
private static synchronized String getDefaultProvider(Class typeClass) {
if (!SourceDataLine.class.equals(typeClass)
&& !TargetDataLine.class.equals(typeClass)
&& !Clip.class.equals(typeClass)
&& !Port.class.equals(typeClass)
&& !Receiver.class.equals(typeClass)
&& !Transmitter.class.equals(typeClass)
&& !Synthesizer.class.equals(typeClass)
&& !Sequencer.class.equals(typeClass)) {
return null;
}
String value;
String propertyName = typeClass.getName();
value = JSSecurityManager.getProperty(propertyName);
if (value == null) {
value = getProperties().getProperty(propertyName);
}
if ("".equals(value)) {
value = null;
}
return value;
}
示例8: MidiReciever
import javax.sound.midi.Transmitter; //导入依赖的package包/类
public MidiReciever()
{
MidiDevice device;
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < infos.length; i++) {
try {
device = MidiSystem.getMidiDevice(infos[i]);
//does the device have any transmitters?
//if it does, add it to the device list
System.out.println(infos[i]);
//get all transmitters
List<Transmitter> transmitters = device.getTransmitters();
//and for each transmitter
for(int j = 0; j<transmitters.size();j++) {
//create a new receiver
transmitters.get(j).setReceiver(
//using my own MidiInputReceiver
new MidiInputReceiver(device.getDeviceInfo().toString())
);
}
Transmitter trans = device.getTransmitter();
trans.setReceiver(new MidiInputReceiver(device.getDeviceInfo().toString()));
//open each device
device.open();
//if code gets this far without throwing an exception
//print a success message
System.out.println(device.getDeviceInfo()+" Was Opened");
} catch (MidiUnavailableException e) {}
}
}
示例9: getDefaultInputDevice
import javax.sound.midi.Transmitter; //导入依赖的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);
}
}
示例10: close
import javax.sound.midi.Transmitter; //导入依赖的package包/类
/**
* Closes the MIDI transmitter.
*
* @param transmitter the MIDI transmitter.
*/
public static void close(Transmitter transmitter) {
try {
if (transmitter != null) {
transmitter.close();
}
} catch (Exception e) {
logger.warn("close", e);
}
}
示例11: getTransmitter
import javax.sound.midi.Transmitter; //导入依赖的package包/类
/**
* This implementation uses createTransmitter, which may throw an exception.
* If a transmitter is returned in createTransmitter, it is added to the internal
* TransmitterList
*/
@Override
public final Transmitter getTransmitter() throws MidiUnavailableException {
Transmitter transmitter;
synchronized (traRecLock) {
transmitter = createTransmitter(); // may throw MidiUnavailableException
getTransmitterList().add(transmitter);
}
return transmitter;
}
示例12: getTransmitters
import javax.sound.midi.Transmitter; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Transmitter> getTransmitters() {
List<Transmitter> tras;
synchronized (traRecLock) {
if (transmitterList == null
|| transmitterList.transmitters.size() == 0) {
tras = Collections.unmodifiableList(new ArrayList<Transmitter>(0));
} else {
tras = Collections.unmodifiableList((List<Transmitter>) (transmitterList.transmitters.clone()));
}
}
return tras;
}
示例13: getTransmitterReferenceCounting
import javax.sound.midi.Transmitter; //导入依赖的package包/类
/** Retrieve a Transmitter and open the device implicitly.
This method is called by MidiSystem.getTransmitter().
*/
@Override
public final Transmitter getTransmitterReferenceCounting()
throws MidiUnavailableException {
/* Keep this order of commands! If getTransmitter() throws an exception,
openInternal() should not be called!
*/
Transmitter transmitter;
synchronized (traRecLock) {
transmitter = getTransmitter();
AbstractMidiDevice.this.openInternal(transmitter);
}
return transmitter;
}
示例14: add
import javax.sound.midi.Transmitter; //导入依赖的package包/类
private void add(Transmitter t) {
synchronized(transmitters) {
transmitters.add(t);
}
if (t instanceof BasicTransmitter) {
((BasicTransmitter) t).setTransmitterList(this);
}
if (Printer.debug) Printer.debug("--added transmitter "+t);
}
示例15: remove
import javax.sound.midi.Transmitter; //导入依赖的package包/类
private void remove(Transmitter t) {
synchronized(transmitters) {
int index = transmitters.indexOf(t);
if (index >= 0) {
transmitters.remove(index);
if (Printer.debug) Printer.debug("--removed transmitter "+t);
}
}
}