コード例 #1
0
 /**
  * Reads some NoteEffect informations
  * 
  * @param Beat $beat
  * @param NoteEffect $effect
  */
 public function readBeatEffects(Beat $beat, NoteEffect $noteEffect)
 {
     $flags1 = $this->reader->readUnsignedByte();
     $flags2 = $this->reader->readUnsignedByte();
     $noteEffect->setFadeIn(($flags1 & 0x10) != 0);
     $noteEffect->setVibrato(($flags1 & 0x2) != 0);
     if (($flags1 & 0x20) != 0) {
         $effect = $this->reader->readUnsignedByte();
         $noteEffect->setTapping($effect == 1);
         $noteEffect->setSlapping($effect == 2);
         $noteEffect->setPopping($effect == 3);
     }
     if (($flags2 & 0x4) != 0) {
         $this->reader->factory('GuitarPro4Effects')->readTremoloBar($noteEffect);
     }
     if (($flags1 & 0x40) != 0) {
         $factory = $this->getParserName() == 'GuitarPro5' ? 'GuitarPro5' : 'GuitarPro3';
         $this->reader->factory($factory . 'Stroke')->readStroke($beat);
     }
     if (($flags2 & 0x2) != 0) {
         $this->reader->readByte();
     }
 }
コード例 #2
0
ファイル: GuitarPro5Writer.php プロジェクト: stdtabs/phptabs
 private function writeBeat(Voice $voice, Beat $beat, Measure $measure, $changeTempo)
 {
     $duration = $voice->getDuration();
     $effect = new NoteEffect();
     for ($i = 0; $i < $voice->countNotes(); $i++) {
         $playedNote = $voice->getNote($i);
         if ($playedNote->getEffect()->isFadeIn()) {
             $effect->setFadeIn(true);
         }
         if ($playedNote->getEffect()->isTremoloBar()) {
             $effect->setTremoloBar(clone $playedNote->getEffect()->getTremoloBar());
         }
         if ($playedNote->getEffect()->isTapping()) {
             $effect->setTapping(true);
         }
         if ($playedNote->getEffect()->isSlapping()) {
             $effect->setSlapping(true);
         }
         if ($playedNote->getEffect()->isPopping()) {
             $effect->setPopping(true);
         }
     }
     $flags = 0;
     if ($duration->isDotted() || $duration->isDoubleDotted()) {
         $flags |= 0x1;
     }
     if ($voice->getIndex() == 0 && $beat->isChordBeat()) {
         $flags |= 0x2;
     }
     if ($voice->getIndex() == 0 && $beat->isTextBeat()) {
         $flags |= 0x4;
     }
     if ($beat->getStroke()->getDirection() != Stroke::STROKE_NONE) {
         $flags |= 0x8;
     } else {
         if ($effect->isTremoloBar() || $effect->isTapping() || $effect->isSlapping() || $effect->isPopping() || $effect->isFadeIn()) {
             $flags |= 0x8;
         }
     }
     if ($changeTempo) {
         $flags |= 0x10;
     }
     if (!$duration->getDivision()->isEqual(DivisionType::normal())) {
         $flags |= 0x20;
     }
     if ($voice->isEmpty() || $voice->isRestVoice()) {
         $flags |= 0x40;
     }
     $this->writeUnsignedByte($flags);
     if (($flags & 0x40) != 0) {
         $this->writeUnsignedByte($voice->isEmpty() ? 0 : 0x2);
     }
     $this->writeByte($this->parseDuration($duration));
     if (($flags & 0x20) != 0) {
         $this->writeInt($duration->getDivision()->getEnters());
     }
     if (($flags & 0x2) != 0) {
         $this->writeChord($beat->getChord());
     }
     if (($flags & 0x4) != 0) {
         $this->writeText($beat->getText());
     }
     if (($flags & 0x8) != 0) {
         $this->writeBeatEffects($beat, $effect);
     }
     if (($flags & 0x10) != 0) {
         $this->writeMixChange($measure->getTempo());
     }
     $stringFlags = 0;
     if (!$voice->isRestVoice()) {
         for ($i = 0; $i < $voice->countNotes(); $i++) {
             $playedNote = $voice->getNote($i);
             $string = 7 - $playedNote->getString();
             $stringFlags |= 1 << $string;
         }
     }
     $this->writeUnsignedByte($stringFlags);
     for ($i = 6; $i >= 0; $i--) {
         if (($stringFlags & 1 << $i) != 0) {
             for ($n = 0; $n < $voice->countNotes(); $n++) {
                 $playedNote = $voice->getNote($n);
                 if ($playedNote->getString() == 6 - $i + 1) {
                     $this->writeNote($playedNote);
                     break;
                 }
             }
         }
     }
     $this->skipBytes(2);
 }