コード例 #1
0
ファイル: GuitarProClef.php プロジェクト: stdtabs/phptabs
 protected function isPercussionChannel(Song $song, $channelId)
 {
     $channels = $song->getChannels();
     foreach ($channels as $channel) {
         if ($channel->getChannelId() == $channelId) {
             return $channel->isPercussionChannel();
         }
     }
     return false;
 }
コード例 #2
0
ファイル: MidiWriter.php プロジェクト: stdtabs/phptabs
 public function __construct(Song $song)
 {
     parent::__construct();
     # Build sequence
     $channelRouter = new ChannelRouter();
     $channelRouterConfigurator = new ChannelRouterConfigurator($channelRouter);
     $channelRouterConfigurator->configureRouter($song->getChannels());
     $settings = (new MidiSettings())->getdefaults();
     $midiSequenceParser = new MidiSequenceParser($song, self::ADD_FIRST_TICK_MOVE | self::ADD_DEFAULT_CONTROLS | self::ADD_MIXER_MESSAGES);
     $midiSequenceParser->setTranspose($settings->getTranspose());
     $midiSequenceParser->parse(new MidiSequenceHandler($song->countTracks() + 1, $channelRouter, $this));
 }
コード例 #3
0
 /**
  * Reads meta informations about tablature
  * 
  * @param Song $song
  */
 public function readInformations(Song $song)
 {
     $song->setName($this->reader->readStringByteSizeOfInteger());
     $this->reader->readStringByteSizeOfInteger();
     $song->setArtist($this->reader->readStringByteSizeOfInteger());
     $song->setAlbum($this->reader->readStringByteSizeOfInteger());
     $song->setAuthor($this->reader->readStringByteSizeOfInteger());
     $song->setCopyright($this->reader->readStringByteSizeOfInteger());
     $song->setWriter($this->reader->readStringByteSizeOfInteger());
     $song->setDate($this->reader->readStringByteSizeOfInteger());
     $comments = $this->reader->readInt();
     for ($i = 0; $i < $comments; $i++) {
         $song->setComments($song->getComments() . $this->reader->readStringByteSizeOfInteger());
     }
 }
コード例 #4
0
 public function __construct(Song $song, $sHeader, $eHeader)
 {
     $this->song = $song;
     $this->sHeader = $sHeader;
     $this->eHeader = $eHeader;
     $this->count = $song->countMeasureHeaders();
     $this->index = 0;
     $this->lastIndex = -1;
     $this->shouldPlay = true;
     $this->repeatOpen = true;
     $this->repeatAlternative = 0;
     $this->repeatStart = Duration::QUARTER_TIME;
     $this->repeatEnd = 0;
     $this->repeatMove = 0;
     $this->repeatStartIndex = 0;
     $this->repeatNumber = 0;
 }
コード例 #5
0
 /**
  * Loops on mesures to read
  * 
  * @param Song $song
  * @param integer $measures
  * @param integer $tracks
  * @param integer $tempoValue
  */
 public function readMeasures(Song $song, $measures, $tracks, $tempoValue)
 {
     $tempo = new Tempo();
     $tempo->setValue($tempoValue);
     $start = Duration::QUARTER_TIME;
     for ($i = 0; $i < $measures; $i++) {
         $header = $song->getMeasureHeader($i);
         $header->setStart($start);
         for ($j = 0; $j < $tracks; $j++) {
             $track = $song->getTrack($j);
             $measure = new Measure($header);
             $track->addMeasure($measure);
             $this->reader->factory('GuitarPro3Measure')->readMeasure($measure, $track, $tempo);
         }
         $header->getTempo()->copyFrom($tempo);
         $start += $header->getLength();
     }
 }
