]> ruin.nu Git - moosique.git/blob - MooSequence.java
removed exportMIDI method; added quit, getPosition, setPosition and resume
[moosique.git] / MooSequence.java
1 import javax.sound.midi.*;
2 import java.util.*;
3
4 /* UPDATES
5    Added MooSequence(Sequence seq) constructor.
6 */
7
8 /*
9  * Functional representation of a MIDI sequence.
10  *
11  * @author  Andersson, Andreen, Lanneskog, Pehrson
12  * @version 1
13  */
14  
15 public class MooSequence {
16
17         private ArrayList tracks;
18
19         /* 
20          * Creates a MooSequence from the given Sequence.
21          */
22         public MooSequence(Sequence seq) {
23
24         }
25
26         /* 
27          * Creates a MooSequence with three tracks.
28          */
29         public MooSequence() {
30                 tracks = new ArrayList();
31                 addTrack(0);
32         }
33
34         /* 
35          * Returns a pointer to the specified track.
36          * @param track         the number of the track (0-31)
37          * @return the specified track
38          */
39         public MooTrack getTrack(int track) {
40                 return tracks.get(track);
41         }
42
43         /* 
44          * Returns the number of tracks in the current sequence.
45          * @return the number of the tracks
46          */
47         public int getNumberOfTracks() {
48                 return tracks.size();
49         }
50
51         /* 
52          * Creates a new track after the specified track.
53          * @param track         the number of the track (0-31)
54          */
55         public void addTrack(int track) {
56                 tracks.add(track, new MooTrack());
57         }
58
59         /* 
60          * Deletes the specified track.
61          * @param track         the number of the track (0-31)
62          */
63         public void deleteTrack(int track) {
64                 tracks.remove(track);
65         }
66
67         /* 
68          * Returns the Java Sequence object of the current sequence.
69          * @return a Sequence
70          */
71         public Sequence getSequence() {
72                 Sequence seq = new Sequence(Sequencer.PPQ, 96, tracks.size());
73                 Track t;
74                 for (int i = 0; i < tracks.size(); i++) {
75                         t = tracks.get(i);
76                         for (int j = 0; j < t.notes.size(); j++) {
77                                 t.add(t.notes.get(j).getNoteOnEvent());
78                                 t.add(t.notes.get(j).getNoteOffEvent());                        }
79                         }
80                 }
81         }
82
83         /* 
84          * Resets the solo and mute settings of all tracks.
85          */
86         public void activateTracks() {
87                 for (int i = 0; i++; i < tracks.size())
88                         tracks[i].setSolo(false);
89                         tracks[i].setMute(false);
90                 }
91         }
92 }