Example usage for javax.sound.midi MidiDevice getMaxReceivers

List of usage examples for javax.sound.midi MidiDevice getMaxReceivers

Introduction

In this page you can find the example usage for javax.sound.midi MidiDevice getMaxReceivers.

Prototype

int getMaxReceivers();

Source Link

Document

Obtains the maximum number of MIDI IN connections available on this MIDI device for receiving MIDI data.

Usage

From source file:org.monome.pages.configuration.Configuration.java

/**
 * Enables or disables a MIDI output device
 * /*from   w  w  w . j  a  v  a 2s . c om*/
 * @param sMidiDevice The MIDI output device to enable or disable
 */
public void actionAddMidiOutput(String sMidiDevice) {
    Info[] midiInfo = MidiSystem.getMidiDeviceInfo();
    MidiDevice midiDevice;

    for (int i = 0; i < midiInfo.length; i++) {
        try {
            midiDevice = MidiSystem.getMidiDevice(midiInfo[i]);
            if (sMidiDevice.compareTo(midiDevice.getDeviceInfo().toString()) == 0) {
                if (midiDevice.getMaxReceivers() != 0) {
                    MidiDeviceFactory.toggleMidiOutDevice(midiDevice);
                }
            }
        } catch (MidiUnavailableException e) {
            e.printStackTrace();
        }
    }
}