public function getIncrementTime(Beat $beat) { $duration = 0; if ($this->value > 0) { for ($v = 0; $v < $beat->countVoices(); $v++) { $voice = $beat->getVoice($v); if (!$voice->isEmpty()) { $currentDuration = $voice->getDuration()->getTime(); if ($duration == 0 || $currentDuration < $duration) { $duration = $currentDuration <= Duration::QUARTER_TIME ? $currentDuration : Duration::QUARTER_TIME; } } } if ($duration > 0) { return round($duration / 8.0 * (4.0 / $this->value)); } } return 0; }
public function __construct($config = []) { \Beat::$app = $this; $this->setProperties($config); }
public function getBeatByStart($start) { $beatCount = $this->countBeats(); for ($i = 0; $i < $beatCount; $i++) { $beat = $this->getBeat($i); if ($beat->getStart() == $start) { return $beat; } } $beat = new Beat(); $beat->setStart($start); $this->addBeat($beat); return $beat; }
public function __clone() { $beat = new Beat(); $beat->setStart($this->getStart()); $beat->getStroke()->copyFrom($this->getStroke()); for ($i = 0; $i < count($this->voices); $i++) { $beat->setVoice($i, clone $this->voices[$i]); } if ($this->chord != null) { $beat->setChord(clone $this->chord); } if ($this->text != null) { $beat->setText(clone $this->text); } return $beat; }