Example usage for javax.sound.midi MidiDevice getReceivers

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

Introduction

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

Prototype

List<Receiver> getReceivers();

Source Link

Document

Returns all currently active, non-closed receivers connected with this MidiDevice .

Usage

From source file:de.ailis.midi4js.Midi4JS.java

/**
 * Returns all currently open receivers.
 *
 * @param deviceHandle/* w ww  . j a  v a2 s . c om*/
 *            The device handle.
 * @return All currently open receivers in form of a JSON-encoded string
 *         which describes an array of receiver handles.
 * @throws JSONException
 *             When JSON data could not be constructed.
 */
public String getReceivers(final int deviceHandle) throws JSONException {
    final MidiDevice device = resolveDeviceHandle(deviceHandle);
    final JSONStringer json = new JSONStringer();
    json.array();
    for (final Receiver receiver : device.getReceivers()) {
        json.value(System.identityHashCode(receiver));
    }
    json.endArray();
    return json.toString();
}