Example usage for javax.sound.midi Receiver close

List of usage examples for javax.sound.midi Receiver close

Introduction

In this page you can find the example usage for javax.sound.midi Receiver close.

Prototype

@Override
void close();

Source Link

Document

Indicates that the application has finished using the receiver, and that limited resources it requires may be released or made available.

Usage

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

/**
 * Releases the specifeid receiver handle.
 *
 * @param receiverHandle/*from  w w w . ja  v a 2  s .c  o  m*/
 *            The receiver handle to release.
 */
public void closeReceiver(final int receiverHandle) {
    final Receiver receiver = resolveReceiverHandle(receiverHandle);
    receiver.close();
    this.receiverMap.remove(receiverHandle);
}

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

/**
 * @see java.applet.Applet#stop()//from w w  w. j  a va2s .com
 */
@Override
public void stop() {
    for (final Receiver receiver : this.receiverMap.values())
        receiver.close();
    for (final Transmitter transmitter : this.transmitterMap.values())
        transmitter.close();
    for (final MidiDevice device : this.deviceMap.values())
        if (device.isOpen())
            device.close();
    this.deviceMap = null;
    this.receiverMap = null;
    this.transmitterMap = null;
    System.out.println("Stopped midi4js applet (Instance #" + System.identityHashCode(this) + ")");
}