Exemplo n.º 1
0
 /**
  * Reads a note
  * 
  * @param TabString $string
  * @param track $track
  * @param NoteEffect $effect
  * @return Note
  */
 public function readNote(TabString $string, Track $track, NoteEffect $effect)
 {
     $flags = $this->reader->readUnsignedByte();
     $note = new Note();
     $note->setString($string->getNumber());
     $note->setEffect($effect);
     $note->getEffect()->setAccentuatedNote(($flags & 0x40) != 0);
     $note->getEffect()->setGhostNote(($flags & 0x4) != 0);
     if (($flags & 0x20) != 0) {
         $noteType = $this->reader->readUnsignedByte();
         $note->setTiedNote($noteType == 0x2);
         $note->getEffect()->setDeadNote($noteType == 0x3);
     }
     if (($flags & 0x1) != 0) {
         $this->reader->skip(2);
     }
     if (($flags & 0x10) != 0) {
         $note->setVelocity(Velocities::MIN_VELOCITY + Velocities::VELOCITY_INCREMENT * $this->reader->readByte() - Velocities::VELOCITY_INCREMENT);
     }
     if (($flags & 0x20) != 0) {
         $fret = $this->reader->readByte();
         $value = $note->isTiedNote() ? $this->reader->factory('GuitarPro3TiedNote')->getTiedNoteValue($string->getNumber(), $track) : $fret;
         $note->setValue($value >= 0 && $value < 100 ? $value : 0);
     }
     if (($flags & 0x80) != 0) {
         $this->reader->skip(2);
     }
     if (($flags & 0x8) != 0) {
         $this->reader->factory('GuitarPro4NoteEffects')->readNoteEffects($note->getEffect());
     }
     return $note;
 }
Exemplo n.º 2
0
 private function makeNote($tick, $track, $channel, $value)
 {
     $tempNote = $this->getTempNote($track, $channel, $value, true);
     if ($tempNote !== null) {
         $nString = 0;
         $nValue = $tempNote->getValue() + $this->settings->getTranspose();
         $nVelocity = $tempNote->getVelocity();
         $nStart = $tempNote->getTick();
         $minDuration = new Duration();
         $minDuration->setValue(Duration::SIXTY_FOURTH);
         $nDuration = Duration::fromTime($tick - $tempNote->getTick(), $minDuration);
         $measure = $this->getMeasure($this->getTrack($track), $tempNote->getTick());
         $beat = $measure->getBeatByStart($nStart);
         $beat->getVoice(0)->getDuration()->copyFrom($nDuration);
         $note = new Note();
         $note->setValue($nValue);
         $note->setString($nString);
         $note->setVelocity($nVelocity);
         // Effect Bends / Vibrato
         if ($tempNote->countPitchBends() > 0) {
             $this->makeNoteEffect($note, $tempNote->getPitchBends());
         }
         $beat->getVoice(0)->addNote($note);
     }
 }