1 import javax.sound.midi.*;
4 import java.awt.event.*;
7 * A Combo Box where the instrument of the currently active channel can be selected.
9 * @author Einar Pehrson, Michael Andreen
12 public class MooInstrumentList extends JComboBox implements ActionListener {
14 protected int channel;
15 public static final int INSTRUMENTS = 0, DRUMS = 1;
18 * Creates the instrument list.
19 * @param chan The channel it will operate on.
21 public MooInstrumentList(int chan, int listType) {
22 super(instruments[listType]);
24 setFont(new Font("Helvetica", Font.PLAIN, 10));
25 addActionListener(this);
29 * Sets the channel that it will operate on.
31 public void setChannel(int chan) {
33 setSelectedIndex(Moosique.getChannel(channel).getProgram());
37 * Sets the instrument on a channel when it's changed in the combobox.
39 public void actionPerformed(ActionEvent e) {
40 JComboBox box = (JComboBox)e.getSource();
41 int instrument = box.getSelectedIndex();
42 Moosique.getChannel(channel).programChange(instrument);
46 * The list with standard midi instruments.
48 public static final String[][] instruments = {{
49 " 0 Acoustic Grand Piano",
50 " 1 Bright Acoustic Piano",
51 " 2 Electric Grand Piano",
52 " 3 Honky-Tonk Piano",
66 " 17 Percussive Organ",
72 " 23 Tango Accordion",
73 " 24 Acoustic Nylon Guitar",
74 " 25 Acoustic Steel Guitar",
75 " 26 Electric Jazz Guitar",
76 " 27 Electric Clean Guitar",
77 " 28 Electric Muted Guitar",
78 " 29 Overdriven Guitar",
79 " 30 Distortion Guitar",
80 " 31 Guitar Harmonics",
82 " 33 Electric Bass Fingered",
83 " 34 Electric Bass Picked",
93 " 44 Tremolo Strings",
94 " 45 Pizzicato Strings",
95 " 46 Orchestral Harp",
97 " 48 String Ensemble 1",
98 " 49 String Ensemble 2",
99 " 50 Synth Strings 1",
100 " 51 Synth Strings 2",
104 " 55 Orchestral Hit",
129 " 80 Synth Lead 1 Square Wave Lead",
130 " 81 Synth Lead 2 Sawtooth Wave Lead",
131 " 82 Synth Lead 3 Caliope Lead",
132 " 83 Synth Lead 4 Chiff Lead",
133 " 84 Synth Lead 5 Charang",
134 " 85 Synth Lead 6 Solo Synth Voice",
135 " 86 Synth Lead 7 Bright Saw Wave",
136 " 87 Synth Lead 8 Brass and Lead",
137 " 88 Synth Pad 1 Fantasia Pad",
138 " 89 Synth Pad 2 Warm Pad",
139 " 90 Synth Pad 3 Poly Synth Pad",
140 " 91 Synth Pad 4 Space Voice Pad",
141 " 92 Synth Pad 5 Bowed Glass Pad",
142 " 93 Synth Pad 6 Metal Pad",
143 " 94 Synth Pad 7 Halo Pad",
144 " 95 Synth Pad 8 Sweep Pad",
145 " 96 Synth SFX 1 Ice Rain",
146 " 97 Synth SFX 2 Sound Track",
147 " 98 Synth SFX 3 Crystal",
148 " 99 Synth SFX 4 Atmosphere",
149 " 100 Synth SFX 5 Brightness",
150 " 101 Synth SFX 6 Goblin",
151 " 102 Synth SFX 7 Echo Drops",
152 " 103 Synth SFX 8 Star Theme",
168 " 119 Reverse Cymbal",
169 " 120 Guitar Fret Noise",
173 " 124 Telephone Ring",
180 for (int i = 0; i < 128; i++) {
181 instruments[1][i] = " Program Change " + i;