예제 #1
0
 protected function isPercussionChannel(Song $song, $channelId)
 {
     $channels = $song->getChannels();
     foreach ($channels as $channel) {
         if ($channel->getChannelId() == $channelId) {
             return $channel->isPercussionChannel();
         }
     }
     return false;
 }
예제 #2
0
 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();
     }
 }
 /**
  * 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
 /**
  * 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
 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
 /**
  * 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
 /**
  * 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;
 }