示例#1
0
 /**
  * Reads beat effects
  * 
  * @param Beat $beat
  * @param NoteEffect $effect
  */
 public function readBeatEffects(Beat $beat, NoteEffect $effect)
 {
     $flags = $this->reader->readUnsignedByte();
     $effect->setVibrato(($flags & 0x1) != 0 || ($flags & 0x2) != 0);
     $effect->setFadeIn(($flags & 0x10) != 0);
     if (($flags & 0x20) != 0) {
         $type = $this->reader->readUnsignedByte();
         if ($type == 0) {
             $this->reader->factory('GuitarPro3Effects')->readTremoloBar($effect);
         } else {
             $effect->setTapping($type == 1);
             $effect->setSlapping($type == 2);
             $effect->setPopping($type == 3);
             $this->reader->readInt();
         }
     }
     if (($flags & 0x40) != 0) {
         $this->reader->factory('GuitarPro3Stroke')->readStroke($beat);
     }
     if (($flags & 0x4) != 0) {
         $harmonic = new EffectHarmonic();
         $harmonic->setType(EffectHarmonic::TYPE_NATURAL);
         $effect->setHarmonic($harmonic);
     }
     if (($flags & 0x8) != 0) {
         $harmonic = new EffectHarmonic();
         $harmonic->setType(EffectHarmonic::TYPE_ARTIFICIAL);
         $harmonic->setData(0);
         $effect->setHarmonic($harmonic);
     }
 }
示例#2
0
 /**
  * Reads tremolo picking
  * 
  * @param NoteEffect $noteEffect
  */
 public function readTremoloPicking(NoteEffect $noteEffect)
 {
     $value = $this->reader->readUnsignedByte();
     $tremoloPicking = new EffectTremoloPicking();
     if ($value == 1) {
         $tremoloPicking->getDuration()->setValue(Duration::EIGHTH);
         $noteEffect->setTremoloPicking($tremoloPicking);
     } else {
         if ($value == 2) {
             $tremoloPicking->getDuration()->setValue(Duration::SIXTEENTH);
             $noteEffect->setTremoloPicking($tremoloPicking);
         } else {
             if ($value == 3) {
                 $tremoloPicking->getDuration()->setValue(Duration::THIRTY_SECOND);
                 $noteEffect->setTremoloPicking($tremoloPicking);
             }
         }
     }
 }
示例#3
0
 private function readHarmonic(NoteEffect $noteEffect)
 {
     $harmonic = new EffectHarmonic();
     $type = intval($this->reader->readByte());
     if ($type == 1) {
         $harmonic->setType(EffectHarmonic::TYPE_NATURAL);
     } else {
         if ($type == 3) {
             $harmonic->setType(EffectHarmonic::TYPE_TAPPED);
         } else {
             if ($type == 4) {
                 $harmonic->setType(EffectHarmonic::TYPE_PINCH);
             } else {
                 if ($type == 5) {
                     $harmonic->setType(EffectHarmonic::TYPE_SEMI);
                 } else {
                     if ($type == 15) {
                         $harmonic->setType(EffectHarmonic::TYPE_ARTIFICIAL);
                         $harmonic->setData(2);
                     } else {
                         if ($type == 17) {
                             $harmonic->setType(EffectHarmonic::TYPE_ARTIFICIAL);
                             $harmonic->setData(3);
                         } else {
                             if ($type == 22) {
                                 $harmonic->setType(EffectHarmonic::TYPE_ARTIFICIAL);
                                 $harmonic->setData(0);
                             }
                         }
                     }
                 }
             }
         }
     }
     $noteEffect->setHarmonic($harmonic);
 }
示例#4
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();
     }
 }
