]> ruin.nu Git - moosique.git/commitdiff
Implemented some obvious methods.
authorEinar Pehrson <einarp@itstud.chalmers.se>
Sun, 13 Apr 2003 21:55:38 +0000 (21:55 +0000)
committerEinar Pehrson <einarp@itstud.chalmers.se>
Sun, 13 Apr 2003 21:55:38 +0000 (21:55 +0000)
MooNote.java
MooSequence.java
MooTrack.java
Moosique.java

index 826b4c3c16ba00326eb9e0ebe5c6e8ed908280d9..fcf32e047c8af6d1819937c914cd57a7bd82f498 100644 (file)
@@ -20,8 +20,8 @@ public class MooNote {
                // MidiEvent(MidiMessage message, long tick)
                noteOnMsg = new ShortMessage();
                noteOffMsg = new ShortMessage();
-               noteOnMsg.setMessage(ShortMessage.NOTE_ON, top.getChannel(), pitch, velocity);
-               noteOffMsg.setMessage(ShortMessage.NOTE_OFF, top.getChannel(), pitch, velocity);
+               noteOnMsg.setMessage(ShortMessage.NOTE_ON, pitch, velocity);
+               noteOffMsg.setMessage(ShortMessage.NOTE_OFF, pitch, velocity);
 //             noteOnTime = ???;
                noteOffTime = noteOnTime + length;
                noteOnEvent = new MidiEvent(noteOnMsg, noteOnTime)
@@ -33,7 +33,8 @@ public class MooNote {
         + @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());
        }
 
        /* 
@@ -41,7 +42,8 @@ public class MooNote {
         + @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);
        }
 
        /* 
@@ -49,7 +51,7 @@ public class MooNote {
         + @param n     the length of the note in ticks (100 per beat)
         */
        public void setLength(int ticks) {
-       
+               
        }
 
        /* 
@@ -57,7 +59,7 @@ public class MooNote {
         * @return      the note on MidiEvent
         */
        public MidiEvent getNoteOnEvent() {
-       
+               return noteOnEvent;
        }
 
        /* 
@@ -65,7 +67,7 @@ public class MooNote {
         * @return      the note off MidiEvent
         */
        public MidiEvent getNoteOffEvent() {
-       
+               return noteOffEvent;
        }
 
        /* 
@@ -73,7 +75,7 @@ public class MooNote {
         * @return the pitch of the note
         */
        public int getPitch() {
-       
+               return noteOnMsg.getData1();
        }
 
        /* 
@@ -81,7 +83,7 @@ public class MooNote {
         * @return the velocity of the note
         */
        public int getVelocity() {
-       
+               return noteOnMsg.getData2();
        }
 
        /* 
index b37424e244022317a2e8a16b166f3bce256e3ac1..2390c4a01da6d8d28f6b7c0084a678fa64f4b3fc 100644 (file)
@@ -1,4 +1,5 @@
 import javax.sound.midi.*;
+import java.util.*;
 
 /*
  * Functional representation of a MIDI sequence.
@@ -9,13 +10,14 @@ import javax.sound.midi.*;
  
 public class MooSequence {
 
-       private Collection tracks;
+       private ArrayList tracks;
 
        /* 
         * Creates a MooSequence with three tracks.
         */
        public MooSequence () {
-
+               tracks = new ArrayList();
+               addTrack(0);
        }
 
        /* 
@@ -24,7 +26,7 @@ public class MooSequence {
         * @return the specified track
         */
        public MooTrack getTrack(int track) {
-       
+               return tracks.get(track);
        }
 
        /* 
@@ -32,7 +34,7 @@ public class MooSequence {
         * @return the number of the tracks
         */
        public int getNumberOfTracks() {
-       
+               return tracks.size();
        }
 
        /* 
@@ -40,7 +42,7 @@ public class MooSequence {
         * @param track         the number of the track (0-31)
         */
        public void addTrack(int track) {
-       
+               tracks.add(track, new MooTrack());
        }
 
        /* 
@@ -48,7 +50,7 @@ public class MooSequence {
         * @param track         the number of the track (0-31)
         */
        public void deleteTrack(int track) {
-       
+               tracks.remove(track);
        }
 
        /* 
@@ -63,6 +65,9 @@ public class MooSequence {
         * Resets the solo and mute settings of all tracks.
         */
        public void activateTracks() {
-       
+               for (int i = 0; i++; i < tracks.size())
+                       tracks[i].setSolo(false);
+                       tracks[i].setMute(false);
+               }
        }
 }
\ No newline at end of file
index df542a6993467cf00d19ed955c1ddd0849139469..b14bcca97de709b8491b0368f11c67108572b41f 100644 (file)
@@ -19,7 +19,9 @@ public class MooTrack {
         * Creates an empty MooTrack.
         */
        public MooTrack () {
-
+               notes = new Collection();
+               setInstrument(0);
+               // Find the first available channel
        }
 
        /* 
@@ -27,7 +29,7 @@ public class MooTrack {
         * @param instr         the number of the MIDI instrument (0-127)
         */
        public void setInstrument(int instr) {
-       
+               instrument = instr;     
        }
 
        /* 
@@ -35,7 +37,7 @@ public class MooTrack {
         * @param chan          the number of the MIDI channel (1-16)
         */
        public void setChannel(int chan) {
-       
+               channel = chan;
        }
 
        /* 
@@ -43,7 +45,7 @@ public class MooTrack {
         * @return      the number of the channel
         */
        public int getChannel() {
-       
+               return channel;
        }
 
        /* 
@@ -51,7 +53,7 @@ public class MooTrack {
         * @return      the number of notes
         */
        public int getNumberOfNotes() {
-       
+               return notes.size();
        }
 
        /* 
@@ -59,7 +61,7 @@ public class MooTrack {
         * @param note          the MooNote to add
         */
        public void addNote(MooNote note) {
-       
+               notes.add(note);
        }
 
        /* 
@@ -75,23 +77,23 @@ public class MooTrack {
         * @param note          the index of the note
         */
        public MooNote getNote(int note) {
-       
+               return notes.get(note);
        }
 
        /* 
         * Makes the current track solo.
         * @param set   if the track should be solo
         */
-       public void solo(boolean set) {
-       
+       public void setSolo(boolean set) {
+               solo = set;
        }
 
        /* 
         * Mutes the current track.
         * @param set   if the track should be muted
         */
-       public void mute(boolean set) {
-       
+       public void setMute(boolean set) {
+               mute = set;     
        }
 
        /* 
@@ -100,7 +102,7 @@ public class MooTrack {
         */
 
        public boolean isSolo() {
-       
+               return solo;
        }
 
        /* 
@@ -108,6 +110,6 @@ public class MooTrack {
         * @return if the track is muted
         */
        public boolean isMute() {
-       
+               return mute;
        }
 }
\ No newline at end of file
index 8edc142920d3fba77e4f8ecc199d7b5ca736a955..42c5e2e03fea09b18c15c566d3fa044502107d01 100644 (file)
@@ -1,5 +1,6 @@
 import javax.sound.midi.*;
 import java.io.*;
+// Import external MIDIFileReader and MIDIFileWriter
 
 /*
  * Moosique - The MIDI Tracker
@@ -17,6 +18,7 @@ public class Moosique {
        private static Sequence seq;
        private static Sequencer sequencer = null;
        private static String filename;
+       private static int position;
 
        /* 
         * Starts the application.