<?php require_once 'IO/MIDI.php'; require_once 'IO/MIDI/GM.php'; $options = getopt("f:"); if (isset($options['f']) === false || is_readable($options['f']) === false) { echo "Usage: php midiinfo.php -f <midi_file>\n"; echo "ex) php midiinfo.php -f test.mid\n"; exit(1); } $mididata = file_get_contents($options['f']); $midi = new IO_MIDI(); $midi->parse($mididata); $header = $midi->header['header']; $tracks = $midi->tracks; echo "Header:" . PHP_EOL; echo " NumberOfTracks: " . $header['NumberOfTracks'] . PHP_EOL; echo " Division: " . $header['Division'] . PHP_EOL; echo "Tracks:" . PHP_EOL; foreach ($tracks as $idx => $track) { $channelTable = array(); $programTable = array(); $noteOnTable = array(); $noteOffTable = array(); $noteOnTable = array(); $noteKeyTable = array(); $pitchbendTable = array(); $pitchbendRangeTable = array(); $controllerTypeTable = array(); // echo " Track[{$idx}]:" . PHP_EOL;
<?php require_once 'IO/MIDI.php'; $options = getopt("f:v:c:"); $program_number = 0; if (isset($options['f']) === false || is_readable($options['f']) === false) { echo "Usage: php midiprogram.php -f <midi_file> -p <program_number>\n"; echo "ex) php midiprogram.php -f in.mid -p 0\n"; exit(1); } $velocity_number = isset($options['v']) ? (int) $options['v'] : 0; $channel_number = isset($options['c']) ? (int) $options['c'] : 0; $mididata = file_get_contents($options['f']); $midi = new IO_MIDI(); $midi->parse($mididata); $res = []; foreach ($midi->tracks as $key => &$value) { foreach ($value["track"] as $key2 => &$value2) { if (isset($value2["Velocity"]) && $value2["EventType"] === 9 && $value2["Velocity"] > 0) { if (0 === $channel_number || $value2["MIDIChannel"] === $channel_number) { $value2["Velocity"] = $velocity_number; } } } } unset($value); unset($value2); $opts = array(); //$opts['runningstatus'] = true; echo $midi->build($opts);
<?php require_once 'IO/MIDI.php'; $options = getopt("f:hvm"); if (isset($options['f']) === false || is_readable($options['f']) === false) { fprintf(STDERR, "Usage: php mididump.php -f <midi_file> [-h]\n"); fprintf(STDERR, "ex) php mididump.php -f test.mid -h \n"); exit(1); } $mididata = file_get_contents($options['f']); $midi = new IO_MIDI(); $midi->parse($mididata); $opts = array(); if (isset($options['h'])) { $opts['hexdump'] = true; } if (isset($options['v'])) { $opts['verbose'] = true; } if (isset($options['m'])) { // 小節 $opts['measure'] = true; } $midi->dump($opts);