X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooNote.java;h=d57772b92be50251ce9a06bb2456344cff570772;hb=2f2b387add66ddc0d8f8c1e301f4718792e969b6;hp=edd815900705e538aafb1c68dcceb887ed4ac332;hpb=1e06fcb34d222ef2017d4adf888568184dd63ab9;p=moosique.git diff --git a/MooNote.java b/MooNote.java index edd8159..d57772b 100644 --- a/MooNote.java +++ b/MooNote.java @@ -1,6 +1,6 @@ import javax.sound.midi.*; -/** +/* * Functional representation of a MIDI note, which contains two MIDI events, note on and note off. * * @author Andersson, Andreen, Lanneskog, Pehrson @@ -9,76 +9,87 @@ import javax.sound.midi.*; public class MooNote { - private MidiEvent noteOn, noteOff; + private MidiEvent noteOnEvent, noteOffEvent; + private ShortMessage noteOnMsg, noteOffMsg; + private long noteOnTime, noteOffTime; - /** + /* * Creates a MooNote of the given pitch, velocity and length in the current track. */ public MooNote (int pitch, int velocity, int length) { - + noteOnMsg = new ShortMessage(); + noteOffMsg = new ShortMessage(); + noteOnMsg.setMessage(ShortMessage.NOTE_ON, pitch, velocity); + noteOffMsg.setMessage(ShortMessage.NOTE_OFF, pitch, velocity); +// noteOnTime = ???; + noteOffTime = noteOnTime + length; + noteOnEvent = new MidiEvent(noteOnMsg, noteOnTime); + noteOffEvent = new MidiEvent(noteOffMsg, noteOffTime); } - /** + /* * Sets the pitch of the current note. - + @param pitch the pitch of the note (0-127) + * @param pitch the pitch of the note (0-127) */ public void setPitch(int pitch) { - + noteOnMsg.setMessage(ShortMessage.NOTE_ON, pitch, noteOnMsg.getData2()); + noteOffMsg.setMessage(ShortMessage.NOTE_OFF, pitch, noteOffMsg.getData2()); } - /** + /* * Sets the velocity of the current note. + @param vel the velocity of the note (0-127) */ public void setVelocity(int vel) { - + noteOnMsg.setMessage(ShortMessage.NOTE_ON, noteOnMsg.getData1(), vel); + noteOffMsg.setMessage(ShortMessage.NOTE_OFF, noteOffMsg.getData1(), vel); } - /** + /* * Sets the length of the current note (or rather moves the note off event). + @param n the length of the note in ticks (100 per beat) */ public void setLength(int ticks) { - + } - /** + /* * Returns the note on event of the current note. * @return the note on MidiEvent */ public MidiEvent getNoteOnEvent() { - + return noteOnEvent; } - /** + /* * Returns the note off event of the current note. * @return the note off MidiEvent */ public MidiEvent getNoteOffEvent() { - + return noteOffEvent; } - /** + /* * Returns the pitch of the current note. * @return the pitch of the note */ public int getPitch() { - + return noteOnMsg.getData1(); } - /** + /* * Returns the velocity of the current note. * @return the velocity of the note */ public int getVelocity() { - + return noteOnMsg.getData2(); } - /** + /* * Returns the length of the current note. * @return the length of the note */ public int getLength() { } -} +} \ No newline at end of file