Cast the MidiMessage
down to ShortMessage
and then you can get the pitch and velocity as data1 and data2:
if (message instanceof ShortMessage) {
ShortMessage shortMessage = (ShortMessage) message;
if(shortMessage.getCommand() == ShortMessage.NOTE_ON) {
int channel = shortMessage.getChannel();
int pitch = shortMessage.getData1();
int vel = shortMessage.getData2();
if(vel > 0) {
shortMessage.setMessage(ShortMessage.NOTE_ON, channel, pitch + pitchUpOrDown, vel);
}
}
}
You might need to change the next NOTE_OFF message as well. This will either be a shortMessage with a NOTE_OFF command, or a NOTE_ON command with a velocity of 0.