X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooNote.java;h=6cb9f9e49d7051773ff44575df0a42074deb7479;hb=b5028dc9c03585cdf231a37d8996a7e836932c3e;hp=3e66dab1c4aa10bf2d23674bd84b1940b1502f6b;hpb=ffc69c8cc2cc9cdfe3841c77c1e680dee2225c63;p=moosique.git diff --git a/MooNote.java b/MooNote.java index 3e66dab..6cb9f9e 100644 --- a/MooNote.java +++ b/MooNote.java @@ -61,7 +61,7 @@ public class MooNote extends MidiEvent { public void setChannel(int channel) { try { noteOnMsg.setMessage(noteOnMsg.getCommand(), (byte)channel, noteOnMsg.getData1(), noteOnMsg.getData2()); - noteOffMsg.setMessage(noteOffMsg.getCommand(), (byte)channel, noteOffMsg.getData1(), noteOffMsg.getData2()); + if(hasNoteOffEvent()) noteOffMsg.setMessage(noteOffMsg.getCommand(), (byte)channel, noteOffMsg.getData1(), noteOffMsg.getData2()); } catch (InvalidMidiDataException e) {} } @@ -72,7 +72,7 @@ public class MooNote extends MidiEvent { public void setPitch(int pitch) { try { noteOnMsg.setMessage(noteOnMsg.getCommand(), noteOnMsg.getChannel(), (byte)pitch, noteOnMsg.getData2()); - noteOffMsg.setMessage(noteOffMsg.getCommand(), noteOffMsg.getChannel(), (byte)pitch, noteOffMsg.getData2()); + if(hasNoteOffEvent()) noteOffMsg.setMessage(noteOffMsg.getCommand(), noteOffMsg.getChannel(), (byte)pitch, noteOffMsg.getData2()); } catch (InvalidMidiDataException e) {} } @@ -83,7 +83,7 @@ public class MooNote extends MidiEvent { public void setVelocity(int vel) { try { noteOnMsg.setMessage(noteOnMsg.getCommand(), noteOnMsg.getChannel(), noteOnMsg.getData1(), (byte)vel); - noteOffMsg.setMessage(noteOffMsg.getCommand(), noteOffMsg.getChannel(), noteOffMsg.getData1(), noteOffMsg.getData2()); + if(hasNoteOffEvent()) noteOffMsg.setMessage(noteOffMsg.getCommand(), noteOffMsg.getChannel(), noteOffMsg.getData1(), noteOffMsg.getData2()); } catch (InvalidMidiDataException e) {} } @@ -134,7 +134,7 @@ public class MooNote extends MidiEvent { */ public int getDuration() { if (!hasNoteOffEvent()) return 0; - return (int)(getTick() - noteOffEvent.getTick()); + return (int)(noteOffEvent.getTick() - getTick()); } /** @@ -144,4 +144,4 @@ public class MooNote extends MidiEvent { public boolean hasNoteOffEvent() { return noteOffEvent != null; } -} \ No newline at end of file +}