Exemple #1
0
 public function testGetDrumNoteName()
 {
     $drumNoteMap = array(35 => 'AcousticBassDrum', 36 => 'BassDrum1', 37 => 'SideStick', 38 => 'AcousticSnare', 39 => 'HandClap', 40 => 'ElectricSnare', 41 => 'LowFloorTom', 42 => 'ClosedHiHat', 43 => 'HighFloorTom', 44 => 'PedalHiHat', 45 => 'LowTom', 46 => 'OpenHiHat', 47 => 'LowMidTom', 48 => 'HiMidTom', 49 => 'CrashCymbal1', 50 => 'HighTom', 51 => 'RideCymbal1', 52 => 'ChineseCymbal', 53 => 'RideBell', 54 => 'Tambourine', 55 => 'SplashCymbal', 56 => 'Cowbell', 57 => 'CrashCymbal2', 58 => 'Vibraslap', 59 => 'RideCymbal2', 60 => 'HiBongo', 61 => 'LowBongo', 62 => 'MuteHiConga', 63 => 'OpenHiConga', 64 => 'LowConga', 65 => 'HighTimbale', 66 => 'LowTimbale', 67 => 'HighAgogo', 68 => 'LowAgogo', 69 => 'Cabasa', 70 => 'Maracas', 71 => 'ShortWhistle', 72 => 'LongWhistle', 73 => 'ShortGuiro', 74 => 'LongGuiro', 75 => 'Claves', 76 => 'HiWoodBlock', 77 => 'LowWoodBlock', 78 => 'MuteCuica', 79 => 'OpenCuica', 80 => 'MuteTriangle', 81 => 'OpenTriangle', 82 => 'Shaker');
     foreach ($drumNoteMap as $note => $name) {
         $this->assertEquals(Note::getDrumNoteName($note), $name);
     }
 }
Exemple #2
0
 /**
  * @since 1.0
  * @uses  Note::getNoteName()
  * 
  * @return string
  */
 public function getParamDescription()
 {
     return Note::getNoteName($this->param1) . ' with velocity ' . $this->param2;
 }
Exemple #3
0
<?php

require_once dirname(dirname(__FILE__)) . '/vendor/autoload.php';
use Tmont\Midi\Parsing\FileParser;
use Tmont\Midi\Event;
use Tmont\Midi\Util\Note;
$file = dirname(__FILE__) . '/And_We_Die_Young.mid';
$parser = new FileParser();
$parser->load($file);
$currentTrackName = null;
while ($chunk = $parser->parse()) {
    if ($chunk instanceof Event\TrackNameEvent) {
        $currentTrackName = $chunk->getParamDescription();
    } else {
        if ($chunk instanceof Event\NoteOnEvent) {
            list($channel, $noteNumber, $velocity) = $chunk->getData();
            if ($velocity) {
                //MIDI generators often use a NOTE ON event with a velocity of 0
                //to stop playing a note in lieu of a NOTE OFF event
                $noteName = Note::getNoteName($noteNumber);
                echo $currentTrackName . ': [' . $channel . '] ' . $noteName . ' (velocity=' . $velocity . ')' . PHP_EOL;
            }
        }
    }
}