Code example for ShortMessage

Methods: getChannelgetCommandgetData1getData2

0
     * @param message The message to parse 
     * @param timestamp the time at which the message was encountered in this track 
     */ 
    private void parseShortMessage(ShortMessage message, long timestamp)
    { 
        int track = message.getChannel();
         
        switch (message.getCommand())
        { 
            case ShortMessage.PROGRAM_CHANGE :                  // 0xC0, 192
                trace("Program change to ",message.getData1());
                Instrument instrument = new Instrument((byte)message.getData1());
                fireTimeEvent(new Time(timestamp));
                fireVoiceEvent(new Voice((byte)track));
                fireInstrumentEvent(instrument);
                break; 
                 
            case ShortMessage.CONTROL_CHANGE :                  // 0xB0, 176
                trace("Controller change to ",message.getData1(),", value = ",message.getData2());                                    
                Controller controller = new Controller((byte)message.getData1(), (byte)message.getData2());
                fireTimeEvent(new Time(timestamp));
                fireVoiceEvent(new Voice((byte)track));
                fireControllerEvent(controller);
                break; 
            case ShortMessage.NOTE_ON :                         // 0x90, 144
                if (message.getData2() == 0) {
                    // A velocity of zero in a note-on event is a note-off event 
                    noteOffEvent(timestamp, track, message.getData1(), message.getData2());
                } else { 
                    noteOnEvent(timestamp, track, message.getData1(), message.getData2());
                } 
                break; 
            case ShortMessage.NOTE_OFF :                        // 0x80, 128
                noteOffEvent(timestamp, track, message.getData1(), message.getData2());
                break; 
            case ShortMessage.CHANNEL_PRESSURE :                // 0xD0, 208
                trace("Channel pressure, pressure = ",message.getData1());                                    
                ChannelPressure pressure = new ChannelPressure((byte)message.getData1());
                fireTimeEvent(new Time(timestamp));
                fireVoiceEvent(new Voice((byte)track));
                fireChannelPressureEvent(pressure);
                break; 
            case ShortMessage.POLY_PRESSURE :                   // 0xA0, 128
                trace("Poly pressure on key ",message.getData1(),", pressure = ",message.getData2());                                    
                PolyphonicPressure poly = new PolyphonicPressure((byte)message.getData1(), (byte)message.getData2());
                fireTimeEvent(new Time(timestamp));
                fireVoiceEvent(new Voice((byte)track));
                firePolyphonicPressureEvent(poly);
                break; 
            case ShortMessage.PITCH_BEND :                      // 0xE0, 224
                trace("Pitch Bend, data1= ",message.getData1(),", data2= ",message.getData2());                                    
                PitchBend bend = new PitchBend((byte)message.getData1(), (byte)message.getData2());
                fireTimeEvent(new Time(timestamp));
                fireVoiceEvent(new Voice((byte)track));
                firePitchBendEvent(bend);
                break; 
            default :  
                trace("Unparsed message: ",message.getCommand());
                break; 
        } 
    } 
 
    private void noteOnEvent(long timestamp, int track, int data1, int data2)
Contextual code suggestions in your IDE  Get Codota for Java