X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooNote.java;h=2a82b6d21b5ac48489aa1a5548f49f96152bb21e;hb=refs%2Fheads%2Forigin;hp=57cf86c8529c9fef5ce0e59726b6c944f83ebc04;hpb=c31857b9fcb119f0d4c12b96222f66340b3dcc56;p=moosique.git diff --git a/MooNote.java b/MooNote.java index 57cf86c..2a82b6d 100644 --- a/MooNote.java +++ b/MooNote.java @@ -1,7 +1,7 @@ import javax.sound.midi.*; /** - * Functional representation of a MIDI note, which adds functionality to the existent MidiEvent class. + * Functional representation of a MIDI note, which adds functionality to the existing MidiEvent class. * Also provides a reference to the corresponding NoteOff event. * * @author Einar Pehrson @@ -40,7 +40,7 @@ public class MooNote extends MidiEvent implements Cloneable, Comparable { noteOffMsg = (ShortMessage)noteOffEvent.getMessage(); try { noteOnMsg.setMessage(ShortMessage.NOTE_ON, channel, pitch, velocity); - noteOffMsg.setMessage(ShortMessage.NOTE_OFF, channel, pitch, 0); + noteOffMsg.setMessage(ShortMessage.NOTE_OFF, channel, pitch, 64); } catch (InvalidMidiDataException e) {System.out.println("Invalid data!");} } @@ -175,6 +175,8 @@ public class MooNote extends MidiEvent implements Cloneable, Comparable { * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object */ public int compareTo(Object o) { - return (int)(getTick() - ((MidiEvent)o).getTick()); + int diff = (int)(getTick() - ((MidiEvent)o).getTick()); + if (diff != 0) return diff; + return (noteOnMsg.getData1() - ((ShortMessage)((MidiEvent)o).getMessage()).getData1()); } }