Example usage for javax.sound.midi Transmitter close

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

Introduction

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

Prototype

@Override
void close();

Source Link

Document

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

Usage

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

/**
 * @see java.applet.Applet#stop()/*w  w  w  .  j a v a  2  s  .c o m*/
 */
@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) + ")");
}

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

/**
 * Releases the specifeid transmitter handle.
 *
 * @param transmitterHandle//from   www. j a  va 2 s .c  o  m
 *            The transmitter handle to release.
 */
public void closeTransmitter(final int transmitterHandle) {
    final Transmitter transmitter = resolveTransmitterHandle(transmitterHandle);
    transmitter.close();
    this.transmitterMap.remove(transmitterHandle);
}

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

/**
 * Enables a MIDI in device to receive MIDI clock.
 * //from   w w  w  .j  av  a 2  s  .  c om
 * @param midiInDevice The MIDI input device to enable
 */
public void toggleMidiInDevice(MidiDevice midiInDevice) {
    // close the currently open device if we have one
    for (int i = 0; i < this.midiInDevices.size(); i++) {
        if (this.midiInDevices.get(i).equals(midiInDevice)) {
            MidiDevice inDevice = this.midiInDevices.get(i);
            System.out
                    .println("closing midi in device " + i + " / " + this.midiInDevices.get(i).getDeviceInfo());
            Transmitter transmitter = this.midiInTransmitters.get(i);
            this.midiInTransmitters.remove(i);
            this.midiInDevices.remove(i);
            transmitter.close();
            inDevice.close();
            return;
        }
    }

    // try to open the new midi in device
    try {
        midiInDevice.open();
        Transmitter transmitter = midiInDevice.getTransmitter();
        transmitter.setReceiver(this);
        this.midiInDevices.add(midiInDevice);
        this.midiInTransmitters.add(transmitter);
    } catch (MidiUnavailableException e) {
        e.printStackTrace();
    }
}