]> ruin.nu Git - moosique.git/blobdiff - MooSequence.java
removed exportMIDI method; added quit, getPosition, setPosition and resume
[moosique.git] / MooSequence.java
index 62af2e32efefe201f98e9c3625d61fe2a5c72fd3..96753790fcc2d83ef7c834fb3a37863b5171f0e9 100644 (file)
@@ -1,68 +1,92 @@
 import javax.sound.midi.*;
+import java.util.*;
 
-/**
+/* UPDATES
+   Added MooSequence(Sequence seq) constructor.
+*/
+
+/*
  * Functional representation of a MIDI sequence.
- * blaha
+ *
  * @author  Andersson, Andreen, Lanneskog, Pehrson
- * @version 1.1
+ * @version 1
  */
  
 public class MooSequence {
 
-       private Collection tracks;
+       private ArrayList tracks;
 
-       /** 
-        * Creates a MooSequence with three tracks.
+       /* 
+        * Creates a MooSequence from the given Sequence.
         */
-       public MooSequence () {
+       public MooSequence(Sequence seq) {
+
+       }
 
+       /* 
+        * Creates a MooSequence with three tracks.
+        */
+       public MooSequence() {
+               tracks = new ArrayList();
+               addTrack(0);
        }
 
-       /** 
+       /* 
         * Returns a pointer to the specified track.
         * @param track         the number of the track (0-31)
         * @return the specified track
         */
        public MooTrack getTrack(int track) {
-       
+               return tracks.get(track);
        }
 
-       /** 
+       /* 
         * Returns the number of tracks in the current sequence.
         * @return the number of the tracks
         */
        public int getNumberOfTracks() {
-       
+               return tracks.size();
        }
 
-       /** 
+       /* 
         * Creates a new track after the specified track.
         * @param track         the number of the track (0-31)
         */
        public void addTrack(int track) {
-       
+               tracks.add(track, new MooTrack());
        }
 
-       /** 
+       /* 
         * Deletes the specified track.
         * @param track         the number of the track (0-31)
         */
        public void deleteTrack(int track) {
-       
+               tracks.remove(track);
        }
 
-       /** 
+       /* 
         * Returns the Java Sequence object of the current sequence.
         * @return a Sequence
         */
        public Sequence getSequence() {
-       
+               Sequence seq = new Sequence(Sequencer.PPQ, 96, tracks.size());
+               Track t;
+               for (int i = 0; i < tracks.size(); i++) {
+                       t = tracks.get(i);
+                       for (int j = 0; j < t.notes.size(); j++) {
+                               t.add(t.notes.get(j).getNoteOnEvent());
+                               t.add(t.notes.get(j).getNoteOffEvent());                        }
+                       }
+               }
        }
 
-       /** 
+       /* 
         * 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