Пример #1
0
 private function getRealVelocity(MidiSequenceHelper $sHelper, Note $note, Track $track, Channel $channel, $mIndex, $bIndex)
 {
     $velocity = $note->getVelocity();
     //Check for Hammer effect
     if (!$channel->isPercussionChannel()) {
         $previousNote = $this->getPreviousNote($sHelper, $note, $track, $mIndex, $bIndex, false);
         if ($previousNote !== null && $previousNote->getNote()->getEffect()->isHammer()) {
             $velocity = max(Velocities::MIN_VELOCITY, $velocity - 25);
         }
     }
     //Check for GhostNote effect
     if ($note->getEffect()->isGhostNote()) {
         $velocity = max(Velocities::MIN_VELOCITY, $velocity - Velocities::VELOCITY_INCREMENT);
     } else {
         if ($note->getEffect()->isAccentuatedNote()) {
             $velocity = max(Velocities::MIN_VELOCITY, $velocity + Velocities::VELOCITY_INCREMENT);
         } else {
             if ($note->getEffect()->isHeavyAccentuatedNote()) {
                 $velocity = max(Velocities::MIN_VELOCITY, $velocity + Velocities::VELOCITY_INCREMENT * 2);
             }
         }
     }
     return $velocity > 127 ? 127 : $velocity;
 }
Пример #2
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());
     }
 }
Пример #3
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());
     }
 }