update the website url
[gmidimonitor.git] / gm.c
blob354b9c629aedb1170172ec9eac2bb077d589a454
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * This file is part of gmidimonitor
6 * Copyright (C) 2005,2006,2007,2008,2011 Nedko Arnaudov <nedko@arnaudov.name>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *****************************************************************************/
23 #include <stdlib.h>
24 #include <assert.h>
26 #include "gm.h"
28 static const char * g_gm_instrument_names[] =
30 "Acoustic Grand Piano", /* 1 */
31 "Bright Acoustic Piano", /* 2 */
32 "Electric Grand Piano", /* 3 */
33 "Honky-tonk Piano", /* 4 */
34 "Electric Piano 1", /* 5 */
35 "Electric Piano 2", /* 6 */
36 "Harpsichord", /* 7 */
37 "Clavi", /* 8 */
38 "Celesta", /* 9 */
39 "Glockenspiel", /* 10 */
40 "Music Box", /* 11 */
41 "Vibraphone", /* 12 */
42 "Marimba", /* 13 */
43 "Xylophone", /* 14 */
44 "Tubular Bells", /* 15 */
45 "Dulcimer", /* 16 */
46 "Drawbar Organ", /* 17 */
47 "Percussive Organ", /* 18 */
48 "Rock Organ", /* 19 */
49 "Church Organ", /* 20 */
50 "Reed Organ", /* 21 */
51 "Accordion", /* 22 */
52 "Harmonica", /* 23 */
53 "Tango Accordion", /* 24 */
54 "Acoustic Guitar (nylon)", /* 25 */
55 "Acoustic Guitar (steel)", /* 26 */
56 "Electric Guitar (jazz)", /* 27 */
57 "Electric Guitar (clean)", /* 28 */
58 "Electric Guitar (muted)", /* 29 */
59 "Overdriven Guitar", /* 30 */
60 "Distortion Guitar", /* 31 */
61 "Guitar harmonics", /* 32 */
62 "Acoustic Bass", /* 33 */
63 "Electric Bass (finger)", /* 34 */
64 "Electric Bass (pick)", /* 35 */
65 "Fretless Bass", /* 36 */
66 "Slap Bass 1", /* 37 */
67 "Slap Bass 2", /* 38 */
68 "Synth Bass 1", /* 39 */
69 "Synth Bass 2", /* 40 */
70 "Violin", /* 41 */
71 "Viola", /* 42 */
72 "Cello", /* 43 */
73 "Contrabass", /* 44 */
74 "Tremolo Strings", /* 45 */
75 "Pizzicato Strings", /* 46 */
76 "Orchestral Harp", /* 47 */
77 "Timpani", /* 48 */
78 "String Ensemble 1", /* 49 */
79 "String Ensemble 2", /* 50 */
80 "SynthStrings 1", /* 51 */
81 "SynthStrings 2", /* 52 */
82 "Choir Aahs", /* 53 */
83 "Voice Oohs", /* 54 */
84 "Synth Voice", /* 55 */
85 "Orchestra Hit", /* 56 */
86 "Trumpet", /* 57 */
87 "Trombone", /* 58 */
88 "Tuba", /* 59 */
89 "Muted Trumpet", /* 60 */
90 "French Horn", /* 61 */
91 "Brass Section", /* 62 */
92 "SynthBrass 1", /* 63 */
93 "SynthBrass 2", /* 64 */
94 "Soprano Sax", /* 65 */
95 "Alto Sax", /* 66 */
96 "Tenor Sax", /* 67 */
97 "Baritone Sax", /* 68 */
98 "Oboe", /* 69 */
99 "English Horn", /* 70 */
100 "Bassoon", /* 71 */
101 "Clarinet", /* 72 */
102 "Piccolo", /* 73 */
103 "Flute", /* 74 */
104 "Recorder", /* 75 */
105 "Pan Flute", /* 76 */
106 "Blown Bottle", /* 77 */
107 "Shakuhachi", /* 78 */
108 "Whistle", /* 79 */
109 "Ocarina", /* 80 */
110 "Lead 1 (square)", /* 81 */
111 "Lead 2 (sawtooth)", /* 82 */
112 "Lead 3 (calliope)", /* 83 */
113 "Lead 4 (chiff)", /* 84 */
114 "Lead 5 (charang)", /* 85 */
115 "Lead 6 (voice)", /* 86 */
116 "Lead 7 (fifths)", /* 87 */
117 "Lead 8 (bass + lead)", /* 88 */
118 "Pad 1 (new age)", /* 89 */
119 "Pad 2 (warm)", /* 90 */
120 "Pad 3 (polysynth)", /* 91 */
121 "Pad 4 (choir)", /* 92 */
122 "Pad 5 (bowed)", /* 93 */
123 "Pad 6 (metallic)", /* 94 */
124 "Pad 7 (halo)", /* 95 */
125 "Pad 8 (sweep)", /* 96 */
126 "FX 1 (rain)", /* 97 */
127 "FX 2 (soundtrack)", /* 98 */
128 "FX 3 (crystal)", /* 99 */
129 "FX 4 (atmosphere)", /* 100 */
130 "FX 5 (brightness)", /* 101 */
131 "FX 6 (goblins)", /* 102 */
132 "FX 7 (echoes)", /* 103 */
133 "FX 8 (sci-fi)", /* 104 */
134 "Sitar", /* 105 */
135 "Banjo", /* 106 */
136 "Shamisen", /* 107 */
137 "Koto", /* 108 */
138 "Kalimba", /* 109 */
139 "Bag pipe", /* 110 */
140 "Fiddle", /* 111 */
141 "Shanai", /* 112 */
142 "Tinkle Bell", /* 113 */
143 "Agogo", /* 114 */
144 "Steel Drums", /* 115 */
145 "Woodblock", /* 116 */
146 "Taiko Drum", /* 117 */
147 "Melodic Tom", /* 118 */
148 "Synth Drum", /* 119 */
149 "Reverse Cymbal", /* 120 */
150 "Guitar Fret Noise", /* 121 */
151 "Breath Noise", /* 122 */
152 "Seashore", /* 123 */
153 "Bird Tweet", /* 124 */
154 "Telephone Ring", /* 125 */
155 "Helicopter", /* 126 */
156 "Applause", /* 127 */
157 "Gunshot", /* 128 */
160 #define GM_DRUM_FIRST_NOTE 35
161 #define GM_DRUM_NOTES_COUNT (sizeof(g_gm_drum_names) / sizeof(g_gm_drum_names[0]))
163 static const char * g_gm_drum_names[] =
165 "Acoustic Bass Drum", /* 35 */
166 "Bass Drum 1", /* 36 */
167 "Side Stick", /* 37 */
168 "Acoustic Snare", /* 38 */
169 "Hand Clap", /* 39 */
170 "Electric Snare", /* 40 */
171 "Low Floor Tom", /* 41 */
172 "Closed Hi-Hat", /* 42 */
173 "High Floor Tom", /* 43 */
174 "Pedal Hi-Hat", /* 44 */
175 "Low Tom", /* 45 */
176 "Open Hi-Hat", /* 46 */
177 "Low-Mid Tom", /* 47 */
178 "Hi-Mid Tom", /* 48 */
179 "Crash Cymbal 1", /* 49 */
180 "High Tom", /* 50 */
181 "Ride Cymbal 1", /* 51 */
182 "Chinese Cymbal", /* 52 */
183 "Ride Bell", /* 53 */
184 "Tambourine", /* 54 */
185 "Splash Cymbal", /* 55 */
186 "Cowbell", /* 56 */
187 "Crash Cymbal 2", /* 57 */
188 "Vibraslap", /* 58 */
189 "Ride Cymbal 2", /* 59 */
190 "Hi Bongo", /* 60 */
191 "Low Bongo", /* 61 */
192 "Mute Hi Conga", /* 62 */
193 "Open Hi Conga", /* 63 */
194 "Low Conga", /* 64 */
195 "High Timbale", /* 65 */
196 "Low Timbale", /* 66 */
197 "High Agogo", /* 67 */
198 "Low Agogo", /* 68 */
199 "Cabasa", /* 69 */
200 "Maracas", /* 70 */
201 "Short Whistle", /* 71 */
202 "Long Whistle", /* 72 */
203 "Short Guiro", /* 73 */
204 "Long Guiro", /* 74 */
205 "Claves", /* 75 */
206 "Hi Wood Block", /* 76 */
207 "Low Wood Block", /* 77 */
208 "Mute Cuica", /* 78 */
209 "Open Cuica", /* 79 */
210 "Mute Triangle", /* 80 */
211 "Open Triangle", /* 81 */
214 const char *
215 gm_get_drum_name(
216 unsigned char note)
218 if (note >= GM_DRUM_FIRST_NOTE &&
219 note < GM_DRUM_FIRST_NOTE + GM_DRUM_NOTES_COUNT)
221 return g_gm_drum_names[note - GM_DRUM_FIRST_NOTE];
223 else
225 return NULL;
229 const char *
230 gm_get_instrument_name(
231 unsigned char program)
233 assert(program < sizeof(g_gm_instrument_names)/sizeof(g_gm_instrument_names[0]));
235 return g_gm_instrument_names[program];
238 const char *
239 gm_get_controller_name(
240 unsigned int controller)
242 switch (controller)
244 case 0x00:
245 return "Bank selection";
246 case 0x01:
247 return "Modulation";
248 case 0x02:
249 return "Breath";
250 case 0x04:
251 return "Foot";
252 case 0x05:
253 return "Portamento time";
254 case 0x06:
255 return "Data entry";
256 case 0x07:
257 return "Main volume";
258 case 0x08:
259 return "Balance";
260 case 0x0A:
261 return "Panpot";
262 case 0x0B:
263 return "Expression";
264 case 0x0C:
265 return "Effect1";
266 case 0x0D:
267 return "Effect2";
268 case 0x10:
269 return "General purpose 1";
270 case 0x11:
271 return "General purpose 2";
272 case 0x12:
273 return "General purpose 3";
274 case 0x13:
275 return "General purpose 4";
276 case 0x20:
277 return "Bank selection (LSB)";
278 case 0x21:
279 return "Modulation (LSB)";
280 case 0x22:
281 return "Breath (LSB)";
282 case 0x24:
283 return "Foot (LSB)";
284 case 0x25:
285 return "Portamento time (LSB)";
286 case 0x26:
287 return "Data entry (LSB)";
288 case 0x27:
289 return "Main volume (LSB)";
290 case 0x28:
291 return "Balance (LSB)";
292 case 0x2A:
293 return "Panpot (LSB)";
294 case 0x2B:
295 return "Expression (LSB)";
296 case 0x2C:
297 return "Effect1 (LSB)";
298 case 0x2D:
299 return "Effect2 (LSB)";
300 case 0x30:
301 return "General purpose 1 (LSB)";
302 case 0x31:
303 return "General purpose 2 (LSB)";
304 case 0x32:
305 return "General purpose 3 (LSB)";
306 case 0x33:
307 return "General purpose 4 (LSB)";
308 case 0x40:
309 return "Sustain pedal";
310 case 0x41:
311 return "Portamento";
312 case 0x42:
313 return "Sostenuto";
314 case 0x43:
315 return "Soft pedal";
316 case 0x44:
317 return "Legato foot switch";
318 case 0x45:
319 return "Hold2";
320 case 0x46:
321 return "SC1 Sound Variation";
322 case 0x47:
323 return "SC2 Timbre";
324 case 0x48:
325 return "SC3 Release Time";
326 case 0x49:
327 return "SC4 Attack Time";
328 case 0x4A:
329 return "SC5 Brightness";
330 case 0x4B:
331 return "SC6";
332 case 0x4C:
333 return "SC7";
334 case 0x4D:
335 return "SC8";
336 case 0x4E:
337 return "SC9";
338 case 0x4F:
339 return "SC10";
340 case 0x50:
341 return "General purpose 5";
342 case 0x51:
343 return "General purpose 6";
344 case 0x52:
345 return "General purpose 7";
346 case 0x53:
347 return "General purpose 8";
348 case 0x54:
349 return "Portamento control";
350 case 0x5B:
351 return "E1 Reverb Depth";
352 case 0x5C:
353 return "E2 Tremolo Depth";
354 case 0x5D:
355 return "E3 Chorus Depth";
356 case 0x5E:
357 return "E4 Detune Depth";
358 case 0x5F:
359 return "E5 Phaser Depth";
360 case 0x60:
361 return "Data Increment";
362 case 0x61:
363 return "Data Decrement";
364 case 0x62:
365 return "Non-registered parameter number (LSB)";
366 case 0x63:
367 return "Non-registered parameter number (MSB)";
368 case 0x64:
369 return "Registered parameter number (LSB)";
370 case 0x65:
371 return "Registered parameter number (MSB)";
374 return NULL;