- noteOffMsg.setMessage(noteOffMsg.getCommand(), noteOffMsg.getChannel(), (byte)pitch, noteOffMsg.getData2());
- } catch (Exception e) {}
- //} catch (InvalidMidiDataException e) {}
+ if(hasNoteOffEvent()) noteOffMsg.setMessage(noteOffMsg.getCommand(), noteOffMsg.getChannel(), (byte)pitch, noteOffMsg.getData2());
+ } 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);