</td></tr></table> </td> <td width=10> </td> <td valign="top"> <table width=140 border=0 cellpadding=2 cellspacing=0 bgcolor="#DADADA"> <tr bgcolor="#333333"><td colspan=7 style="color:#FFFFFF"><b>Published Mixes</b></td></tr> <tr><td> <?php $handle = opendir('mix'); while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { echo "<a href=\"sequencer.php?mix={$file}&plug={$plug}\">{$file}</a><br>\n"; } } closedir($handle); ?> <br> </td></tr></table> </td></tr></table> <?php if (isset($p['showTxt'])) { echo '<hr><pre>' . $midi->getTxt() . '</pre>'; } if (isset($p['showXml'])) { echo '<hr><pre>' . htmlspecialchars($midi->getXml()) . '</pre>'; } ?> </body> </html>
<?php $p = $_POST; $tt = isset($p['tt']) ? $p['tt'] : 0; $xm = isset($p['xm']) ? $p['xm'] : 0; $file = isset($_FILES['mid_upload']) && $_FILES['mid_upload']['tmp_name'] != '' ? $_FILES['mid_upload']['tmp_name'] : ''; if ($file != '') { require 'midi.class.php'; $midi = new Midi(); $midi->importMid($file); $xml = $midi->getXml($tt); $fn = $_FILES['mid_upload']['name']; $a = explode('.', $fn); array_pop($a); array_push($a, "xml"); $xn = implode('.', $a); //$xn = str_replace('.mid','.xml',$fn); if ($xm == 1) { header('Content-Type: application/octetstream'); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Disposition: attachment; filename="' . $xn . '"'); header('Pragma: no-cache'); echo $xml; exit; } } ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Midi2Xml</title>
private function getTracks() { if (!isset($privateData['tracks'])) { $fretIndex = array(60 => 'easy', 61 => 'easy', 62 => 'easy', 63 => 'easy', 64 => 'easy', 72 => 'medium', 73 => 'medium', 74 => 'medium', 75 => 'medium', 76 => 'medium', 84 => 'hard', 85 => 'hard', 86 => 'hard', 87 => 'hard', 88 => 'hard', 96 => 'expert', 97 => 'expert', 98 => 'expert', 99 => 'expert', 100 => 'expert'); $difficulties = array_unique(array_values($fretIndex)); $midi = new Midi(); // $midi->importMid( 'abeautifullie/notes.mid' ); // $midi->importMid( 'acdc_thunderstruck/notes.mid' ); $midi->importMid($this->directoryPath . DIRECTORY_SEPARATOR . 'notes.mid'); $xmlString = $midi->getXml(); $xml = simplexml_load_string($xmlString); foreach ($xml->Track as $track) { $trackName = (string) $track->Event[0]->TrackName; if (substr($trackName, 0, 5) == 'PART ') { $trackName = ucfirst(strtolower(substr($trackName, 5))); $parts[] = $trackName; // disabled difficulty levels for track $t0 = $track->xpath('Event[Absolute=0 and child::NoteOn]'); foreach ($t0 as $event) { $note = (int) $event->NoteOn[0]['Note']; if (!isset($disabled[$trackName])) { $disabled[$trackName] = array(); } // unknown note, let's skip it for now if (!isset($fretIndex[$note])) { break; } $difficulty = $fretIndex[$note]; if (!isset($disabled[$trackName][$difficulty])) { $disabled[$trackName][$difficulty] = array(); } $disabled[$trackName][$difficulty][$note] = true; } } } // display available difficulties for each track $tracks = array(); foreach ($parts as $track) { $trackDifficulties = array(); foreach ($difficulties as $difficulty) { if (!isset($disabled[$track][$difficulty])) { $trackDifficulties[] = $difficulty; } } if (count($trackDifficulties) > 0) { $currentTrack = new FOFSongTrack($track); $currentTrack->difficulties = $trackDifficulties; $tracks[] = $currentTrack; } } } return $privateData['tracks']; }