示例#5
0
 /**
  * Reads GraceEffect
  * 
  * @param NoteEffect $effect
  */
 public function readGrace(NoteEffect $effect)
 {
     $fret = $this->readUnsignedByte();
     $grace = new EffectGrace();
     $grace->setOnBeat(false);
     $grace->setDead($fret == 255);
     $grace->setFret(!$grace->isDead() ? $fret : 0);
     $grace->setDynamic(Velocities::MIN_VELOCITY + Velocities::VELOCITY_INCREMENT * $this->readUnsignedByte() - Velocities::VELOCITY_INCREMENT);
     $transition = $this->readUnsignedByte();
     if ($transition == 0) {
         $grace->setTransition(EffectGrace::TRANSITION_NONE);
     } else {
         if ($transition == 1) {
             $grace->setTransition(EffectGrace::TRANSITION_SLIDE);
         } else {
             if ($transition == 2) {
                 $grace->setTransition(EffectGrace::TRANSITION_BEND);
             } else {
                 if ($transition == 3) {
                     $grace->setTransition(EffectGrace::TRANSITION_HAMMER);
                 }
             }
         }
     }
     $grace->setDuration($this->readUnsignedByte());
     $effect->setGrace($grace);
 }
示例#6
0
 private function writeNoteEffects(NoteEffect $effect)
 {
     $flags = 0;
     if ($effect->isBend()) {
         $flags |= 0x1;
     }
     if ($effect->isHammer()) {
         $flags |= 0x2;
     }
     if ($effect->isSlide()) {
         $flags |= 0x4;
     }
     if ($effect->isLetRing()) {
         $flags |= 0x8;
     }
     if ($effect->isGrace()) {
         $flags |= 0x10;
     }
     $this->writeUnsignedByte($flags);
     if (($flags & 0x1) != 0) {
         $this->writeBend($effect->getBend());
     }
     if (($flags & 0x10) != 0) {
         $this->writeGrace($effect->getGrace());
     }
 }
示例#7
0
 private function writeNoteEffects(NoteEffect $effect)
 {
     $flags1 = 0;
     $flags2 = 0;
     if ($effect->isBend()) {
         $flags1 |= 0x1;
     }
     if ($effect->isHammer()) {
         $flags1 |= 0x2;
     }
     if ($effect->isLetRing()) {
         $flags1 |= 0x8;
     }
     if ($effect->isGrace()) {
         $flags1 |= 0x10;
     }
     if ($effect->isStaccato()) {
         $flags2 |= 0x1;
     }
     if ($effect->isPalmMute()) {
         $flags2 |= 0x2;
     }
     if ($effect->isTremoloPicking()) {
         $flags2 |= 0x4;
     }
     if ($effect->isSlide()) {
         $flags2 |= 0x8;
     }
     if ($effect->isHarmonic()) {
         $flags2 |= 0x10;
     }
     if ($effect->isTrill()) {
         $flags2 |= 0x20;
     }
     if ($effect->isVibrato()) {
         $flags2 |= 0x40;
     }
     $this->writeUnsignedByte($flags1);
     $this->writeUnsignedByte($flags2);
     if (($flags1 & 0x1) != 0) {
         $this->writeBend($effect->getBend());
     }
     if (($flags1 & 0x10) != 0) {
         $this->writeGrace($effect->getGrace());
     }
     if (($flags2 & 0x4) != 0) {
         $this->writeTremoloPicking($effect->getTremoloPicking());
     }
     if (($flags2 & 0x8) != 0) {
         $this->writeByte(1);
     }
     if (($flags2 & 0x10) != 0) {
         $this->writeByte(1);
     }
     if (($flags2 & 0x20) != 0) {
         $this->writeTrill($effect->getTrill());
     }
 }
