From 48b314acf130d347f3c0e01ca7d8e9e90b5eb3b5 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 13 May 2003 16:21:40 +0000 Subject: [PATCH] sets and gets the channel.. --- MooNote.java | 5 +++-- MooTrackTitle.java | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/MooNote.java b/MooNote.java index 2774c30..d942de9 100644 --- a/MooNote.java +++ b/MooNote.java @@ -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 +} diff --git a/MooTrackTitle.java b/MooTrackTitle.java index 7e749f2..e229c6d 100644 --- a/MooTrackTitle.java +++ b/MooTrackTitle.java @@ -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); -- 2.39.2