]> ruin.nu Git - moosique.git/blob - MooInstrumentList.java
hmm.. this doesn't want to work..
[moosique.git] / MooInstrumentList.java
1 import javax.sound.midi.*;
2 import javax.swing.*;
3 import java.awt.*;
4 import java.awt.event.*;
5
6 /**
7  * A Combo Box where the instrument of the currently active channel can be selected.
8  * 
9  * @author  Einar Pehrson, Michael Andreen
10  */
11  
12 public class MooInstrumentList extends JComboBox implements ActionListener {
13
14         protected int channel;
15         public static final int INSTRUMENTS = 0, DRUMS = 1;
16         
17         /**
18          * Creates the instrument list.
19          * @param chan The channel it will operate on.
20          */
21         public MooInstrumentList(int chan, int listType) {
22                 super(instruments[listType]);
23                 setChannel(chan);       
24                 setFont(Moosique.getGUI().FONT);
25                 addActionListener(this);
26         }
27
28         /**
29          * Sets the channel that it will operate on.
30          */
31         public void setChannel(int chan) {
32                 channel = chan;
33                 setSelectedIndex(Moosique.getChannel(channel).getProgram());
34         }
35
36         /**
37          * Sets the instrument on a channel when it's changed in the combobox.
38          */
39         public void actionPerformed(ActionEvent e) {
40                 JComboBox box = (JComboBox)e.getSource();
41                 int instrument = box.getSelectedIndex();
42                 Moosique.getChannel(channel).programChange(instrument);
43         }
44     
45         /**
46          * The list with standard midi instruments.
47          */
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",
53                 " 4 Rhodes Piano",
54                 " 5 Chorused Piano",
55                 " 6 Harpischord",
56                 " 7 Clavinet",
57                 " 8 Celesta",
58                 " 9 Glockenspiel",
59                 " 10 Music Box",
60                 " 11 Vibraphone",
61                 " 12 Marimba",
62                 " 13 Xylophone",
63                 " 14 Tubular Bells",
64                 " 15 Dulcimer",
65                 " 16 Hammond Organ",
66                 " 17 Percussive Organ",
67                 " 18 Rock Organ",
68                 " 19 Church Organ",
69                 " 20 Reed Organ",
70                 " 21 Accordion",
71                 " 22 Harmonica",
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",
81                 " 32 Acoustic Bass",
82                 " 33 Electric Bass Fingered",
83                 " 34 Electric Bass Picked",
84                 " 35 Fretless Bass",
85                 " 36 Slap Bass 1",
86                 " 37 Slap Bass 2",
87                 " 38 Synth Bass 1",
88                 " 39 Synth Bass 2",
89                 " 40 Violin",
90                 " 41 Viola",
91                 " 42 Cello",
92                 " 43 Contrabass",
93                 " 44 Tremolo Strings",
94                 " 45 Pizzicato Strings",
95                 " 46 Orchestral Harp",
96                 " 47 Timpani",
97                 " 48 String Ensemble 1",
98                 " 49 String Ensemble 2",
99                 " 50 Synth Strings 1",
100                 " 51 Synth Strings 2",
101                 " 52 Choir Aahs",
102                 " 53 Voice Oohs",
103                 " 54 Synth Voice",
104                 " 55 Orchestral Hit",
105                 " 56 Trumpet",
106                 " 57 Trombone",
107                 " 58 Tuba",
108                 " 59 Muted Trumpet",
109                 " 60 French Horn",
110                 " 61 Brass Section",
111                 " 62 Synth Brass 1",
112                 " 63 Synth Brass 2",
113                 " 64 Soprano Sax",
114                 " 65 Alto Sax",
115                 " 66 Tenor Sax",
116                 " 67 Baritone Sax",
117                 " 68 Oboe",
118                 " 69 English Horn",
119                 " 70 Bassoon",
120                 " 71 Clarinet",
121                 " 72 Piccolo",
122                 " 73 Flute",
123                 " 74 Recorder",
124                 " 75 Pan Flute",
125                 " 76 Bottle Blow",
126                 " 77 Shakuhachi",
127                 " 78 Whistle",
128                 " 79 Ocarina",
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",
153                 " 104 Sitar",
154                 " 105 Banjo",
155                 " 106 Shamisen",
156                 " 107 Koto",
157                 " 108 Kalimba",
158                 " 109 Bagpipe",
159                 " 110 Fiddle",
160                 " 111 Shanai",
161                 " 112 Tinkle Bells",
162                 " 113 Agogo",
163                 " 114 Steel Drums",
164                 " 115 Woodblock",
165                 " 116 Taiko Drum",
166                 " 117 Melodic Tom",
167                 " 118 Synth Drum",
168                 " 119 Reverse Cymbal",
169                 " 120 Guitar Fret Noise",
170                 " 121 Breath Noise",
171                 " 122 Seashore",
172                 " 123 Bird Tweet",
173                 " 124 Telephone Ring",
174                 " 125 Helicopter",
175                 " 126 Applause",
176                 " 127 Gunshot"
177         }, new String[128]};
178         
179         static {
180                 for (int i = 0; i < 128; i++) {
181                         instruments[1][i] = " Program Change " + i;
182                 }       
183         }
184 }