コード例 #6
0
 /**
  * Parses repeat alternative
  * 
  * @param Song $song
  * @param integer $measure
  * 
  * @return integer Number of repeat alternatives
  */
 public function parseRepeatAlternative(Song $song, $measure)
 {
     $value = $this->reader->readUnsignedByte();
     $repeatAlternative = 0;
     $existentAlternatives = 0;
     $headers = $song->getMeasureHeaders();
     foreach ($headers as $header) {
         if ($header->getNumber() == $measure) {
             break;
         }
         if ($header->isRepeatOpen()) {
             $existentAlternatives = 0;
         }
         $existentAlternatives |= $header->getRepeatAlternative();
     }
     for ($i = 0; $i < 8; $i++) {
         if ($value > $i && ($existentAlternatives & 1 << $i) == 0) {
             $repeatAlternative |= 1 << $i;
         }
     }
     return $repeatAlternative;
 }
コード例 #7
0
ファイル: GuitarPro4Reader.php プロジェクト: stdtabs/phptabs
 /**
  * Loops on mesure headers to read
  * 
  * @param Song $song
  * @param integer $count
  */
 private function readMeasureHeaders(Song $song, $count)
 {
     $timeSignature = new TimeSignature();
     for ($i = 0; $i < $count; $i++) {
         $song->addMeasureHeader($this->factory('GuitarPro3MeasureHeader')->readMeasureHeader($i + 1, $song, $timeSignature));
     }
 }
コード例 #8
0
ファイル: GuitarPro3Writer.php プロジェクト: stdtabs/phptabs
 private function writeTracks(Song $song)
 {
     for ($i = 0; $i < $song->countTracks(); $i++) {
         $track = $song->getTrack($i);
         $this->writeTrack($track);
     }
 }
コード例 #9
0
 public function addDefaultMessages(MidiSequenceHelper $sHelper, Song $song)
 {
     if (($this->flags & MidiWriter::ADD_DEFAULT_CONTROLS) != 0) {
         $channels = $song->getChannels();
         foreach ($channels as $channel) {
             $channelId = $channel->getChannelId();
             $sHelper->getSequence()->addControlChange($this->getTick(Duration::QUARTER_TIME), $this->getInfoTrack(), $channelId, MidiWriter::RPN_MSB, 0);
             $sHelper->getSequence()->addControlChange($this->getTick(Duration::QUARTER_TIME), $this->getInfoTrack(), $channelId, MidiWriter::RPN_LSB, 0);
             $sHelper->getSequence()->addControlChange($this->getTick(Duration::QUARTER_TIME), $this->getInfoTrack(), $channelId, MidiWriter::DATA_ENTRY_MSB, 12);
             $sHelper->getSequence()->addControlChange($this->getTick(Duration::QUARTER_TIME), $this->getInfoTrack(), $channelId, MidiWriter::DATA_ENTRY_LSB, 0);
         }
     }
 }
コード例 #10
0
 protected function configureChannelRouter(Song $song)
 {
     $this->channelRouter = new ChannelRouter();
     $routerConfigurator = new ChannelRouterConfigurator($this->channelRouter);
     $routerConfigurator->configureRouter($song->getChannels());
 }
コード例 #11
0
ファイル: GuitarPro3Reader.php プロジェクト: stdtabs/phptabs
 /**
  * Loops on tracks to read
  * 
  * @param Song $song
  * @param int $count
  * @param array $channels Current array of channels
  */
 private function readTracks(Song $song, $count, array $channels)
 {
     for ($number = 1; $number <= $count; $number++) {
         $song->addTrack($this->factory('GuitarPro3Track')->readTrack($song, $number, $channels));
     }
 }
コード例 #12
0
ファイル: GuitarProChannel.php プロジェクト: stdtabs/phptabs
 /**
  * Checks if a channel is still defined
  *
  * @param Song $song
  * @param string $name
  * @return boolean Result of the search
  */
 protected function findChannelsByName(Song $song, $name)
 {
     $channels = $song->getChannels();
     foreach ($channels as $v) {
         if ($v->getName() == $name) {
             return true;
         }
     }
     return false;
 }