예제 #1
0
    echo isset($p['show']) ? ' checked' : '';
    ?>
>show MIDI result as Text
<br><br>
<input type="submit" value=" PLAY! ">
</form>
<?php 
    $new = 'tmp/~' . rand() . '.mid';
    if (isset($p['up'])) {
        $midi->transpose(12);
    }
    if (isset($p['down'])) {
        $midi->transpose(-12);
    }
    if (isset($p['double'])) {
        $midi->setTempo($midi->getTempo() / 2);
    }
    if (isset($p['half'])) {
        $midi->setTempo($midi->getTempo() * 2);
    }
    if (isset($p['solo'])) {
        $midi->soloTrack($p['soloTrackNum']);
    }
    if (isset($p['delete'])) {
        $midi->deleteTrack($p['delTrackNum']);
    }
    if (isset($p['insert'])) {
        $midi->insertMsg(0, "0 On ch=10 n=39 v=127");
        $midi->insertMsg(0, "120 On ch=10 n=39 v=127");
        $midi->insertMsg(0, "240 On ch=10 n=39 v=127");
    }
예제 #2
0
 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);
         $text = substr($text, 1, strlen($text) - 2);
         array_push($lyric, array($milis, 0, $text));
     }
 }
 define("SYLABE_TIME_MIN", 50);
 define("SYLABE_TIME_MAX", 1000);
 define("SYLABE_GAP_MIN", 100);
 $oldObjs = null;
 foreach ($lyric as $arrKey => $newObjs) {
예제 #3
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);