Пример #1
0
 /**
  * Reads tremolo bar
  * 
  * @param NoteEffect $noteEffect
  */
 public function readTremoloBar(NoteEffect $effect)
 {
     $tremoloBar = new EffectTremoloBar();
     $this->reader->skip(5);
     $points = $this->reader->readInt();
     for ($i = 0; $i < $points; $i++) {
         $position = $this->reader->readInt();
         $value = $this->reader->readInt();
         $this->reader->readByte();
         $pointPosition = round($position * EffectTremoloBar::MAX_POSITION_LENGTH / GuitarProReaderInterface::GP_BEND_POSITION);
         $pointValue = round($value / (GuitarProReaderInterface::GP_BEND_SEMITONE * 2));
         $tremoloBar->addPoint($pointPosition, $pointValue);
     }
     if (count($tremoloBar->getPoints())) {
         $effect->setTremoloBar($tremoloBar);
     }
 }
Пример #2
0
 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);
 }
Пример #3
0
 /**
  * Reads tremolo bar
  * 
  * @param NoteEffect $noteEffect
  */
 public function readTremoloBar(NoteEffect $noteEffect)
 {
     $value = $this->reader->readInt();
     $effect = new EffectTremoloBar();
     $effect->addPoint(0, 0);
     $effect->addPoint(round(EffectTremoloBar::MAX_POSITION_LENGTH / 2), round(-($value / (GuitarProReaderInterface::GP_BEND_SEMITONE * 2))));
     $effect->addPoint(EffectTremoloBar::MAX_POSITION_LENGTH, 0);
     $noteEffect->setTremoloBar($effect);
 }