]> ruin.nu Git - moosique.git/commitdiff
sets and gets the channel..
authorMichael Andreen <harv@ruin.nu>
Tue, 13 May 2003 16:21:40 +0000 (16:21 +0000)
committerMichael Andreen <harv@ruin.nu>
Tue, 13 May 2003 16:21:40 +0000 (16:21 +0000)
MooNote.java
MooTrackTitle.java

index 2774c3052090a98bfadfc76a6156aba485189e6e..d942de93a6e1e7c6dd455f153833bfbe73fa5e26 100644 (file)
@@ -62,7 +62,8 @@ public class MooNote extends MidiEvent {
                try {
                        noteOnMsg.setMessage(noteOnMsg.getCommand(), (byte)channel, noteOnMsg.getData1(), noteOnMsg.getData2());
                        noteOffMsg.setMessage(noteOffMsg.getCommand(), (byte)channel, noteOffMsg.getData1(), noteOffMsg.getData2());
-               } catch (InvalidMidiDataException e) {}
+               } catch (Exception e) {}
+               //} catch (InvalidMidiDataException e) {}
        }
 
        /** 
@@ -144,4 +145,4 @@ public class MooNote extends MidiEvent {
        public boolean hasNoteOffEvent() {
                return noteOffEvent != null;
        }
-}
\ No newline at end of file
+}
index 7e749f213539d3bc7dd67dc05380669c1e849944..e229c6dfbc3da8165bb9e9a4d50b800f6a71ead3 100644 (file)
@@ -17,10 +17,12 @@ public class MooTrackTitle extends JPanel {
        private JComboBox channel;
        private JCheckBox mute;
        private JCheckBox solo;
+       private Track track;
        /** 
         * Creates the title bar.
         */
-       public MooTrackTitle (Track track) {
+       public MooTrackTitle (Track aTrack) {
+               track = aTrack;
                setLayout(new GridLayout(4,1));
                setBorder(BorderFactory.createLineBorder(Color.black));
 
@@ -40,13 +42,35 @@ public class MooTrackTitle extends JPanel {
                channel.setFont(Moosique.getGUI().FONT);
                for (int i = 1; i <= 16; i++)
                        channel.addItem(new Integer(i));
+
+               for (int j = 0; j < track.size(); j++) {
+                       MidiEvent me = track.get(j);
+               if (me instanceof MooNote){
+                               MooNote mn = (MooNote)me;
+                               channel.setSelectedIndex(mn.getChannel());
+                               break;
+                       }
+        }
+
                channel.addItemListener(new ItemListener(){
                                public void itemStateChanged(ItemEvent e){
                                        Object ob = channel.getSelectedItem();
                                        if (ob instanceof Integer){
+                                               int chan = ((Integer)ob).intValue();
                                                //set channel
+                                               MidiEvent me;
+                                               MooNote mn;
+                                               for (int j = 0; j < track.size(); j++) {
+                                                       me = track.get(j);
+                                               if (me instanceof MooNote){
+                                                               mn = (MooNote)me;
+                                                               mn.setChannel(chan);
+                                                               System.out.println(ob);
+                                                       }
+                                   }
                                        }
                                }});
+
                add(channel);