Java Code Examples for javax.sound.midi.MidiDevice#Info

The following examples show how to use javax.sound.midi.MidiDevice#Info . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractMidiDeviceProvider.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public final MidiDevice getDevice(MidiDevice.Info info) {
    if (info instanceof Info) {
        readDeviceInfos();
        MidiDevice[] devices = getDeviceCache();
        Info[] infos = getInfoCache();
        Info thisInfo = (Info) info;
        int index = thisInfo.getIndex();
        if (index >= 0 && index < devices.length && infos[index] == info) {
            if (devices[index] == null) {
                devices[index] = createDevice(thisInfo);
            }
            if (devices[index] != null) {
                return devices[index];
            }
        }
    }

    throw new IllegalArgumentException("MidiDevice " + info.toString()
                                       + " not supported by this provider.");
}
 
Example 2
Source File: MidiDeviceProvider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether the device provider supports the device represented by
 * the specified device info object.
 *
 * @param  info an info object that describes the device for which support
 *         is queried
 * @return {@code true} if the specified device is supported, otherwise
 *         {@code false}
 */
public boolean isDeviceSupported(MidiDevice.Info info) {

    MidiDevice.Info infos[] = getDeviceInfo();

    for(int i=0; i<infos.length; i++) {
        if( info.equals( infos[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: RealTimeSequencerProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public MidiDevice getDevice(final MidiDevice.Info info) {
    Objects.requireNonNull(info);
    if (RealTimeSequencer.info.equals(info)) {
        return new RealTimeSequencer();
    }
    throw MidiUtils.unsupportedDevice(info);
}
 
Example 4
Source File: MidiDeviceProvider.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether the device provider supports the device represented by
 * the specified device info object.
 *
 * @param  info an info object that describes the device for which support
 *         is queried
 * @return {@code true} if the specified device is supported, otherwise
 *         {@code false}
 */
public boolean isDeviceSupported(MidiDevice.Info info) {

    MidiDevice.Info infos[] = getDeviceInfo();

    for(int i=0; i<infos.length; i++) {
        if( info.equals( infos[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 5
Source File: MidiDeviceProvider.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether the device provider supports the device represented by
 * the specified device info object.
 *
 * @param  info an info object that describes the device for which support
 *         is queried
 * @return {@code true} if the specified device is supported, otherwise
 *         {@code false}
 */
public boolean isDeviceSupported(MidiDevice.Info info) {

    MidiDevice.Info infos[] = getDeviceInfo();

    for(int i=0; i<infos.length; i++) {
        if( info.equals( infos[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 6
Source File: VolumeScalingReceiver.java    From mochadoom with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int compare(MidiDevice.Info o1, MidiDevice.Info o2) {
    float score1 = score(o1), score2 = score(o2);
    if (score1 < score2) {
        return 1;
    } else if (score1 > score2) {
        return -1;
    } else {
        return 0;
    }
}
 
Example 7
Source File: RealTimeSequencerProvider.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public MidiDevice getDevice(MidiDevice.Info info) {
    if ((info != null) && (!info.equals(RealTimeSequencer.info))) {
        return null;
    }

    try {
        return new RealTimeSequencer();
    } catch (MidiUnavailableException e) {
        return null;
    }
}
 
Example 8
Source File: AbstractMidiDevice.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs an AbstractMidiDevice with the specified info object.
 * @param info the description of the device
 */
/*
 * The initial mode and only supported mode default to OMNI_ON_POLY.
 */
protected AbstractMidiDevice(MidiDevice.Info info) {

    if(Printer.trace) Printer.trace(">> AbstractMidiDevice CONSTRUCTOR");

    this.info = info;
    openRefCount = 0;

    if(Printer.trace) Printer.trace("<< AbstractMidiDevice CONSTRUCTOR completed");
}
 
Example 9
Source File: SoftProvider.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Override
public MidiDevice.Info[] getDeviceInfo() {
    return new MidiDevice.Info[]{SoftSynthesizer.info};
}
 
Example 10
Source File: SoftProvider.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public MidiDevice.Info[] getDeviceInfo() {
    return Arrays.copyOf(softinfos, softinfos.length);
}
 
Example 11
Source File: SoftProvider.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public MidiDevice getDevice(MidiDevice.Info info) {
    if (info == softinfo) {
        return new SoftSynthesizer();
    }
    return null;
}
 
Example 12
Source File: SoftProvider.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public MidiDevice getDevice(MidiDevice.Info info) {
    if (info == softinfo) {
        return new SoftSynthesizer();
    }
    return null;
}
 
Example 13
Source File: RealTimeSequencerProvider.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public MidiDevice.Info[] getDeviceInfo() {

        MidiDevice.Info[] localArray = { RealTimeSequencer.info };
        return localArray;
    }
 
Example 14
Source File: SoftSynthesizer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public MidiDevice.Info getDeviceInfo() {
    return info;
}
 
Example 15
Source File: SoftSynthesizer.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public MidiDevice.Info getDeviceInfo() {
    return info;
}
 
Example 16
Source File: MidiDeviceProvider.java    From tuxguitar with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Obtains an instance of the device represented by the info object.
 * @param info an info object that describes the desired device
 * @return device instance
 * @throws IllegalArgumentException if the info object specified does not
 * match the info object for a device supported by this <code>MidiDeviceProvider</code>.
 */
public abstract MidiDevice getDevice(MidiDevice.Info info);
 
Example 17
Source File: MidiDeviceProvider.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains the set of info objects representing the device or devices
 * provided by this {@code MidiDeviceProvider}.
 *
 * @return set of device info objects
 */
public abstract MidiDevice.Info[] getDeviceInfo();
 
Example 18
Source File: MidiDeviceProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains the set of info objects representing the device or devices
 * provided by this {@code MidiDeviceProvider}.
 *
 * @return set of device info objects
 */
public abstract MidiDevice.Info[] getDeviceInfo();
 
Example 19
Source File: MidiDeviceProvider.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains the set of info objects representing the device or devices
 * provided by this {@code MidiDeviceProvider}.
 *
 * @return set of device info objects
 */
public abstract MidiDevice.Info[] getDeviceInfo();
 
Example 20
Source File: MidiDeviceProvider.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains the set of info objects representing the device or devices
 * provided by this {@code MidiDeviceProvider}.
 *
 * @return set of device info objects
 */
public abstract MidiDevice.Info[] getDeviceInfo();