示例#1
0
 private function writeMeasureHeader(MeasureHeader $measure, TimeSignature $timeSignature)
 {
     $flags = 0;
     if ($measure->getNumber() == 1 || $measure->getTimeSignature()->getNumerator() != $timeSignature->getNumerator()) {
         $flags |= 0x1;
     }
     if ($measure->getNumber() == 1 || $measure->getTimeSignature()->getDenominator()->getValue() != $timeSignature->getDenominator()->getValue()) {
         $flags |= 0x2;
     }
     if ($measure->isRepeatOpen()) {
         $flags |= 0x4;
     }
     if ($measure->getRepeatClose() > 0) {
         $flags |= 0x8;
     }
     if ($measure->hasMarker()) {
         $flags |= 0x20;
     }
     $this->writeUnsignedByte($flags);
     if (($flags & 0x1) != 0) {
         $this->writeByte($measure->getTimeSignature()->getNumerator());
     }
     if (($flags & 0x2) != 0) {
         $this->writeByte($measure->getTimeSignature()->getDenominator()->getValue());
     }
     if (($flags & 0x8) != 0) {
         $this->writeByte($measure->getRepeatClose());
     }
     if (($flags & 0x20) != 0) {
         $this->writeMarker($measure->getMarker());
     }
 }
示例#2
0
 private function writeMeasureHeader(MeasureHeader $measure, TimeSignature $timeSignature)
 {
     $flags = 0;
     if ($measure->getNumber() == 1) {
         $flags |= 0x40;
     }
     if ($measure->getNumber() == 1 || !$measure->getTimeSignature()->isEqual($timeSignature)) {
         $flags |= 0x1;
         $flags |= 0x2;
     }
     if ($measure->isRepeatOpen()) {
         $flags |= 0x4;
     }
     if ($measure->getRepeatClose() > 0) {
         $flags |= 0x8;
     }
     if ($measure->getRepeatAlternative() > 0) {
         $flags |= 0x10;
     }
     if ($measure->hasMarker()) {
         $flags |= 0x20;
     }
     $this->writeUnsignedByte($flags);
     if (($flags & 0x1) != 0) {
         $this->writeByte($measure->getTimeSignature()->getNumerator());
     }
     if (($flags & 0x2) != 0) {
         $this->writeByte($measure->getTimeSignature()->getDenominator()->getValue());
     }
     if (($flags & 0x8) != 0) {
         $this->writeByte($measure->getRepeatClose() + 1);
     }
     if (($flags & 0x20) != 0) {
         $this->writeMarker($measure->getMarker());
     }
     if (($flags & 0x10) != 0) {
         $this->writeByte($measure->getRepeatAlternative());
     }
     if (($flags & 0x40) != 0) {
         $this->skipBytes(2);
     }
     if (($flags & 0x1) != 0) {
         $this->writeBytes($this->makeEighthNoteBytes($measure->getTimeSignature()));
     }
     if (($flags & 0x10) == 0) {
         $this->writeByte(0);
     }
     if ($measure->getTripletFeel() == MeasureHeader::TRIPLET_FEEL_NONE) {
         $this->writeByte(0);
     } else {
         if ($measure->getTripletFeel() == MeasureHeader::TRIPLET_FEEL_EIGHTH) {
             $this->writeByte(1);
         } else {
             if ($measure->getTripletFeel() == MeasureHeader::TRIPLET_FEEL_SIXTEENTH) {
                 $this->writeByte(2);
             }
         }
     }
 }