]> ruin.nu Git - moosique.git/blob - MooTrack.java
removed exportMIDI method; added quit, getPosition, setPosition and resume
[moosique.git] / MooTrack.java
1 import javax.sound.midi.*;
2
3 /*
4  * Functional representation of a MIDI track.
5  * 
6  * @author  Andersson, Andreen, Lanneskog, Pehrson
7  * @version 1
8  */
9  
10 public class MooTrack {
11
12         private Collection notes;
13         private int channel;
14         private int instrument;
15         private boolean solo = false;
16         private boolean mute = false;
17
18         /* 
19          * Creates an empty MooTrack.
20          */
21         public MooTrack () {
22                 notes = new Collection();
23                 setInstrument(0);
24                 // Find the first available channel
25         }
26
27         /* 
28          * Sets the MIDI instrument of the current track.
29          * @param instr         the number of the MIDI instrument (0-127)
30          */
31         public void setInstrument(int instr) {
32                 instrument = instr;     
33         }
34
35         /* 
36          * Sets the MIDI channel of the current track.
37          * @param chan          the number of the MIDI channel (1-16)
38          */
39         public void setChannel(int chan) {
40                 channel = chan;
41         }
42
43         /* 
44          * Returns the MIDI channel of the current track.
45          * @return      the number of the channel
46          */
47         public int getChannel() {
48                 return channel;
49         }
50
51         /* 
52          * Returns the number of notes in the current track.
53          * @return      the number of notes
54          */
55         public int getNumberOfNotes() {
56                 return notes.size();
57         }
58
59         /* 
60          * Adds the given note to the current track.
61          * @param note          the MooNote to add
62          */
63         public void addNote(MooNote note) {
64                 notes.add(note);
65         }
66
67         /* 
68          * Deletes the given note from the current track.
69          * @param note          the MooNote to delete
70          */
71         public void deleteNote(MooNote note) {
72                 notes.remove(note);
73         }
74
75         /* 
76          * Returns the note of the given index.
77          * @param note          the index of the note
78          */
79         public MooNote getNote(int note) {
80                 return notes.get(note);
81         }
82
83         /* 
84          * Makes the current track solo.
85          * @param set   if the track should be solo
86          */
87         public void setSolo(boolean set) {
88                 solo = set;
89         }
90
91         /* 
92          * Mutes the current track.
93          * @param set   if the track should be muted
94          */
95         public void setMute(boolean set) {
96                 mute = set;     
97         }
98
99         /* 
100          * Checks if the current track is solo.
101          * @return if the track is solo
102          */
103
104         public boolean isSolo() {
105                 return solo;
106         }
107
108         /* 
109          * Checks if the current track is muted.
110          * @return if the track is muted
111          */
112         public boolean isMute() {
113                 return mute;
114         }
115 }