コード例 #1
0
 public function addMetronome(MidiSequenceHelper $sHelper, MeasureHeader $header, $startMove)
 {
     if (($this->flags & MidiWriter::ADD_METRONOME) != 0) {
         if ($this->metronomeChannelId >= 0) {
             $start = $startMove + $header->getStart();
             $length = $header->getTimeSignature()->getDenominator()->getTime();
             for ($i = 1; $i <= $header->getTimeSignature()->getNumerator(); $i++) {
                 $this->makeNote($sHelper, $this->getMetronomeTrack(), self::DEFAULT_METRONOME_KEY, $start, $length, Velocities::_DEFAULT, $this->metronomeChannelId, false);
                 $start += $length;
             }
         }
     }
 }
コード例 #2
0
ファイル: MidiReader.php プロジェクト: stdtabs/phptabs
 private function getHeader($tick)
 {
     $realTick = $tick >= Duration::QUARTER_TIME ? $tick : Duration::QUARTER_TIME;
     foreach ($this->headers as $header) {
         if ($realTick >= $header->getStart() && $realTick < $header->getStart() + $header->getLength()) {
             return $header;
         }
     }
     $last = $this->getLastHeader();
     $header = new MeasureHeader();
     $header->setNumber($last !== null ? $last->getNumber() + 1 : 1);
     $header->setStart($last !== null ? $last->getStart() + $last->getLength() : Duration::QUARTER_TIME);
     $header->getTempo()->setValue($last !== null ? $last->getTempo()->getValue() : 120);
     if ($last !== null) {
         $header->getTimeSignature()->copyFrom($last->getTimeSignature());
     } else {
         $header->getTimeSignature()->setNumerator(4);
         $header->getTimeSignature()->getDenominator()->setValue(Duration::QUARTER);
     }
     $this->headers[] = $header;
     if ($realTick >= $header->getStart() && $realTick < $header->getStart() + $header->getLength()) {
         return $header;
     }
     return $this->getHeader($realTick);
 }