Example usage for javax.sound.midi ShortMessage PITCH_BEND

List of usage examples for javax.sound.midi ShortMessage PITCH_BEND

Introduction

In this page you can find the example usage for javax.sound.midi ShortMessage PITCH_BEND.

Prototype

int PITCH_BEND

To view the source code for javax.sound.midi ShortMessage PITCH_BEND.

Click Source Link

Document

Command value for Pitch Bend message (0xE0, or 224).

Usage

From source file:com.rockhoppertech.music.midi.js.MIDIEvent.java

public String toReadableString() {
    StringBuilder sb = new StringBuilder();

    // switch(se.getType()) {
    // case MidiEvent.CHANNEL_VOICE_MESSAGE:

    switch (status & 0xF0) {
    case ShortMessage.NOTE_OFF:
        sb.append("Note Off Key=").append(bytes[0]).append(" Velocity=").append(bytes[1]);
        break;//  w w w.jav a 2s  . c  o  m

    case ShortMessage.NOTE_ON:
        sb.append("Note On Key=").append(bytes[0]).append(" Velocity=").append(bytes[1]);
        break;

    case ShortMessage.POLY_PRESSURE:
        sb.append("Polyphonic key pressure key=").append(bytes[0]).append(" pressure=").append(bytes[1]);
        break;

    case ShortMessage.CONTROL_CHANGE:
        sb.append("Control Change controller=").append(bytes[0]).append(" value=").append(bytes[1]);
        sb.append(" ").append(MIDIControllers.getControllerName((int) bytes[0]));

        break;

    case ShortMessage.PROGRAM_CHANGE:
        sb.append("Program Change program=").append(bytes[0]).append(" name=")
                .append(MIDIGMPatch.getName(bytes[0]));
        break;

    case ShortMessage.CHANNEL_PRESSURE:
        sb.append("Channel Pressure pressure=").append(bytes[0]);
        break;

    case ShortMessage.PITCH_BEND:
        // int val = (this.bytes[0] & 0x7f) | ((this.bytes[1] & 0x7f) << 7);
        // short centered = 0x2000;
        short s14bit;
        s14bit = bytes[1];
        s14bit <<= 7;
        s14bit |= bytes[0];

        sb.append("Pitch Bend one=").append(bytes[0]).append(" two=").append(bytes[1]);
        sb.append(" val=").append(s14bit);
        break;
    default:
        sb.append(" Unhandled=").append(status & 0xF0);
        break;
    }
    sb.append(" Channel=").append(status & 0x0F);
    sb.append(" status=").append(Integer.toHexString(status));

    /*
     * case MidiEvent.CHANNEL_MODE_MESSAGE: printChannelModeMessage(se);
     * break;
     * 
     * case MidiEvent.SYSTEM_COMMON_MESSAGE : System.out.print(" system
     * common message "); break;
     * 
     * case MidiEvent.SYSTEM_REALTIME_MESSAGE : System.out.print(" system
     * realtime message "); break;
     * 
     * default: strMessage = "unknown event: status = " + se.getStatus() +
     * ", byte1 = " + this.bytes[0] + ", byte2 = " + this.bytes[1];
     */
    // System.out.print(sw.toString());
    return sb.toString();

}