javax.sound.midi.ControllerEventListener Java Examples

The following examples show how to use javax.sound.midi.ControllerEventListener. 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: RealTimeSequencer.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers) {
    synchronized(controllerEventListeners) {
        ControllerListElement cve = null;
        boolean flag = false;
        for (int i=0; i < controllerEventListeners.size(); i++) {
            cve = controllerEventListeners.get(i);
            if (cve.listener.equals(listener)) {
                cve.removeControllers(controllers);
                flag = true;
                break;
            }
        }
        if (!flag) {
            return new int[0];
        }
        if (controllers == null) {
            int index = controllerEventListeners.indexOf(cve);
            if (index >= 0) {
                controllerEventListeners.remove(index);
            }
            return new int[0];
        }
        return cve.getControllers();
    }
}
 
Example #2
Source File: RealTimeSequencer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers) {
    synchronized(controllerEventListeners) {
        ControllerListElement cve = null;
        boolean flag = false;
        for (int i=0; i < controllerEventListeners.size(); i++) {
            cve = controllerEventListeners.get(i);
            if (cve.listener.equals(listener)) {
                cve.removeControllers(controllers);
                flag = true;
                break;
            }
        }
        if (!flag) {
            return new int[0];
        }
        if (controllers == null) {
            int index = controllerEventListeners.indexOf(cve);
            if (index >= 0) {
                controllerEventListeners.remove(index);
            }
            return new int[0];
        }
        return cve.getControllers();
    }
}
 
Example #3
Source File: RealTimeSequencer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers) {
    synchronized(controllerEventListeners) {

        // first find the listener.  if we have one, add the controllers
        // if not, create a new element for it.
        ControllerListElement cve = null;
        boolean flag = false;
        for(int i=0; i < controllerEventListeners.size(); i++) {

            cve = controllerEventListeners.get(i);

            if (cve.listener.equals(listener)) {
                cve.addControllers(controllers);
                flag = true;
                break;
            }
        }
        if (!flag) {
            cve = new ControllerListElement(listener, controllers);
            controllerEventListeners.add(cve);
        }

        // and return all the controllers this listener is interested in
        return cve.getControllers();
    }
}
 
Example #4
Source File: RealTimeSequencer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private ControllerListElement(ControllerEventListener listener, int[] controllers) {

            this.listener = listener;
            if (controllers == null) {
                controllers = new int[128];
                for (int i = 0; i < 128; i++) {
                    controllers[i] = i;
                }
            }
            this.controllers = controllers;
        }
 
Example #5
Source File: RealTimeSequencer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers) {
    synchronized(controllerEventListeners) {

        // first find the listener.  if we have one, add the controllers
        // if not, create a new element for it.
        ControllerListElement cve = null;
        boolean flag = false;
        for(int i=0; i < controllerEventListeners.size(); i++) {

            cve = controllerEventListeners.get(i);

            if (cve.listener.equals(listener)) {
                cve.addControllers(controllers);
                flag = true;
                break;
            }
        }
        if (!flag) {
            cve = new ControllerListElement(listener, controllers);
            controllerEventListeners.add(cve);
        }

        // and return all the controllers this listener is interested in
        return cve.getControllers();
    }
}
 
Example #6
Source File: RealTimeSequencer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private ControllerListElement(ControllerEventListener listener, int[] controllers) {

            this.listener = listener;
            if (controllers == null) {
                controllers = new int[128];
                for (int i = 0; i < 128; i++) {
                    controllers[i] = i;
                }
            }
            this.controllers = controllers;
        }