Exemple #1
0
 private function writeNote(Note $note)
 {
     $flags = 0x20 | 0x10;
     if ($note->getEffect()->isGhostNote()) {
         $flags |= 0x4;
     }
     if ($note->getEffect()->isBend() || $note->getEffect()->isGrace() || $note->getEffect()->isSlide() || $note->getEffect()->isHammer() || $note->getEffect()->isLetRing()) {
         $flags |= 0x8;
     }
     $this->writeUnsignedByte($flags);
     if (($flags & 0x20) != 0) {
         $typeHeader = 0x1;
         if ($note->isTiedNote()) {
             $typeHeader = 0x2;
         } else {
             if ($note->getEffect()->isDeadNote()) {
                 $typeHeader = 0x3;
             }
         }
         $this->writeUnsignedByte($typeHeader);
     }
     if (($flags & 0x10) != 0) {
         $this->writeByte(intval(($note->getVelocity() - Velocities::MIN_VELOCITY) / Velocities::VELOCITY_INCREMENT + 1));
     }
     if (($flags & 0x20) != 0) {
         $this->writeByte($note->getValue());
     }
     if (($flags & 0x8) != 0) {
         $this->writeNoteEffects($note->getEffect());
     }
 }
Exemple #2
0
 private function writeNote(Note $note)
 {
     $flags = 0x20 | 0x10;
     if ($note->getEffect()->isVibrato() || $note->getEffect()->isBend() || $note->getEffect()->isGrace() || $note->getEffect()->isSlide() || $note->getEffect()->isHammer() || $note->getEffect()->isLetRing() || $note->getEffect()->isPalmMute() || $note->getEffect()->isStaccato() || $note->getEffect()->isHarmonic() || $note->getEffect()->isTrill() || $note->getEffect()->isTremoloPicking()) {
         $flags |= 0x8;
     }
     if ($note->getEffect()->isGhostNote()) {
         $flags |= 0x4;
     }
     if ($note->getEffect()->isHeavyAccentuatedNote()) {
         $flags |= 0x2;
     }
     if ($note->getEffect()->isAccentuatedNote()) {
         $flags |= 0x40;
     }
     $this->writeUnsignedByte($flags);
     if (($flags & 0x20) != 0) {
         $typeHeader = 0x1;
         if ($note->isTiedNote()) {
             $typeHeader = 0x2;
         } else {
             if ($note->getEffect()->isDeadNote()) {
                 $typeHeader = 0x3;
             }
         }
         $this->writeUnsignedByte($typeHeader);
     }
     if (($flags & 0x10) != 0) {
         $this->writeByte(intval(($note->getVelocity() - Velocities::MIN_VELOCITY) / Velocities::VELOCITY_INCREMENT + 1));
     }
     if (($flags & 0x20) != 0) {
         $this->writeByte($note->getValue());
     }
     $this->skipBytes(1);
     if (($flags & 0x8) != 0) {
         $this->writeNoteEffects($note->getEffect());
     }
 }