예제 #1
0
require __DIR__ . "/../../vendor/autoload.php";
require __DIR__ . "/../../src/MIDI/midi.class.php";
$admin = new LTE\AdminLte2();
$admin->title("MIDI");
echo $admin;
?>
<section class="container">
<?php 
$midi = new Midi();
$files = glob(__DIR__ . "/../../midifiles/*.mid");
shuffle($files);
$file = $files[0];
$midi->importMid($file);
$track = $midi->getTrack(0);
echo "<h1>" . basename($file) . "</h1>\n";
echo "<pre>";
$tempo = $midi->getTempo();
$bpm = $midi->getBpm();
//returns tempo as beats per minute (0 if tempo not set).
$timebase = $midi->getTimebase();
//returns timebase value.
$trackCount = $midi->getTrackCount();
//returns number of tracks.
$duration = $midi->getDuration();
//in sec
echo "tempo={$tempo}\n";
echo "BPM={$bpm}\n";
echo "duration={$duration} sec\n";
echo "timebase={$timebase}\n";
echo "trackCount={$trackCount}\n";
//print_r($track);
예제 #2
0
option {font-family:arial;font-size:11px}
</style>
</head>
<body>
<form enctype="multipart/form-data" action="manipulate.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="1048576"><!-- 1 MB -->
MIDI file (*.mid) to upload: <input type="file" name="mid_upload">
<input type="submit" value=" send ">
</form>
<hr>
<?php 
if (isset($file)) {
    $plug = isset($p['plug']) ? $p['plug'] : 'wm';
    $midi = new Midi();
    $midi->importMid($file);
    $tc = $midi->getTrackCount();
    ?>
<form action="manipulate.php" method="POST">
<input type="hidden" name="file" value="<?php 
    echo isset($file) ? $file : '';
    ?>
">
<input type="radio" name="plug" value="bk"<?php 
    echo $plug == 'bk' ? ' checked' : '';
    ?>
>Beatnik
<input type="radio" name="plug" value="qt"<?php 
    echo $plug == 'qt' ? ' checked' : '';
    ?>
>QuickTime
<input type="radio" name="plug" value="wm"<?php 
예제 #3
0
         //returns timebase value.
         $f['trackCount'] = $midi->getTrackCount();
         //returns number of tracks.
         $dat['files'][] = $f;
     }
     exit(json_encode($dat));
 case 'fileInfo':
     $dat['post'] = $_POST;
     $midi = new Midi();
     $midi->importMid(__DIR__ . "/../../midifiles/" . $_POST['filename']);
     //$track = $midi->getTrack(0);
     $dat['bpm'] = $midi->getBpm();
     //returns tempo as beats per minute (0 if tempo not set).
     $dat['timebase'] = $midi->getTimebase();
     //returns timebase value.
     $dat['trackCount'] = $midi->getTrackCount();
     //returns number of tracks.
     $track = $midi->getTrack(0);
     // list of meta events that we are interested in (adjust!)
     //$texttypes = array('Text','Copyright','TrkName','InstrName','Lyric','Marker','Cue');
     $texttypes = array('TrkName');
     foreach ($track as $msgStr) {
         $msg = explode(' ', $msgStr);
         if ($msg[1] == 'Meta' && $msg[2] == 'TrkName') {
             //print_r($msgStr);//ex : 0 Meta TrkName "A Message to Rudy by THE SPECIALS"
             //$dat['meta'][]=$msg[2].': '.substr($msgStr,strpos($msgStr,'"'));
             $dat['trackName'] = trim(explode('TrkName', $msgStr)[1]);
         }
     }
     exit(json_encode($dat));
 default: