Java Code Examples for javax.sound.midi.ShortMessage#PITCH_BEND

The following examples show how to use javax.sound.midi.ShortMessage#PITCH_BEND . 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: MidiReceiverImpl.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseMessage(MidiMessage message) throws MidiPlayerException{
	byte[] data = message.getMessage();
	if( data.length > 0 ){
		//NOTE ON
		if(((data[0] & 0xFF) & 0xF0) == ShortMessage.NOTE_ON){
			parseNoteOn(data, findChannel(message), findVoice(message), findBendMode(message));
		}
		//NOTE OFF
		else if(((data[0] & 0xFF) & 0xF0) == ShortMessage.NOTE_OFF){
			parseNoteOff(data, findChannel(message), findVoice(message), findBendMode(message));
		}
		//PITCH BEND
		else if(((data[0] & 0xFF) & 0xF0) == ShortMessage.PITCH_BEND){
			parsePitchBend(data, findChannel(message), findVoice(message), findBendMode(message));
		}
		//PROGRAM CHANGE
		else if(((data[0] & 0xFF) & 0xF0) == ShortMessage.PROGRAM_CHANGE){
			parseProgramChange(data, findChannel(message));
		}
		//CONTROL CHANGE
		else if(((data[0] & 0xFF) & 0xF0) == ShortMessage.CONTROL_CHANGE){
			parseControlChange(data, findChannel(message));
		}
	}
}
 
Example 2
Source File: SoftMainMixer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 3
Source File: SoftMainMixer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 4
Source File: SoftMainMixer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 5
Source File: SoftMainMixer.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 6
Source File: SoftMainMixer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 7
Source File: SoftMainMixer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 8
Source File: SoftMainMixer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 9
Source File: SoftMainMixer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 10
Source File: SoftMainMixer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 11
Source File: SoftMainMixer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 12
Source File: SoftMainMixer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 13
Source File: SoftMainMixer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 14
Source File: SoftMainMixer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 15
Source File: SoftMainMixer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 16
Source File: SoftMainMixer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void processMessage(int ch, int cmd, int data1, int data2) {
    synchronized (synth.control_mutex) {
        activity();
    }

    if (cmd == 0xF0) {
        int status = cmd | ch;
        switch (status) {
        case ShortMessage.ACTIVE_SENSING:
            synchronized (synth.control_mutex) {
                active_sensing_on = true;
            }
            break;
        default:
            break;
        }
        return;
    }

    SoftChannel[] channels = synth.channels;
    if (ch >= channels.length)
        return;
    SoftChannel softchannel = channels[ch];

    switch (cmd) {
    case ShortMessage.NOTE_ON:
        if(delay_midievent != 0)
            softchannel.noteOn(data1, data2, delay_midievent);
        else
            softchannel.noteOn(data1, data2);
        break;
    case ShortMessage.NOTE_OFF:
        softchannel.noteOff(data1, data2);
        break;
    case ShortMessage.POLY_PRESSURE:
        softchannel.setPolyPressure(data1, data2);
        break;
    case ShortMessage.CONTROL_CHANGE:
        softchannel.controlChange(data1, data2);
        break;
    case ShortMessage.PROGRAM_CHANGE:
        softchannel.programChange(data1);
        break;
    case ShortMessage.CHANNEL_PRESSURE:
        softchannel.setChannelPressure(data1);
        break;
    case ShortMessage.PITCH_BEND:
        softchannel.setPitchBend(data1 + data2 * 128);
        break;
    default:
        break;
    }

}
 
Example 17
Source File: IOLoop.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
private static boolean testMessage(MidiMessage message) {
    receivedMessage = null;
    baos = new ByteArrayOutputStream();
    expectedBytes = message.getLength();
    receivedBytes = 0;
    System.out.print("Sending message " + getMessageString(message.getMessage())+"...");
    receiver.send(message, -1);
    /* sending 3 bytes can roughly be done in 1 millisecond,
     * so this estimate waits at max 3 times longer than the message takes,
     * plus a little offset to allow the MIDI subsystem some processing time
     */
    int offset = 300; // standard offset 100 millis
    if (message instanceof SysexMessage) {
        // add a little processing time to sysex messages
        offset += 1000;
    }
    if (receivedBytes < expectedBytes) {
        sleep(expectedBytes + offset);
    }
    boolean equal;
    byte[] data = baos.toByteArray();
    if (data.length > 0) {
        equal = messagesEqual(message.getMessage(), data);
    } else {
        equal = messagesEqual(message, receivedMessage);
        if (receivedMessage != null) {
            data = receivedMessage.getMessage();
        } else {
            data = null;
        }
    }
    if (!equal) {
        if ((message.getStatus() & 0xF0) == ShortMessage.PITCH_BEND) {
            out("NOT failed (may expose a bug in ALSA)");
            equal = true;
            sleep(100);
        }
        if ((message.getStatus() == 0xF6) && (message.getLength() == 1)) {
            out("NOT failed (may expose an issue on Solaris)");
            equal = true;
            sleep(100);
        }
        else if ((message.getStatus()) == 0xF0 && message.getLength() < 4) {
            out("NOT failed (not a correct sys ex message)");
            equal = true;
            sleep(200);
        } else {
            out("FAILED:");
            out("  received as " + getMessageString(data));
        }
    } else {
        System.out.println("OK");
    }
    return equal;
}