1 import javax.sound.midi.*;
5 Added MooSequence(Sequence seq) constructor.
9 * Functional representation of a MIDI sequence.
11 * @author Andersson, Andreen, Lanneskog, Pehrson
15 public class MooSequence {
17 private ArrayList tracks;
20 * Creates a MooSequence from the given Sequence.
22 public MooSequence(Sequence seq) {
27 * Creates a MooSequence with three tracks.
29 public MooSequence() {
30 tracks = new ArrayList();
35 * Returns a pointer to the specified track.
36 * @param track the number of the track (0-31)
37 * @return the specified track
39 public MooTrack getTrack(int track) {
40 return tracks.get(track);
44 * Returns the number of tracks in the current sequence.
45 * @return the number of the tracks
47 public int getNumberOfTracks() {
52 * Creates a new track after the specified track.
53 * @param track the number of the track (0-31)
55 public void addTrack(int track) {
56 tracks.add(track, new MooTrack());
60 * Deletes the specified track.
61 * @param track the number of the track (0-31)
63 public void deleteTrack(int track) {
68 * Returns the Java Sequence object of the current sequence.
71 public Sequence getSequence() {
72 Sequence seq = new Sequence(Sequencer.PPQ, 96, tracks.size());
74 for (int i = 0; i < tracks.size(); 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()); }
84 * Resets the solo and mute settings of all tracks.
86 public void activateTracks() {
87 for (int i = 0; i++; i < tracks.size())
88 tracks[i].setSolo(false);
89 tracks[i].setMute(false);