]> ruin.nu Git - moosique.git/blob - MooInstrumentList.java
more comments.. *sigh* ;py
[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         
16         /**
17          * Creates the instrument list.
18          * @param chan The channel it will operate on.
19          */
20         public MooInstrumentList(int chan) {
21                 super(instruments);
22                 setChannel(chan);       
23                 setFont(new Font("Helvetica", Font.PLAIN, 10));
24                 addActionListener(this);
25         }
26
27         /**
28          * Sets the channel that it will operate on.
29          */
30         public void setChannel(int chan) {
31                 channel = chan;
32                 setSelectedIndex(Moosique.getChannel(channel).getProgram());
33         }
34
35         /**
36          * Sets the instrument on a channel when it's changed in the combobox.
37          */
38         public void actionPerformed(ActionEvent e) {
39                 JComboBox box = (JComboBox)e.getSource();
40                 int instrument = box.getSelectedIndex();
41                 Moosique.getChannel(channel).programChange(instrument);
42         }
43     
44         /**
45          * The list with standard midi instruments.
46          */
47         public static final String[] instruments = {
48                 " 0 Acoustic Grand Piano",
49                 " 1 Bright Acoustic Piano",
50                 " 2 Electric Grand Piano",
51                 " 3 Honky-Tonk Piano",
52                 " 4 Rhodes Piano",
53                 " 5 Chorused Piano",
54                 " 6 Harpischord",
55                 " 7 Clavinet",
56                 " 8 Celesta",
57                 " 9 Glockenspiel",
58                 " 10 Music Box",
59                 " 11 Vibraphone",
60                 " 12 Marimba",
61                 " 13 Xylophone",
62                 " 14 Tubular Bells",
63                 " 15 Dulcimer",
64                 " 16 Hammond Organ",
65                 " 17 Percussive Organ",
66                 " 18 Rock Organ",
67                 " 19 Church Organ",
68                 " 20 Reed Organ",
69                 " 21 Accordion",
70                 " 22 Harmonica",
71                 " 23 Tango Accordion",
72                 " 24 Acoustic Nylon Guitar",
73                 " 25 Acoustic Steel Guitar",
74                 " 26 Electric Jazz Guitar",
75                 " 27 Electric Clean Guitar",
76                 " 28 Electric Muted Guitar",
77                 " 29 Overdriven Guitar",
78                 " 30 Distortion Guitar",
79                 " 31 Guitar Harmonics",
80                 " 32 Acoustic Bass",
81                 " 33 Electric Bass Fingered",
82                 " 34 Electric Bass Picked",
83                 " 35 Fretless Bass",
84                 " 36 Slap Bass 1",
85                 " 37 Slap Bass 2",
86                 " 38 Synth Bass 1",
87                 " 39 Synth Bass 2",
88                 " 40 Violin",
89                 " 41 Viola",
90                 " 42 Cello",
91                 " 43 Contrabass",
92                 " 44 Tremolo Strings",
93                 " 45 Pizzicato Strings",
94                 " 46 Orchestral Harp",
95                 " 47 Timpani",
96                 " 48 String Ensemble 1",
97                 " 49 String Ensemble 2",
98                 " 50 Synth Strings 1",
99                 " 51 Synth Strings 2",
100                 " 52 Choir Aahs",
101                 " 53 Voice Oohs",
102                 " 54 Synth Voice",
103                 " 55 Orchestral Hit",
104                 " 56 Trumpet",
105                 " 57 Trombone",
106                 " 58 Tuba",
107                 " 59 Muted Trumpet",
108                 " 60 French Horn",
109                 " 61 Brass Section",
110                 " 62 Synth Brass 1",
111                 " 63 Synth Brass 2",
112                 " 64 Soprano Sax",
113                 " 65 Alto Sax",
114                 " 66 Tenor Sax",
115                 " 67 Baritone Sax",
116                 " 68 Oboe",
117                 " 69 English Horn",
118                 " 70 Bassoon",
119                 " 71 Clarinet",
120                 " 72 Piccolo",
121                 " 73 Flute",
122                 " 74 Recorder",
123                 " 75 Pan Flute",
124                 " 76 Bottle Blow",
125                 " 77 Shakuhachi",
126                 " 78 Whistle",
127                 " 79 Ocarina",
128                 " 80 Synth Lead 1 Square Wave Lead",
129                 " 81 Synth Lead 2 Sawtooth Wave Lead",
130                 " 82 Synth Lead 3 Caliope Lead",
131                 " 83 Synth Lead 4 Chiff Lead",
132                 " 84 Synth Lead 5 Charang",
133                 " 85 Synth Lead 6 Solo Synth Voice",
134                 " 86 Synth Lead 7 Bright Saw Wave",
135                 " 87 Synth Lead 8 Brass and Lead",
136                 " 88 Synth Pad 1 Fantasia Pad",
137                 " 89 Synth Pad 2 Warm Pad",
138                 " 90 Synth Pad 3 Poly Synth Pad",
139                 " 91 Synth Pad 4 Space Voice Pad",
140                 " 92 Synth Pad 5 Bowed Glass Pad",
141                 " 93 Synth Pad 6 Metal Pad",
142                 " 94 Synth Pad 7 Halo Pad",
143                 " 95 Synth Pad 8 Sweep Pad",
144                 " 96 Synth SFX 1 Ice Rain",
145                 " 97 Synth SFX 2 Sound Track",
146                 " 98 Synth SFX 3 Crystal",
147                 " 99 Synth SFX 4 Atmosphere",
148                 " 100 Synth SFX 5 Brightness",
149                 " 101 Synth SFX 6 Goblin",
150                 " 102 Synth SFX 7 Echo Drops",
151                 " 103 Synth SFX 8 Star Theme",
152                 " 104 Sitar",
153                 " 105 Banjo",
154                 " 106 Shamisen",
155                 " 107 Koto",
156                 " 108 Kalimba",
157                 " 109 Bagpipe",
158                 " 110 Fiddle",
159                 " 111 Shanai",
160                 " 112 Tinkle Bells",
161                 " 113 Agogo",
162                 " 114 Steel Drums",
163                 " 115 Woodblock",
164                 " 116 Taiko Drum",
165                 " 117 Melodic Tom",
166                 " 118 Synth Drum",
167                 " 119 Reverse Cymbal",
168                 " 120 Guitar Fret Noise",
169                 " 121 Breath Noise",
170                 " 122 Seashore",
171                 " 123 Bird Tweet",
172                 " 124 Telephone Ring",
173                 " 125 Helicopter",
174                 " 126 Applause",
175                 " 127 Gunshot"
176         };
177 }