try {
noteOnMsg.setMessage(ShortMessage.NOTE_ON, channel, pitch, velocity);
noteOffMsg.setMessage(ShortMessage.NOTE_OFF, channel, pitch, 0);
- } catch (InvalidMidiDataException e) {}
+ } catch (InvalidMidiDataException e) {System.out.println("Invalid data!");}
}
/**
} catch (InvalidMidiDataException e) {}
}
+ /**
+ * Transposes the current note the given number of halftones.
+ * @param halftones the number of halftones to transpose - positive for up, negative for down
+ */
+ public void transpose(int halftones) {
+ setPitch(getPitch() + halftones);
+ }
+
/**
* Sets the velocity of the current note.
* @param vel the velocity of the note (0-127)
* @param tick the timestamp of the note in ticks (96 per beat)
*/
public void setTick(long tick) {
- if (hasNoteOffEvent()) noteOffEvent.setTick(tick + getDuration());
+ if (hasNoteOffEvent()) noteOffEvent.setTick(tick + getDuration());
super.setTick(tick);
}