rlm@3
|
1 <?php
|
rlm@3
|
2 // +----------------------------------------------------------------------+
|
rlm@3
|
3 // | PHP version 5 |
|
rlm@3
|
4 // +----------------------------------------------------------------------+
|
rlm@3
|
5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen |
|
rlm@3
|
6 // +----------------------------------------------------------------------+
|
rlm@3
|
7 // | This source file is subject to version 2 of the GPL license, |
|
rlm@3
|
8 // | that is bundled with this package in the file license.txt and is |
|
rlm@3
|
9 // | available through the world-wide-web at the following url: |
|
rlm@3
|
10 // | http://www.gnu.org/copyleft/gpl.html |
|
rlm@3
|
11 // +----------------------------------------------------------------------+
|
rlm@3
|
12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org |
|
rlm@3
|
13 // +----------------------------------------------------------------------+
|
rlm@3
|
14 // | Authors: James Heinrich <infoØgetid3*org> |
|
rlm@3
|
15 // | Allan Hansen <ahØartemis*dk> |
|
rlm@3
|
16 // +----------------------------------------------------------------------+
|
rlm@3
|
17 // | module.audio.midi.php |
|
rlm@3
|
18 // | Module for analyzing midi audio files |
|
rlm@3
|
19 // | dependencies: NONE |
|
rlm@3
|
20 // +----------------------------------------------------------------------+
|
rlm@3
|
21 //
|
rlm@3
|
22 // $Id: module.audio.midi.php,v 1.5 2006/11/02 10:48:01 ah Exp $
|
rlm@3
|
23
|
rlm@3
|
24
|
rlm@3
|
25
|
rlm@3
|
26 class getid3_midi extends getid3_handler
|
rlm@3
|
27 {
|
rlm@3
|
28
|
rlm@3
|
29 public function Analyze() {
|
rlm@3
|
30
|
rlm@3
|
31 $getid3 = $this->getid3;
|
rlm@3
|
32
|
rlm@3
|
33 $getid3->info['midi']['raw'] = array ();
|
rlm@3
|
34 $info_midi = &$getid3->info['midi'];
|
rlm@3
|
35 $info_midi_raw = &$info_midi['raw'];
|
rlm@3
|
36
|
rlm@3
|
37 $getid3->info['fileformat'] = 'midi';
|
rlm@3
|
38 $getid3->info['audio']['dataformat'] = 'midi';
|
rlm@3
|
39
|
rlm@3
|
40 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
|
rlm@3
|
41 $midi_data = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
|
rlm@3
|
42
|
rlm@3
|
43 // Magic bytes: 'MThd'
|
rlm@3
|
44
|
rlm@3
|
45 getid3_lib::ReadSequence('BigEndian2Int', $info_midi_raw, $midi_data, 4,
|
rlm@3
|
46 array (
|
rlm@3
|
47 'headersize' => 4,
|
rlm@3
|
48 'fileformat' => 2,
|
rlm@3
|
49 'tracks' => 2,
|
rlm@3
|
50 'ticksperqnote' => 2
|
rlm@3
|
51 )
|
rlm@3
|
52 );
|
rlm@3
|
53
|
rlm@3
|
54 $offset = 14;
|
rlm@3
|
55
|
rlm@3
|
56 for ($i = 0; $i < $info_midi_raw['tracks']; $i++) {
|
rlm@3
|
57
|
rlm@3
|
58 if ((strlen($midi_data) - $offset) < 8) {
|
rlm@3
|
59 $midi_data .= fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
|
rlm@3
|
60 }
|
rlm@3
|
61
|
rlm@3
|
62 $track_id = substr($midi_data, $offset, 4);
|
rlm@3
|
63 $offset += 4;
|
rlm@3
|
64
|
rlm@3
|
65 if ($track_id != 'MTrk') {
|
rlm@3
|
66 throw new getid3_exception('Expecting "MTrk" at '.$offset.', found '.$track_id.' instead');
|
rlm@3
|
67 }
|
rlm@3
|
68
|
rlm@3
|
69 $track_size = getid3_lib::BigEndian2Int(substr($midi_data, $offset, 4));
|
rlm@3
|
70 $offset += 4;
|
rlm@3
|
71
|
rlm@3
|
72 $track_data_array[$i] = substr($midi_data, $offset, $track_size);
|
rlm@3
|
73 $offset += $track_size;
|
rlm@3
|
74 }
|
rlm@3
|
75
|
rlm@3
|
76 if (!isset($track_data_array) || !is_array($track_data_array)) {
|
rlm@3
|
77 throw new getid3_exception('Cannot find MIDI track information');
|
rlm@3
|
78 }
|
rlm@3
|
79
|
rlm@3
|
80
|
rlm@3
|
81 $info_midi['totalticks'] = 0;
|
rlm@3
|
82 $getid3->info['playtime_seconds'] = 0;
|
rlm@3
|
83 $current_ms_per_beat = 500000; // 120 beats per minute; 60,000,000 microseconds per minute -> 500,000 microseconds per beat
|
rlm@3
|
84 $current_beats_per_min = 120; // 120 beats per minute; 60,000,000 microseconds per minute -> 500,000 microseconds per beat
|
rlm@3
|
85 $ms_per_quarter_note_after = array ();
|
rlm@3
|
86
|
rlm@3
|
87 foreach ($track_data_array as $track_number => $track_data) {
|
rlm@3
|
88
|
rlm@3
|
89 $events_offset = $last_issued_midi_command = $last_issued_midi_channel = $cumulative_delta_time = $ticks_at_current_bpm = 0;
|
rlm@3
|
90
|
rlm@3
|
91 while ($events_offset < strlen($track_data)) {
|
rlm@3
|
92
|
rlm@3
|
93 $event_id = 0;
|
rlm@3
|
94 if (isset($midi_events[$track_number]) && is_array($midi_events[$track_number])) {
|
rlm@3
|
95 $event_id = count($midi_events[$track_number]);
|
rlm@3
|
96 }
|
rlm@3
|
97 $delta_time = 0;
|
rlm@3
|
98 for ($i = 0; $i < 4; $i++) {
|
rlm@3
|
99 $delta_time_byte = ord($track_data{$events_offset++});
|
rlm@3
|
100 $delta_time = ($delta_time << 7) + ($delta_time_byte & 0x7F);
|
rlm@3
|
101 if ($delta_time_byte & 0x80) {
|
rlm@3
|
102 // another byte follows
|
rlm@3
|
103 } else {
|
rlm@3
|
104 break;
|
rlm@3
|
105 }
|
rlm@3
|
106 }
|
rlm@3
|
107
|
rlm@3
|
108 $cumulative_delta_time += $delta_time;
|
rlm@3
|
109 $ticks_at_current_bpm += $delta_time;
|
rlm@3
|
110
|
rlm@3
|
111 $midi_events[$track_number][$event_id]['deltatime'] = $delta_time;
|
rlm@3
|
112
|
rlm@3
|
113 $midi_event_channel = ord($track_data{$events_offset++});
|
rlm@3
|
114
|
rlm@3
|
115 // OK, normal event - MIDI command has MSB set
|
rlm@3
|
116 if ($midi_event_channel & 0x80) {
|
rlm@3
|
117 $last_issued_midi_command = $midi_event_channel >> 4;
|
rlm@3
|
118 $last_issued_midi_channel = $midi_event_channel & 0x0F;
|
rlm@3
|
119 }
|
rlm@3
|
120
|
rlm@3
|
121 // Running event - assume last command
|
rlm@3
|
122 else {
|
rlm@3
|
123 $events_offset--;
|
rlm@3
|
124 }
|
rlm@3
|
125
|
rlm@3
|
126 $midi_events[$track_number][$event_id]['eventid'] = $last_issued_midi_command;
|
rlm@3
|
127 $midi_events[$track_number][$event_id]['channel'] = $last_issued_midi_channel;
|
rlm@3
|
128
|
rlm@3
|
129 switch ($midi_events[$track_number][$event_id]['eventid']) {
|
rlm@3
|
130
|
rlm@3
|
131 case 0x8: // Note off (key is released)
|
rlm@3
|
132 case 0x9: // Note on (key is pressed)
|
rlm@3
|
133 case 0xA: // Key after-touch
|
rlm@3
|
134
|
rlm@3
|
135 //$notenumber = ord($track_data{$events_offset++});
|
rlm@3
|
136 //$velocity = ord($track_data{$events_offset++});
|
rlm@3
|
137 $events_offset += 2;
|
rlm@3
|
138 break;
|
rlm@3
|
139
|
rlm@3
|
140
|
rlm@3
|
141 case 0xB: // Control Change
|
rlm@3
|
142
|
rlm@3
|
143 //$controllernum = ord($track_data{$events_offset++});
|
rlm@3
|
144 //$newvalue = ord($track_data{$events_offset++});
|
rlm@3
|
145 $events_offset += 2;
|
rlm@3
|
146 break;
|
rlm@3
|
147
|
rlm@3
|
148
|
rlm@3
|
149 case 0xC: // Program (patch) change
|
rlm@3
|
150
|
rlm@3
|
151 $new_program_num = ord($track_data{$events_offset++});
|
rlm@3
|
152
|
rlm@3
|
153 $info_midi_raw['track'][$track_number]['instrumentid'] = $new_program_num;
|
rlm@3
|
154 $info_midi_raw['track'][$track_number]['instrument'] = $track_number == 10 ? getid3_midi::GeneralMIDIpercussionLookup($new_program_num) : getid3_midi::GeneralMIDIinstrumentLookup($new_program_num);
|
rlm@3
|
155 break;
|
rlm@3
|
156
|
rlm@3
|
157
|
rlm@3
|
158 case 0xD: // Channel after-touch
|
rlm@3
|
159
|
rlm@3
|
160 //$channelnumber = ord($track_data{$events_offset++});
|
rlm@3
|
161 break;
|
rlm@3
|
162
|
rlm@3
|
163
|
rlm@3
|
164 case 0xE: // Pitch wheel change (2000H is normal or no change)
|
rlm@3
|
165
|
rlm@3
|
166 //$changeLSB = ord($track_data{$events_offset++});
|
rlm@3
|
167 //$changeMSB = ord($track_data{$events_offset++});
|
rlm@3
|
168 //$pitchwheelchange = (($changeMSB & 0x7F) << 7) & ($changeLSB & 0x7F);
|
rlm@3
|
169 $events_offset += 2;
|
rlm@3
|
170 break;
|
rlm@3
|
171
|
rlm@3
|
172
|
rlm@3
|
173 case 0xF:
|
rlm@3
|
174
|
rlm@3
|
175 if ($midi_events[$track_number][$event_id]['channel'] == 0xF) {
|
rlm@3
|
176
|
rlm@3
|
177 $meta_event_command = ord($track_data{$events_offset++});
|
rlm@3
|
178 $meta_event_length = ord($track_data{$events_offset++});
|
rlm@3
|
179 $meta_event_data = substr($track_data, $events_offset, $meta_event_length);
|
rlm@3
|
180 $events_offset += $meta_event_length;
|
rlm@3
|
181
|
rlm@3
|
182 switch ($meta_event_command) {
|
rlm@3
|
183
|
rlm@3
|
184 case 0x00: // Set track sequence number
|
rlm@3
|
185
|
rlm@3
|
186 //$track_sequence_number = getid3_lib::BigEndian2Int(substr($meta_event_data, 0, $meta_event_length));
|
rlm@3
|
187 //$info_midi_raw['events'][$track_number][$event_id]['seqno'] = $track_sequence_number;
|
rlm@3
|
188 break;
|
rlm@3
|
189
|
rlm@3
|
190
|
rlm@3
|
191 case 0x01: // Text: generic
|
rlm@3
|
192
|
rlm@3
|
193 $text_generic = substr($meta_event_data, 0, $meta_event_length);
|
rlm@3
|
194 //$info_midi_raw['events'][$track_number][$event_id]['text'] = $text_generic;
|
rlm@3
|
195 $info_midi['comments']['comment'][] = $text_generic;
|
rlm@3
|
196 break;
|
rlm@3
|
197
|
rlm@3
|
198
|
rlm@3
|
199 case 0x02: // Text: copyright
|
rlm@3
|
200
|
rlm@3
|
201 $text_copyright = substr($meta_event_data, 0, $meta_event_length);
|
rlm@3
|
202 //$info_midi_raw['events'][$track_number][$event_id]['copyright'] = $text_copyright;
|
rlm@3
|
203 $info_midi['comments']['copyright'][] = $text_copyright;
|
rlm@3
|
204 break;
|
rlm@3
|
205
|
rlm@3
|
206
|
rlm@3
|
207 case 0x03: // Text: track name
|
rlm@3
|
208
|
rlm@3
|
209 $text_trackname = substr($meta_event_data, 0, $meta_event_length);
|
rlm@3
|
210 $info_midi_raw['track'][$track_number]['name'] = $text_trackname;
|
rlm@3
|
211 break;
|
rlm@3
|
212
|
rlm@3
|
213
|
rlm@3
|
214 case 0x04: // Text: track instrument name
|
rlm@3
|
215
|
rlm@3
|
216 //$text_instrument = substr($meta_event_data, 0, $meta_event_length);
|
rlm@3
|
217 //$info_midi_raw['events'][$track_number][$event_id]['instrument'] = $text_instrument;
|
rlm@3
|
218 break;
|
rlm@3
|
219
|
rlm@3
|
220
|
rlm@3
|
221 case 0x05: // Text: lyrics
|
rlm@3
|
222
|
rlm@3
|
223 $text_lyrics = substr($meta_event_data, 0, $meta_event_length);
|
rlm@3
|
224 //$info_midi_raw['events'][$track_number][$event_id]['lyrics'] = $text_lyrics;
|
rlm@3
|
225 if (!isset($info_midi['lyrics'])) {
|
rlm@3
|
226 $info_midi['lyrics'] = '';
|
rlm@3
|
227 }
|
rlm@3
|
228 $info_midi['lyrics'] .= $text_lyrics . "\n";
|
rlm@3
|
229 break;
|
rlm@3
|
230
|
rlm@3
|
231
|
rlm@3
|
232 case 0x06: // Text: marker
|
rlm@3
|
233
|
rlm@3
|
234 //$text_marker = substr($meta_event_data, 0, $meta_event_length);
|
rlm@3
|
235 //$info_midi_raw['events'][$track_number][$event_id]['marker'] = $text_marker;
|
rlm@3
|
236 break;
|
rlm@3
|
237
|
rlm@3
|
238
|
rlm@3
|
239 case 0x07: // Text: cue point
|
rlm@3
|
240
|
rlm@3
|
241 //$text_cuepoint = substr($meta_event_data, 0, $meta_event_length);
|
rlm@3
|
242 //$info_midi_raw['events'][$track_number][$event_id]['cuepoint'] = $text_cuepoint;
|
rlm@3
|
243 break;
|
rlm@3
|
244
|
rlm@3
|
245
|
rlm@3
|
246 case 0x2F: // End Of Track
|
rlm@3
|
247
|
rlm@3
|
248 //$info_midi_raw['events'][$track_number][$event_id]['EOT'] = $cumulative_delta_time;
|
rlm@3
|
249 break;
|
rlm@3
|
250
|
rlm@3
|
251
|
rlm@3
|
252 case 0x51: // Tempo: microseconds / quarter note
|
rlm@3
|
253
|
rlm@3
|
254 $current_ms_per_beat = getid3_lib::BigEndian2Int(substr($meta_event_data, 0, $meta_event_length));
|
rlm@3
|
255 $info_midi_raw['events'][$track_number][$cumulative_delta_time]['us_qnote'] = $current_ms_per_beat;
|
rlm@3
|
256 $current_beats_per_min = (1000000 / $current_ms_per_beat) * 60;
|
rlm@3
|
257 $ms_per_quarter_note_after[$cumulative_delta_time] = $current_ms_per_beat;
|
rlm@3
|
258 $ticks_at_current_bpm = 0;
|
rlm@3
|
259 break;
|
rlm@3
|
260
|
rlm@3
|
261
|
rlm@3
|
262 case 0x58: // Time signature
|
rlm@3
|
263 $timesig_numerator = getid3_lib::BigEndian2Int($meta_event_data[0]);
|
rlm@3
|
264 $timesig_denominator = pow(2, getid3_lib::BigEndian2Int($meta_event_data[1])); // $02 -> x/4, $03 -> x/8, etc
|
rlm@3
|
265 //$timesig_32inqnote = getid3_lib::BigEndian2Int($meta_event_data[2]); // number of 32nd notes to the quarter note
|
rlm@3
|
266 //$info_midi_raw['events'][$track_number][$event_id]['timesig_32inqnote'] = $timesig_32inqnote;
|
rlm@3
|
267 //$info_midi_raw['events'][$track_number][$event_id]['timesig_numerator'] = $timesig_numerator;
|
rlm@3
|
268 //$info_midi_raw['events'][$track_number][$event_id]['timesig_denominator'] = $timesig_denominator;
|
rlm@3
|
269 //$info_midi_raw['events'][$track_number][$event_id]['timesig_text'] = $timesig_numerator.'/'.$timesig_denominator;
|
rlm@3
|
270 $info_midi['timesignature'][] = $timesig_numerator.'/'.$timesig_denominator;
|
rlm@3
|
271 break;
|
rlm@3
|
272
|
rlm@3
|
273
|
rlm@3
|
274 case 0x59: // Keysignature
|
rlm@3
|
275
|
rlm@3
|
276 $keysig_sharpsflats = getid3_lib::BigEndian2Int($meta_event_data{0});
|
rlm@3
|
277 if ($keysig_sharpsflats & 0x80) {
|
rlm@3
|
278 // (-7 -> 7 flats, 0 ->key of C, 7 -> 7 sharps)
|
rlm@3
|
279 $keysig_sharpsflats -= 256;
|
rlm@3
|
280 }
|
rlm@3
|
281
|
rlm@3
|
282 $keysig_majorminor = getid3_lib::BigEndian2Int($meta_event_data{1}); // 0 -> major, 1 -> minor
|
rlm@3
|
283 $keysigs = array (-7=>'Cb', -6=>'Gb', -5=>'Db', -4=>'Ab', -3=>'Eb', -2=>'Bb', -1=>'F', 0=>'C', 1=>'G', 2=>'D', 3=>'A', 4=>'E', 5=>'B', 6=>'F#', 7=>'C#');
|
rlm@3
|
284 //$info_midi_raw['events'][$track_number][$event_id]['keysig_sharps'] = (($keysig_sharpsflats > 0) ? abs($keysig_sharpsflats) : 0);
|
rlm@3
|
285 //$info_midi_raw['events'][$track_number][$event_id]['keysig_flats'] = (($keysig_sharpsflats < 0) ? abs($keysig_sharpsflats) : 0);
|
rlm@3
|
286 //$info_midi_raw['events'][$track_number][$event_id]['keysig_minor'] = (bool)$keysig_majorminor;
|
rlm@3
|
287 //$info_midi_raw['events'][$track_number][$event_id]['keysig_text'] = $keysigs[$keysig_sharpsflats].' '.($info_midi_raw['events'][$track_number][$event_id]['keysig_minor'] ? 'minor' : 'major');
|
rlm@3
|
288
|
rlm@3
|
289 // $keysigs[$keysig_sharpsflats] gets an int key (correct) - $keysigs["$keysig_sharpsflats"] gets a string key (incorrect)
|
rlm@3
|
290 $info_midi['keysignature'][] = $keysigs[$keysig_sharpsflats].' '.((bool)$keysig_majorminor ? 'minor' : 'major');
|
rlm@3
|
291 break;
|
rlm@3
|
292
|
rlm@3
|
293
|
rlm@3
|
294 case 0x7F: // Sequencer specific information
|
rlm@3
|
295
|
rlm@3
|
296 $custom_data = substr($meta_event_data, 0, $meta_event_length);
|
rlm@3
|
297 break;
|
rlm@3
|
298
|
rlm@3
|
299
|
rlm@3
|
300 default:
|
rlm@3
|
301
|
rlm@3
|
302 $getid3->warning('Unhandled META Event Command: '.$meta_event_command);
|
rlm@3
|
303 }
|
rlm@3
|
304 }
|
rlm@3
|
305 break;
|
rlm@3
|
306
|
rlm@3
|
307
|
rlm@3
|
308 default:
|
rlm@3
|
309 $getid3->warning('Unhandled MIDI Event ID: '.$midi_events[$track_number][$event_id]['eventid']);
|
rlm@3
|
310 }
|
rlm@3
|
311 }
|
rlm@3
|
312
|
rlm@3
|
313 if (($track_number > 0) || (count($track_data_array) == 1)) {
|
rlm@3
|
314 $info_midi['totalticks'] = max($info_midi['totalticks'], $cumulative_delta_time);
|
rlm@3
|
315 }
|
rlm@3
|
316 }
|
rlm@3
|
317
|
rlm@3
|
318 $previous_tick_offset = null;
|
rlm@3
|
319
|
rlm@3
|
320 ksort($ms_per_quarter_note_after);
|
rlm@3
|
321 foreach ($ms_per_quarter_note_after as $tick_offset => $ms_per_beat) {
|
rlm@3
|
322
|
rlm@3
|
323 if (is_null($previous_tick_offset)) {
|
rlm@3
|
324 $prev_ms_per_beat = $ms_per_beat;
|
rlm@3
|
325 $previous_tick_offset = $tick_offset;
|
rlm@3
|
326 continue;
|
rlm@3
|
327 }
|
rlm@3
|
328
|
rlm@3
|
329 if ($info_midi['totalticks'] > $tick_offset) {
|
rlm@3
|
330 $getid3->info['playtime_seconds'] += (($tick_offset - $previous_tick_offset) / $info_midi_raw['ticksperqnote']) * ($prev_ms_per_beat / 1000000);
|
rlm@3
|
331
|
rlm@3
|
332 $prev_ms_per_beat = $ms_per_beat;
|
rlm@3
|
333 $previous_tick_offset = $tick_offset;
|
rlm@3
|
334 }
|
rlm@3
|
335 }
|
rlm@3
|
336
|
rlm@3
|
337 if ($info_midi['totalticks'] > $previous_tick_offset) {
|
rlm@3
|
338 $getid3->info['playtime_seconds'] += (($info_midi['totalticks'] - $previous_tick_offset) / $info_midi_raw['ticksperqnote']) * ($ms_per_beat / 1000000);
|
rlm@3
|
339 }
|
rlm@3
|
340
|
rlm@3
|
341 if (@$getid3->info['playtime_seconds'] > 0) {
|
rlm@3
|
342 $getid3->info['bitrate'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds'];
|
rlm@3
|
343 }
|
rlm@3
|
344
|
rlm@3
|
345 if (!empty($info_midi['lyrics'])) {
|
rlm@3
|
346 $info_midi['comments']['lyrics'][] = $info_midi['lyrics'];
|
rlm@3
|
347 }
|
rlm@3
|
348
|
rlm@3
|
349 return true;
|
rlm@3
|
350 }
|
rlm@3
|
351
|
rlm@3
|
352
|
rlm@3
|
353
|
rlm@3
|
354 public static function GeneralMIDIinstrumentLookup($instrument_id) {
|
rlm@3
|
355
|
rlm@3
|
356 static $lookup = array (
|
rlm@3
|
357
|
rlm@3
|
358 0 => 'Acoustic Grand',
|
rlm@3
|
359 1 => 'Bright Acoustic',
|
rlm@3
|
360 2 => 'Electric Grand',
|
rlm@3
|
361 3 => 'Honky-Tonk',
|
rlm@3
|
362 4 => 'Electric Piano 1',
|
rlm@3
|
363 5 => 'Electric Piano 2',
|
rlm@3
|
364 6 => 'Harpsichord',
|
rlm@3
|
365 7 => 'Clavier',
|
rlm@3
|
366 8 => 'Celesta',
|
rlm@3
|
367 9 => 'Glockenspiel',
|
rlm@3
|
368 10 => 'Music Box',
|
rlm@3
|
369 11 => 'Vibraphone',
|
rlm@3
|
370 12 => 'Marimba',
|
rlm@3
|
371 13 => 'Xylophone',
|
rlm@3
|
372 14 => 'Tubular Bells',
|
rlm@3
|
373 15 => 'Dulcimer',
|
rlm@3
|
374 16 => 'Drawbar Organ',
|
rlm@3
|
375 17 => 'Percussive Organ',
|
rlm@3
|
376 18 => 'Rock Organ',
|
rlm@3
|
377 19 => 'Church Organ',
|
rlm@3
|
378 20 => 'Reed Organ',
|
rlm@3
|
379 21 => 'Accordian',
|
rlm@3
|
380 22 => 'Harmonica',
|
rlm@3
|
381 23 => 'Tango Accordian',
|
rlm@3
|
382 24 => 'Acoustic Guitar (nylon)',
|
rlm@3
|
383 25 => 'Acoustic Guitar (steel)',
|
rlm@3
|
384 26 => 'Electric Guitar (jazz)',
|
rlm@3
|
385 27 => 'Electric Guitar (clean)',
|
rlm@3
|
386 28 => 'Electric Guitar (muted)',
|
rlm@3
|
387 29 => 'Overdriven Guitar',
|
rlm@3
|
388 30 => 'Distortion Guitar',
|
rlm@3
|
389 31 => 'Guitar Harmonics',
|
rlm@3
|
390 32 => 'Acoustic Bass',
|
rlm@3
|
391 33 => 'Electric Bass (finger)',
|
rlm@3
|
392 34 => 'Electric Bass (pick)',
|
rlm@3
|
393 35 => 'Fretless Bass',
|
rlm@3
|
394 36 => 'Slap Bass 1',
|
rlm@3
|
395 37 => 'Slap Bass 2',
|
rlm@3
|
396 38 => 'Synth Bass 1',
|
rlm@3
|
397 39 => 'Synth Bass 2',
|
rlm@3
|
398 40 => 'Violin',
|
rlm@3
|
399 41 => 'Viola',
|
rlm@3
|
400 42 => 'Cello',
|
rlm@3
|
401 43 => 'Contrabass',
|
rlm@3
|
402 44 => 'Tremolo Strings',
|
rlm@3
|
403 45 => 'Pizzicato Strings',
|
rlm@3
|
404 46 => 'Orchestral Strings',
|
rlm@3
|
405 47 => 'Timpani',
|
rlm@3
|
406 48 => 'String Ensemble 1',
|
rlm@3
|
407 49 => 'String Ensemble 2',
|
rlm@3
|
408 50 => 'SynthStrings 1',
|
rlm@3
|
409 51 => 'SynthStrings 2',
|
rlm@3
|
410 52 => 'Choir Aahs',
|
rlm@3
|
411 53 => 'Voice Oohs',
|
rlm@3
|
412 54 => 'Synth Voice',
|
rlm@3
|
413 55 => 'Orchestra Hit',
|
rlm@3
|
414 56 => 'Trumpet',
|
rlm@3
|
415 57 => 'Trombone',
|
rlm@3
|
416 58 => 'Tuba',
|
rlm@3
|
417 59 => 'Muted Trumpet',
|
rlm@3
|
418 60 => 'French Horn',
|
rlm@3
|
419 61 => 'Brass Section',
|
rlm@3
|
420 62 => 'SynthBrass 1',
|
rlm@3
|
421 63 => 'SynthBrass 2',
|
rlm@3
|
422 64 => 'Soprano Sax',
|
rlm@3
|
423 65 => 'Alto Sax',
|
rlm@3
|
424 66 => 'Tenor Sax',
|
rlm@3
|
425 67 => 'Baritone Sax',
|
rlm@3
|
426 68 => 'Oboe',
|
rlm@3
|
427 69 => 'English Horn',
|
rlm@3
|
428 70 => 'Bassoon',
|
rlm@3
|
429 71 => 'Clarinet',
|
rlm@3
|
430 72 => 'Piccolo',
|
rlm@3
|
431 73 => 'Flute',
|
rlm@3
|
432 74 => 'Recorder',
|
rlm@3
|
433 75 => 'Pan Flute',
|
rlm@3
|
434 76 => 'Blown Bottle',
|
rlm@3
|
435 77 => 'Shakuhachi',
|
rlm@3
|
436 78 => 'Whistle',
|
rlm@3
|
437 79 => 'Ocarina',
|
rlm@3
|
438 80 => 'Lead 1 (square)',
|
rlm@3
|
439 81 => 'Lead 2 (sawtooth)',
|
rlm@3
|
440 82 => 'Lead 3 (calliope)',
|
rlm@3
|
441 83 => 'Lead 4 (chiff)',
|
rlm@3
|
442 84 => 'Lead 5 (charang)',
|
rlm@3
|
443 85 => 'Lead 6 (voice)',
|
rlm@3
|
444 86 => 'Lead 7 (fifths)',
|
rlm@3
|
445 87 => 'Lead 8 (bass + lead)',
|
rlm@3
|
446 88 => 'Pad 1 (new age)',
|
rlm@3
|
447 89 => 'Pad 2 (warm)',
|
rlm@3
|
448 90 => 'Pad 3 (polysynth)',
|
rlm@3
|
449 91 => 'Pad 4 (choir)',
|
rlm@3
|
450 92 => 'Pad 5 (bowed)',
|
rlm@3
|
451 93 => 'Pad 6 (metallic)',
|
rlm@3
|
452 94 => 'Pad 7 (halo)',
|
rlm@3
|
453 95 => 'Pad 8 (sweep)',
|
rlm@3
|
454 96 => 'FX 1 (rain)',
|
rlm@3
|
455 97 => 'FX 2 (soundtrack)',
|
rlm@3
|
456 98 => 'FX 3 (crystal)',
|
rlm@3
|
457 99 => 'FX 4 (atmosphere)',
|
rlm@3
|
458 100 => 'FX 5 (brightness)',
|
rlm@3
|
459 101 => 'FX 6 (goblins)',
|
rlm@3
|
460 102 => 'FX 7 (echoes)',
|
rlm@3
|
461 103 => 'FX 8 (sci-fi)',
|
rlm@3
|
462 104 => 'Sitar',
|
rlm@3
|
463 105 => 'Banjo',
|
rlm@3
|
464 106 => 'Shamisen',
|
rlm@3
|
465 107 => 'Koto',
|
rlm@3
|
466 108 => 'Kalimba',
|
rlm@3
|
467 109 => 'Bagpipe',
|
rlm@3
|
468 110 => 'Fiddle',
|
rlm@3
|
469 111 => 'Shanai',
|
rlm@3
|
470 112 => 'Tinkle Bell',
|
rlm@3
|
471 113 => 'Agogo',
|
rlm@3
|
472 114 => 'Steel Drums',
|
rlm@3
|
473 115 => 'Woodblock',
|
rlm@3
|
474 116 => 'Taiko Drum',
|
rlm@3
|
475 117 => 'Melodic Tom',
|
rlm@3
|
476 118 => 'Synth Drum',
|
rlm@3
|
477 119 => 'Reverse Cymbal',
|
rlm@3
|
478 120 => 'Guitar Fret Noise',
|
rlm@3
|
479 121 => 'Breath Noise',
|
rlm@3
|
480 122 => 'Seashore',
|
rlm@3
|
481 123 => 'Bird Tweet',
|
rlm@3
|
482 124 => 'Telephone Ring',
|
rlm@3
|
483 125 => 'Helicopter',
|
rlm@3
|
484 126 => 'Applause',
|
rlm@3
|
485 127 => 'Gunshot'
|
rlm@3
|
486 );
|
rlm@3
|
487
|
rlm@3
|
488 return @$lookup[$instrument_id];
|
rlm@3
|
489 }
|
rlm@3
|
490
|
rlm@3
|
491
|
rlm@3
|
492
|
rlm@3
|
493 public static function GeneralMIDIpercussionLookup($instrument_id) {
|
rlm@3
|
494
|
rlm@3
|
495 static $lookup = array (
|
rlm@3
|
496
|
rlm@3
|
497 35 => 'Acoustic Bass Drum',
|
rlm@3
|
498 36 => 'Bass Drum 1',
|
rlm@3
|
499 37 => 'Side Stick',
|
rlm@3
|
500 38 => 'Acoustic Snare',
|
rlm@3
|
501 39 => 'Hand Clap',
|
rlm@3
|
502 40 => 'Electric Snare',
|
rlm@3
|
503 41 => 'Low Floor Tom',
|
rlm@3
|
504 42 => 'Closed Hi-Hat',
|
rlm@3
|
505 43 => 'High Floor Tom',
|
rlm@3
|
506 44 => 'Pedal Hi-Hat',
|
rlm@3
|
507 45 => 'Low Tom',
|
rlm@3
|
508 46 => 'Open Hi-Hat',
|
rlm@3
|
509 47 => 'Low-Mid Tom',
|
rlm@3
|
510 48 => 'Hi-Mid Tom',
|
rlm@3
|
511 49 => 'Crash Cymbal 1',
|
rlm@3
|
512 50 => 'High Tom',
|
rlm@3
|
513 51 => 'Ride Cymbal 1',
|
rlm@3
|
514 52 => 'Chinese Cymbal',
|
rlm@3
|
515 53 => 'Ride Bell',
|
rlm@3
|
516 54 => 'Tambourine',
|
rlm@3
|
517 55 => 'Splash Cymbal',
|
rlm@3
|
518 56 => 'Cowbell',
|
rlm@3
|
519 57 => 'Crash Cymbal 2',
|
rlm@3
|
520 59 => 'Ride Cymbal 2',
|
rlm@3
|
521 60 => 'Hi Bongo',
|
rlm@3
|
522 61 => 'Low Bongo',
|
rlm@3
|
523 62 => 'Mute Hi Conga',
|
rlm@3
|
524 63 => 'Open Hi Conga',
|
rlm@3
|
525 64 => 'Low Conga',
|
rlm@3
|
526 65 => 'High Timbale',
|
rlm@3
|
527 66 => 'Low Timbale',
|
rlm@3
|
528 67 => 'High Agogo',
|
rlm@3
|
529 68 => 'Low Agogo',
|
rlm@3
|
530 69 => 'Cabasa',
|
rlm@3
|
531 70 => 'Maracas',
|
rlm@3
|
532 71 => 'Short Whistle',
|
rlm@3
|
533 72 => 'Long Whistle',
|
rlm@3
|
534 73 => 'Short Guiro',
|
rlm@3
|
535 74 => 'Long Guiro',
|
rlm@3
|
536 75 => 'Claves',
|
rlm@3
|
537 76 => 'Hi Wood Block',
|
rlm@3
|
538 77 => 'Low Wood Block',
|
rlm@3
|
539 78 => 'Mute Cuica',
|
rlm@3
|
540 79 => 'Open Cuica',
|
rlm@3
|
541 80 => 'Mute Triangle',
|
rlm@3
|
542 81 => 'Open Triangle'
|
rlm@3
|
543 );
|
rlm@3
|
544
|
rlm@3
|
545 return @$lookup[$instrument_id];
|
rlm@3
|
546 }
|
rlm@3
|
547
|
rlm@3
|
548
|
rlm@3
|
549 }
|
rlm@3
|
550
|
rlm@3
|
551
|
rlm@3
|
552 ?> |