示例#8
0
 /**
  * Reads EffectGrace
  * 
  * @param NoteEffect $effect
  */
 private function readGrace(NoteEffect $effect)
 {
     $fret = $this->reader->readUnsignedByte();
     $dynamic = $this->reader->readUnsignedByte();
     $transition = $this->reader->readByte();
     $duration = $this->reader->readUnsignedByte();
     $flags = $this->reader->readUnsignedByte();
     $grace = new EffectGrace();
     $grace->setFret($fret);
     $grace->setDynamic(Velocities::MIN_VELOCITY + Velocities::VELOCITY_INCREMENT * $dynamic - Velocities::VELOCITY_INCREMENT);
     $grace->setDuration($duration);
     $grace->setDead(($flags & 0x1) != 0);
     $grace->setOnBeat(($flags & 0x2) != 0);
     if ($transition == 0) {
         $grace->setTransition(EffectGrace::TRANSITION_NONE);
     } else {
         if ($transition == 1) {
             $grace->setTransition(EffectGrace::TRANSITION_SLIDE);
         } else {
             if ($transition == 2) {
                 $grace->setTransition(EffectGrace::TRANSITION_BEND);
             } else {
                 if ($transition == 3) {
                     $grace->setTransition(EffectGrace::TRANSITION_HAMMER);
                 }
             }
         }
     }
     $effect->setGrace($grace);
 }
示例#9
0
 private function writeNoteEffects(NoteEffect $effect)
 {
     $flags1 = 0;
     $flags2 = 0;
     if ($effect->isBend()) {
         $flags1 |= 0x1;
     }
     if ($effect->isHammer()) {
         $flags1 |= 0x2;
     }
     if ($effect->isLetRing()) {
         $flags1 |= 0x8;
     }
     if ($effect->isGrace()) {
         $flags1 |= 0x10;
     }
     if ($effect->isStaccato()) {
         $flags2 |= 0x1;
     }
     if ($effect->isPalmMute()) {
         $flags2 |= 0x2;
     }
     if ($effect->isTremoloPicking()) {
         $flags2 |= 0x4;
     }
     if ($effect->isSlide()) {
         $flags2 |= 0x8;
     }
     if ($effect->isVibrato()) {
         $flags2 |= 0x40;
     }
     if ($effect->isHarmonic()) {
         $flags2 |= 0x10;
     }
     if ($effect->isTrill()) {
         $flags2 |= 0x20;
     }
     $this->writeUnsignedByte($flags1);
     $this->writeUnsignedByte($flags2);
     if (($flags1 & 0x1) != 0) {
         $this->writeBend($effect->getBend());
     }
     if (($flags1 & 0x10) != 0) {
         $this->writeGrace($effect->getGrace());
     }
     if (($flags2 & 0x4) != 0) {
         $this->writeTremoloPicking($effect->getTremoloPicking());
     }
     if (($flags2 & 0x8) != 0) {
         $this->writeByte(1);
     }
     if (($flags2 & 0x10) != 0) {
         if ($effect->getHarmonic()->getType() == EffectHarmonic::TYPE_NATURAL) {
             $this->writeByte(1);
         } else {
             if ($effect->getHarmonic()->getType() == EffectHarmonic::TYPE_TAPPED) {
                 $this->writeByte(3);
             } else {
                 if ($effect->getHarmonic()->getType() == EffectHarmonic::TYPE_PINCH) {
                     $this->writeByte(4);
                 } else {
                     if ($effect->getHarmonic()->getType() == EffectHarmonic::TYPE_SEMI) {
                         $this->writeByte(5);
                     } else {
                         if ($effect->getHarmonic()->getType() == EffectHarmonic::TYPE_ARTIFICIAL) {
                             $this->writeByte(15);
                         }
                     }
                 }
             }
         }
     }
     if (($flags2 & 0x20) != 0) {
         $this->writeByte($effect->getTrill()->getFret());
         if ($effect->getTrill()->getDuration()->getValue() == Duration::SIXTEENTH) {
             $this->writeByte(1);
         } else {
             if ($effect->getTrill()->getDuration()->getValue() == Duration::THIRTY_SECOND) {
                 $this->writeByte(2);
             } else {
                 if ($effect->getTrill()->getDuration()->getValue() == Duration::SIXTY_FOURTH) {
                     $this->writeByte(3);
                 }
             }
         }
     }
 }
示例#10
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);
 }