/** * @param Track $track * @return integer Clef of $track */ public function getClef(Track $track) { if (!$this->isPercussionChannel($track->getSong(), $track->getChannelId())) { $strings = $track->getStrings(); foreach ($strings as $string) { if ($string->getValue() <= 34) { return Measure::CLEF_BASS; } } } return Measure::CLEF_TREBLE; }
private function writeTrack(Track $track) { $channel = $this->getChannelRoute($track->getChannelId()); $flags = 0; if ($this->isPercussionChannel($track->getSong(), $track->getChannelId())) { $flags |= 0x1; } $this->writeUnsignedByte($flags); $this->writeStringByte($track->getName(), 40); $this->writeInt(count($track->getStrings())); for ($i = 0; $i < 7; $i++) { $value = 0; if (count($track->getStrings()) > $i) { $string = $track->getStrings()[$i]; $value = $string->getValue(); } $this->writeInt($value); } $this->writeInt(1); $this->writeInt($channel->getChannel1() + 1); $this->writeInt($channel->getChannel2() + 1); $this->writeInt(24); $this->writeInt(min(max($track->getOffset(), 0), 12)); $this->writeColor($track->getColor()); }
private function createTrack(MidiSequenceHelper $helper, Track $track) { $channel = $this->song->getChannelById($track->getChannelId()); if ($channel !== null) { $previous = null; $this->addBend($helper, $track->getNumber(), Duration::QUARTER_TIME, self::DEFAULT_BEND, $channel->getChannelId(), false); $this->makeChannel($helper, $channel, $track->getNumber()); $mCount = count($helper->getMeasureHelpers()); for ($mIndex = 0; $mIndex < $mCount; $mIndex++) { $measureHelper = $helper->getMeasureHelper($mIndex); $measure = $track->getMeasure($measureHelper->getIndex()); if ($track->getNumber() == 1) { $this->addTimeSignature($helper, $measure, $previous, $measureHelper->getMove()); $this->addTempo($helper, $measure, $previous, $measureHelper->getMove()); $this->addMetronome($helper, $measure->getHeader(), $measureHelper->getMove()); } $this->makeBeats($helper, $channel, $track, $measure, $mIndex, $measureHelper->getMove()); $previous = $measure; } } }
private function writeTrack(Track $track) { $channel = $this->getChannelRoute($track->getChannelId()); $flags = 0; if ($this->isPercussionChannel($track->getSong(), $track->getChannelId())) { $flags |= 0x1; } $this->writeUnsignedByte($flags); $this->writeUnsignedByte(8 | $flags); $this->writeStringByte($track->getName(), 40); $this->writeInt(count($track->getStrings())); for ($i = 0; $i < 7; $i++) { $value = 0; if (count($track->getStrings()) > $i) { $string = $track->getStrings()[$i]; $value = $string->getValue(); } $this->writeInt($value); } $this->writeInt(1); $this->writeInt($channel->getChannel1() + 1); $this->writeInt($channel->getChannel2() + 1); $this->writeInt(24); $this->writeInt($track->getOffset()); $this->writeColor($track->getColor()); $this->writeBytes(array(67, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1)); }