示例#1
0
 /**
  * Reads Duration
  *
  * @param byte $flags unsigned bytes
  * @return Duration
  */
 public function readDuration($flags)
 {
     $duration = new Duration();
     $duration->setValue(pow(2, $this->reader->readByte() + 4) / 4);
     $duration->setDotted(($flags & 0x1) != 0);
     if (($flags & 0x20) != 0) {
         $divisionType = $this->reader->readInt();
         switch ($divisionType) {
             case 3:
                 $duration->getDivision()->setEnters(3);
                 $duration->getDivision()->setTimes(2);
                 break;
             case 5:
                 $duration->getDivision()->setEnters(5);
                 $duration->getDivision()->setTimes(4);
                 break;
             case 6:
                 $duration->getDivision()->setEnters(6);
                 $duration->getDivision()->setTimes(4);
                 break;
             case 7:
                 $duration->getDivision()->setEnters(7);
                 $duration->getDivision()->setTimes(4);
                 break;
             case 9:
                 $duration->getDivision()->setEnters(9);
                 $duration->getDivision()->setTimes(8);
                 break;
             case 10:
                 $duration->getDivision()->setEnters(10);
                 $duration->getDivision()->setTimes(8);
                 break;
             case 11:
                 $duration->getDivision()->setEnters(11);
                 $duration->getDivision()->setTimes(8);
                 break;
             case 12:
                 $duration->getDivision()->setEnters(12);
                 $duration->getDivision()->setTimes(8);
                 break;
         }
     }
     return $duration;
 }
示例#2
0
 private function newDuration($value)
 {
     $duration = new Duration();
     $duration->setValue($value);
     return $duration;
 }
示例#3
0
 private function makeNote($tick, $track, $channel, $value)
 {
     $tempNote = $this->getTempNote($track, $channel, $value, true);
     if ($tempNote !== null) {
         $nString = 0;
         $nValue = $tempNote->getValue() + $this->settings->getTranspose();
         $nVelocity = $tempNote->getVelocity();
         $nStart = $tempNote->getTick();
         $minDuration = new Duration();
         $minDuration->setValue(Duration::SIXTY_FOURTH);
         $nDuration = Duration::fromTime($tick - $tempNote->getTick(), $minDuration);
         $measure = $this->getMeasure($this->getTrack($track), $tempNote->getTick());
         $beat = $measure->getBeatByStart($nStart);
         $beat->getVoice(0)->getDuration()->copyFrom($nDuration);
         $note = new Note();
         $note->setValue($nValue);
         $note->setString($nString);
         $note->setVelocity($nVelocity);
         // Effect Bends / Vibrato
         if ($tempNote->countPitchBends() > 0) {
             $this->makeNoteEffect($note, $tempNote->getPitchBends());
         }
         $beat->getVoice(0)->addNote($note);
     }
 }