Esempio n. 1
0
 /**
  * @param integer $string String on which note has started
  * @param Track $track
  *
  * @return integer tied note value
  */
 public function getTiedNoteValue($string, Track $track)
 {
     $measureCount = $track->countMeasures();
     if ($measureCount > 0) {
         for ($m = $measureCount - 1; $m >= 0; $m--) {
             $measure = $track->getMeasure($m);
             for ($b = $measure->countBeats() - 1; $b >= 0; $b--) {
                 $beat = $measure->getBeat($b);
                 $voice = $beat->getVoice(0);
                 for ($n = 0; $n < $voice->countNotes(); $n++) {
                     $note = $voice->getNote($n);
                     if ($note->getString() == $string) {
                         return $note->getValue();
                     }
                 }
             }
         }
     }
     return -1;
 }
Esempio n. 2
0
 private function getMeasure(Track $track, $tick)
 {
     $realTick = $tick >= Duration::QUARTER_TIME ? $tick : Duration::QUARTER_TIME;
     $measures = $track->getMeasures();
     foreach ($measures as $measure) {
         if ($realTick >= $measure->getStart() && $realTick < $measure->getStart() + $measure->getLength()) {
             return $measure;
         }
     }
     $this->getHeader($realTick);
     for ($i = 0; $i < count($this->headers); $i++) {
         $exist = false;
         $header = $this->headers[$i];
         $measureCount = $track->countMeasures();
         for ($j = 0; $j < $measureCount; $j++) {
             $measure = $track->getMeasure($j);
             if ($measure->getHeader() == $header) {
                 $exist = true;
             }
         }
         if (!$exist) {
             $measure = new Measure($header);
             $track->addMeasure($measure);
         }
     }
     return $this->getMeasure($track, $realTick);
 }