]> ruin.nu Git - moosique.git/blobdiff - MooNote.java
Implemented some obvious methods.
[moosique.git] / MooNote.java
index edd815900705e538aafb1c68dcceb887ed4ac332..fcf32e047c8af6d1819937c914cd57a7bd82f498 100644 (file)
@@ -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,88 @@ 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) {
-
+               // MidiEvent(MidiMessage message, long tick)
+               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)
         */
        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