예제 #1
0
 if ($file != '') {
     $par_dir = getCode();
     // skopiowanie pliku
     $path = "../wap/get/" . $par_dir;
     // TODO: sprawdzi, czy taki kod już jest w filesystemie
     if (mkdir($path) == FALSE) {
         $reason = M1K0_REASON_NO_DIR;
         $par_request = NULL;
     } else {
         copy($file, $path . "/song.midi");
         require '../scripts/midi.class.php';
         require '../scripts/ConvertCharset.class.php';
         $NewEncoding = new ConvertCharset();
         $midi = new Midi();
         $midi->importMid($file, 0);
         $track = $midi->getTrack(0);
         // list of meta events that we are interested in (adjust!)
         $texttypes = array('Text', 'Copyright', 'TrkName', 'InstrName', 'Lyric', 'Marker', 'Cue');
         $lyric = array();
         // poustawianie czasów trwania
         foreach ($track as $msgStr) {
             //print_r($msgStr);
             $msg = explode(' ', $msgStr);
             if ($msg[1] == 'Meta' && in_array($msg[2], $texttypes)) {
                 $milis = (int) ($msg[0] * $midi->getTempo() / $midi->getTimebase() / 1000);
                 $text = $NewEncoding->Convert(substr($msgStr, strpos($msgStr, '"')), "windows-1250", "utf-8");
                 $text = str_replace("_", " ", $text);
                 $text = str_replace("\n", "/", $text);
                 $text = str_replace("\r", "/", $text);
                 $text = str_replace("//", "/", $text);
                 $text = str_replace("//", "/", $text);
예제 #2
0
?>
</select><br />
<input type="submit" value=" send " />
</div>
</form>
<?php 
if (@$file) {
    echo '<div style="margin-top:20px">File: ' . $_FILES['mid_upload']['name'];
    echo '<hr /><pre>';
    /****************************************************************************
    	MIDI CLASS CODE
    	****************************************************************************/
    require './classes/midi.class.php';
    $midi = new Midi();
    $midi->importMid($file);
    $track = $midi->getTrack((int) $_POST['track_num']);
    // list of meta events that we are interested in (adjust!)
    $texttypes = array('Text', 'Copyright', 'TrkName', 'InstrName', 'Lyric', 'Marker', 'Cue');
    $nothing = 1;
    foreach ($track as $msgStr) {
        $msg = explode(' ', $msgStr);
        if ($msg[1] == 'Meta' && in_array($msg[2], $texttypes)) {
            echo $msg[2] . ': ' . substr($msgStr, strpos($msgStr, '"')) . "\n";
            $nothing = 0;
        }
    }
    if ($nothing) {
        echo 'No events found!';
    }
    echo '</pre></div>';
}