From: Michael Andreen Date: Tue, 13 May 2003 16:46:14 +0000 (+0000) Subject: changes to instrument and channel combos.. X-Git-Url: https://ruin.nu/git/?p=moosique.git;a=commitdiff_plain;h=f7c0dc0b216c60d93f722b040878a51399679fc2 changes to instrument and channel combos.. --- diff --git a/MooInstrumentList.java b/MooInstrumentList.java index 716cd18..88903e0 100644 --- a/MooInstrumentList.java +++ b/MooInstrumentList.java @@ -11,16 +11,22 @@ import java.awt.event.*; public class MooInstrumentList extends JComboBox implements ActionListener { - public MooInstrumentList() { + protected int channel; + public MooInstrumentList(int chan) { super(instruments); + setChannel(chan); setFont(new Font("Helvetica", Font.PLAIN, 10)); addActionListener(this); } + public void setChannel(int chan){ + channel = chan; + setSelectedIndex(Moosique.getChannel(chan).getProgram()); + } public void actionPerformed(ActionEvent e) { JComboBox box = (JComboBox)e.getSource(); int instrument = box.getSelectedIndex(); - Moosique.getActiveChannel().programChange(instrument); + Moosique.getChannel(channel).programChange(instrument); } public static final String[] instruments = { diff --git a/MooTrackTitle.java b/MooTrackTitle.java index e229c6d..1d9171a 100644 --- a/MooTrackTitle.java +++ b/MooTrackTitle.java @@ -32,8 +32,6 @@ public class MooTrackTitle extends JPanel { title.addFocusListener(new TitleFocusListener()); add(title); - instruments = new MooInstrumentList(); - add(instruments); JPanel checkboxes = new JPanel(); checkboxes.setLayout(new GridLayout(1,3)); @@ -52,26 +50,23 @@ public class MooTrackTitle extends JPanel { } } - 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); - } - } - } + instruments = new MooInstrumentList(channel.getSelectedIndex()); + + channel.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + int chan = channel.getSelectedIndex(); + MidiEvent me; + MooNote mn; + instruments.setChannel(channel.getSelectedIndex()); + for (int j = 0; j < track.size(); j++) { + me = track.get(j); + if (me instanceof MooNote){ + mn = (MooNote)me; + mn.setChannel(chan); + } + } }}); - add(channel); mute = new JCheckBox("Mute"); @@ -91,6 +86,9 @@ public class MooTrackTitle extends JPanel { mute.setSelected(false); }}); checkboxes.add(solo); + + add(instruments); + add(channel); add(checkboxes); } diff --git a/Moosique.java b/Moosique.java index b79fa67..c100436 100644 --- a/Moosique.java +++ b/Moosique.java @@ -119,6 +119,14 @@ public class Moosique { return channels; } + /** + * Returns the MidiChannels of the selected synthesizer. + * @return the available MidiChannels + */ + public static MidiChannel getChannel(int i) { + return channels[i]; + } + /** * Returns the currently active MidiChannel. * @return the active MidiChannel