public class MooTrackTitle extends JPanel {
+ private Track track;
private MetaMessage trackNameMessage;
- private String trackName = "";
private ShortMessage programChangeMessage;
- private int channel = 0;
+
private JTextField title;
private MooInstrumentList instruments;
private JComboBox channelBox;
private JCheckBox mute;
private JCheckBox solo;
- private Track track;
- private int trackNum;
+
+ private String trackName = "";
+ private int channel = 0;
+
+ /**
+ * Creates the title bar for an empty track, and therefore an initial channel is required.
+ * @param aTrack the track that this tracktitle is operating on.
+ * @param chan the initial channel
+ */
+ public MooTrackTitle (Track aTrack, int chan) {
+ this(aTrack);
+ channel = chan;
+ }
/**
* Creates the title bar.
+ * @param aTrack the track that this tracktitle is operating on.
*/
- public MooTrackTitle (Track aTrack, int aTrackNum) {
+ public MooTrackTitle (Track aTrack) {
setDoubleBuffered(true);
track = aTrack;
- this.trackNum = aTrackNum;
// Finds track name, program change and channel.
MidiMessage msg;
}
}
-/* // Finds channel number.
- MidiEvent event;
- for (int i = 0; i < track.size(); i++) {
- event = track.get(i);
- if (event instanceof MooNote) {
- channel = ((MooNote)event).getChannel();
- break;
- }
- }
-*/
// Creates and places components.
setLayout(new GridLayout(4,1));
setBorder(BorderFactory.createLineBorder(Color.black));
title.addFocusListener(new TitleFocusListener());
add(title);
- instruments = new MooInstrumentList(channel);
- // instruments = new MooInstrumentList(channel, programChangeMessage);
+ int type;
+ if (channel == 9) type = MooInstrumentList.DRUMS;
+ else type = MooInstrumentList.INSTRUMENTS;
+ instruments = new MooInstrumentList(channel, type);
+ // instruments = new MooInstrumentList(channel, type, programChangeMessage);
add(instruments);
channelBox = new JComboBox();
channelBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
- int chan = channelBox.getSelectedIndex();
+ channel = channelBox.getSelectedIndex();
MidiEvent me;
MooNote mn;
- instruments.setChannel(channelBox.getSelectedIndex());
+ instruments.setChannel(channel);
for (int j = 0; j < track.size(); j++) {
me = track.get(j);
if (me instanceof MooNote){
mn = (MooNote)me;
- mn.setChannel(chan);
+ mn.setChannel(channel);
}
}}});
add(channelBox);
checkboxes.setLayout(new GridLayout(1,3));
mute = new JCheckBox("Mute");
- mute.setSelected(Moosique.getSequencer().getTrackMute(trackNum));
+ mute.setSelected(false);
+ Moosique.setTrackMute(track, false);
mute.setFont(Moosique.getGUI().FONT);
mute.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
boolean selected = mute.isSelected();
if (selected){
solo.setSelected(false);
- Moosique.getSequencer().setTrackSolo(trackNum, false);
+ Moosique.setTrackSolo(track, false);
}
- Moosique.getSequencer().setTrackMute(trackNum, selected);
+ Moosique.setTrackMute(track, selected);
}});
checkboxes.add(mute);
solo = new JCheckBox("Solo");
- solo.setSelected(Moosique.getSequencer().getTrackSolo(trackNum));
+ solo.setSelected(false);
+ Moosique.setTrackSolo(track, false);
solo.setFont(Moosique.getGUI().FONT);
solo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
boolean selected = solo.isSelected();
if (selected){
mute.setSelected(false);
- Moosique.getSequencer().setTrackMute(trackNum, false);
+ Moosique.setTrackMute(track, false);
}
- Moosique.getSequencer().setTrackSolo(trackNum, selected);
+ Moosique.setTrackSolo(track, selected);
}});
checkboxes.add(solo);
add(checkboxes);
}
+
+ /**
+ * Returns the channel of the track that the view is visualising.
+ * @return the chanel of the visualised track
+ */
+ public int getChannel() {
+ return channel;
+ }
+ /**
+ * Checks if the focus is lost.
+ */
class TitleFocusListener extends FocusAdapter {
public void focusLost(FocusEvent e) {
// Update the MidiEvent containing the title of this track