LCOV - code coverage report
Current view: top level - src/engraving/rw/read460 - measureread.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 65.2 % 422 275
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : #include "measureread.h"
      23              : 
      24              : #include "translation.h"
      25              : 
      26              : #include "../dom/ambitus.h"
      27              : #include "../dom/anchors.h"
      28              : #include "../dom/barline.h"
      29              : #include "../dom/beam.h"
      30              : #include "../dom/breath.h"
      31              : #include "../dom/chord.h"
      32              : #include "../dom/dynamic.h"
      33              : #include "../dom/expression.h"
      34              : #include "../dom/factory.h"
      35              : #include "../dom/fermata.h"
      36              : #include "../dom/fret.h"
      37              : #include "../dom/keysig.h"
      38              : #include "../dom/location.h"
      39              : #include "../dom/measure.h"
      40              : #include "../dom/measurenumber.h"
      41              : #include "../dom/measurerepeat.h"
      42              : #include "../dom/mmrest.h"
      43              : #include "../dom/mmrestrange.h"
      44              : #include "../dom/score.h"
      45              : #include "../dom/segment.h"
      46              : #include "../dom/spacer.h"
      47              : #include "../dom/staff.h"
      48              : #include "../dom/stafflines.h"
      49              : #include "../dom/stafftext.h"
      50              : #include "../dom/system.h"
      51              : #include "../dom/systemdivider.h"
      52              : #include "../dom/timesig.h"
      53              : #include "../dom/tuplet.h"
      54              : #include "../dom/harmony.h"
      55              : #include "../dom/fret.h"
      56              : #include "../dom/tremolobar.h"
      57              : #include "../dom/tempotext.h"
      58              : #include "../dom/image.h"
      59              : 
      60              : #include "../types/typesconv.h"
      61              : #include "tread.h"
      62              : 
      63              : #include "log.h"
      64              : 
      65              : using namespace mu::engraving;
      66              : using namespace mu::engraving::read460;
      67              : 
      68         1695 : void MeasureRead::readMeasure(Measure* measure, XmlReader& e, ReadContext& ctx, int staffIdx)
      69              : {
      70         1695 :     IF_ASSERT_FAILED(ctx.isSameScore(measure)) {
      71            0 :         return;
      72              :     }
      73              : 
      74         1695 :     ctx.setCurrentMeasure(measure);
      75         1695 :     int nextTrack = staffIdx * VOICES;
      76         1695 :     ctx.setTrack(nextTrack);
      77              : 
      78         1695 :     for (int n = int(measure->mstaves().size()); n <= staffIdx; ++n) {
      79            0 :         Staff* staff = ctx.staff(n);
      80            0 :         MStaff* s = new MStaff;
      81            0 :         s->setLines(Factory::createStaffLines(measure));
      82            0 :         s->lines()->setTrack(n * VOICES);
      83            0 :         s->lines()->setVisible(!staff->isLinesInvisible(measure->tick()));
      84            0 :         measure->mstaves().push_back(s);
      85              :     }
      86              : 
      87         1695 :     bool irregular = false;
      88         1695 :     if (e.hasAttribute("len")) {
      89            2 :         bool ok = true;
      90            2 :         measure->setTicks(Fraction::fromString(e.attribute("len"), &ok));
      91            2 :         if (!ok || measure->ticks() < Fraction(1, 128)) {
      92            0 :             e.raiseError(muse::mtrc("engraving", "MSCX error at byte offset %1: invalid measure length: %2")
      93            0 :                          .arg(e.byteOffset()).arg(e.attribute("len")));
      94            0 :             return;
      95              :         }
      96            2 :         irregular = true;
      97              :     }
      98              : 
      99         4668 :     while (e.readNextStartElement()) {
     100         2973 :         const AsciiStringView tag(e.name());
     101              : 
     102         2973 :         if (tag == "voice") {
     103         1785 :             ctx.setTrack(nextTrack++);
     104         1785 :             ctx.setTick(measure->tick());
     105         1785 :             readVoice(measure, e, ctx, staffIdx, irregular);
     106         1188 :         } else if (tag == "Marker" || tag == "Jump") {
     107           50 :             EngravingItem* el = Factory::createItemByName(tag, measure);
     108           50 :             el->setTrack(ctx.track());
     109           50 :             TRead::readItem(el, e, ctx);
     110           50 :             if (el->systemFlag() && el->isTopSystemObject()) {
     111           50 :                 el->setTrack(0); // original system object always goes on top
     112              :             }
     113           50 :             measure->add(el);
     114         1138 :         } else if (tag == "stretch") {
     115            2 :             double val = e.readDouble();
     116            2 :             if (val < 0.0) {
     117            0 :                 val = 0;
     118              :             }
     119            2 :             measure->setUserStretch(val);
     120         1136 :         } else if (tag == "noOffset") {
     121            0 :             measure->setMeasureNumberOffset(e.readInt());
     122         1136 :         } else if (tag == "measureNumberMode") {
     123            0 :             measure->setMeasureNumberMode(MeasureNumberMode(e.readInt()));
     124         1136 :         } else if (tag == "irregular") {
     125            0 :             measure->setExcludeFromNumbering(e.readBool());
     126         1136 :         } else if (tag == "breakMultiMeasureRest") {
     127            0 :             measure->setBreakMultiMeasureRest(e.readBool());
     128         1136 :         } else if (tag == "startRepeat") {
     129           15 :             measure->setRepeatStart(true);
     130           15 :             e.readNext();
     131         1121 :         } else if (tag == "endRepeat") {
     132           17 :             measure->setRepeatCount(e.readInt());
     133           17 :             measure->setRepeatEnd(true);
     134         1104 :         } else if (tag == "vspacer" || tag == "vspacerDown") {
     135            0 :             if (!measure->mstaves()[staffIdx]->vspacerDown()) {
     136            0 :                 Spacer* spacer = Factory::createSpacer(measure);
     137            0 :                 spacer->setSpacerType(SpacerType::DOWN);
     138            0 :                 spacer->setTrack(staffIdx * VOICES);
     139            0 :                 measure->add(spacer);
     140              :             }
     141            0 :             measure->mstaves()[staffIdx]->vspacerDown()->setGap(Spatium(e.readDouble()));
     142         1104 :         } else if (tag == "vspacerFixed") {
     143            1 :             if (!measure->mstaves()[staffIdx]->vspacerDown()) {
     144            1 :                 Spacer* spacer = Factory::createSpacer(measure);
     145            1 :                 spacer->setSpacerType(SpacerType::FIXED);
     146            1 :                 spacer->setTrack(staffIdx * VOICES);
     147            1 :                 measure->add(spacer);
     148              :             }
     149            1 :             measure->mstaves()[staffIdx]->vspacerDown()->setGap(Spatium(e.readDouble()));
     150         1103 :         } else if (tag == "vspacerUp") {
     151            0 :             if (!measure->mstaves()[staffIdx]->vspacerUp()) {
     152            0 :                 Spacer* spacer = Factory::createSpacer(measure);
     153            0 :                 spacer->setSpacerType(SpacerType::UP);
     154            0 :                 spacer->setTrack(staffIdx * VOICES);
     155            0 :                 measure->add(spacer);
     156              :             }
     157            0 :             measure->mstaves()[staffIdx]->vspacerUp()->setGap(Spatium(e.readDouble()));
     158         1103 :         } else if (tag == "visible") {
     159            0 :             measure->mstaves()[staffIdx]->setVisible(e.readInt());
     160         1103 :         } else if (tag == "stemless") {
     161            0 :             measure->mstaves()[staffIdx]->setStemless(e.readInt());
     162         1103 :         } else if (tag == "hideIfEmpty") {
     163            0 :             measure->mstaves()[staffIdx]->setHideIfEmpty(TConv::fromXml(e.readAsciiText(), AutoOnOff::AUTO));
     164         1103 :         } else if (tag == "measureRepeatCount") {
     165            1 :             measure->setMeasureRepeatCount(e.readInt(), staffIdx);
     166         1102 :         } else if (tag == "SystemDivider") {
     167            0 :             SystemDivider* sd = new SystemDivider(ctx.dummy());
     168            0 :             TRead::read(sd, e, ctx);
     169              :             //! TODO Looks like a bug.
     170              :             //! The SystemDivider parent must be System
     171              :             //! there is a method: `System* system() const { return (System*)parent(); }`,
     172              :             //! but when we add it to Measure, the parent will be rewritten.
     173            0 :             measure->add(sd);
     174         1102 :         } else if (tag == "multiMeasureRest") {
     175            9 :             measure->setMMRestCount(e.readInt());
     176              :             // set tick to previous measure
     177            9 :             measure->setTick(ctx.lastMeasure()->tick());
     178            9 :             ctx.setTick(ctx.lastMeasure()->tick());
     179         1093 :         } else if (tag == "MeasureNumber") {
     180            0 :             MeasureNumber* noText = new MeasureNumber(measure);
     181            0 :             TRead::read(noText, e, ctx);
     182            0 :             noText->setTrack(ctx.track());
     183            0 :             measure->add(noText);
     184         1093 :         } else if (tag == "MMRestRange") {
     185            0 :             MMRestRange* range = new MMRestRange(measure);
     186            0 :             TRead::read(range, e, ctx);
     187            0 :             range->setTrack(ctx.track());
     188            0 :             measure->add(range);
     189         1093 :         } else if (TRead::readProperties(static_cast<MeasureBase*>(measure), e, ctx)) {
     190              :         } else {
     191            0 :             e.unknown();
     192              :         }
     193              :     }
     194         1695 :     ctx.checkConnectors();
     195         1695 :     if (measure->isMMRest()) {
     196            9 :         Measure* lm = ctx.lastMeasure();
     197            9 :         ctx.setTick(lm->endTick());
     198              :     }
     199         1695 :     ctx.setCurrentMeasure(nullptr);
     200              : 
     201         1695 :     measure->connectTremolo();
     202              : }
     203              : 
     204         1785 : void MeasureRead::readVoice(Measure* measure, XmlReader& e, ReadContext& ctx, int staffIdx, bool irregular)
     205              : {
     206         1785 :     Segment* segment = nullptr;
     207         1785 :     std::vector<Chord*> graceNotes;
     208         1785 :     Beam* startingBeam = nullptr;
     209         1785 :     Tuplet* tuplet = nullptr;
     210         1785 :     Fermata* fermata = nullptr;
     211              : 
     212         1785 :     Staff* staff = ctx.staff(staffIdx);
     213         1785 :     Fraction timeStretch(staff->timeStretch(measure->tick()));
     214              : 
     215         7320 :     while (e.readNextStartElement()) {
     216         5535 :         const AsciiStringView tag(e.name());
     217              : 
     218         5535 :         if (tag == "location") {
     219           50 :             Location loc = Location::relative();
     220           50 :             TRead::read(&loc, e, ctx);
     221           50 :             ctx.setLocation(loc);
     222           50 :             if (loc.isTimeTick()) {
     223           19 :                 EditTimeTickAnchors::createTimeTickAnchor(measure, ctx.tick() - measure->tick(), track2staff(ctx.track()));
     224              :             }
     225         5485 :         } else if (tag == "tick") {             // obsolete?
     226            0 :             LOGD() << "read midi tick";
     227            0 :             ctx.setTick(Fraction::fromTicks(ctx.fileDivision(e.readInt())));
     228         5485 :         } else if (tag == "BarLine") {
     229            3 :             BarLine* barLine = Factory::createBarLine(ctx.dummy());
     230            3 :             barLine->setTrack(ctx.track());
     231            3 :             TRead::read(barLine, e, ctx);
     232              :             //
     233              :             //  StartRepeatBarLine: at rtick == 0, always BarLineType::START_REPEAT
     234              :             //  BarLine:            in the middle of a measure, has no semantic
     235              :             //  EndBarLine:         at the end of a measure
     236              :             //  BeginBarLine:       first segment of a measure, systemic barline
     237              : 
     238            3 :             SegmentType st = SegmentType::Invalid;
     239            3 :             Fraction t = ctx.tick() - measure->tick();
     240            3 :             if (t.isNotZero() && (t != measure->ticks())) {
     241            0 :                 st = SegmentType::BarLine;
     242            3 :             } else if (barLine->barLineType() == BarLineType::START_REPEAT && t.isZero()) {
     243            0 :                 st = SegmentType::StartRepeatBarLine;
     244            3 :             } else if (barLine->barLineType() == BarLineType::START_REPEAT && t == measure->ticks()) {
     245              :                 // old version, ignore
     246            0 :                 delete barLine;
     247            0 :                 barLine = 0;
     248            3 :             } else if (t.isZero() && segment == 0) {
     249            0 :                 st = SegmentType::BeginBarLine;
     250              :             } else {
     251            3 :                 st = SegmentType::EndBarLine;
     252              :             }
     253            3 :             if (barLine) {
     254            3 :                 segment = measure->getSegmentR(st, t);
     255            3 :                 segment->add(barLine);
     256              :             }
     257            3 :             if (fermata) {
     258            0 :                 segment->add(fermata);
     259            0 :                 fermata = nullptr;
     260              :             }
     261         5482 :         } else if (tag == "Chord") {
     262         3331 :             Chord* chord = Factory::createChord(ctx.dummy());
     263         3331 :             chord->setTrack(ctx.track());
     264         3331 :             TRead::read(chord, e, ctx);
     265         3331 :             if (startingBeam) {
     266            1 :                 startingBeam->add(chord);         // also calls chord->setBeam(startingBeam)
     267            1 :                 startingBeam = nullptr;
     268              :             }
     269              : //                  if (tuplet && !chord->isGrace())
     270              : //                        chord->readAddTuplet(tuplet);
     271         3331 :             segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     272         3331 :             if (chord->noteType() != NoteType::NORMAL) {
     273           52 :                 graceNotes.push_back(chord);
     274              :             } else {
     275         3279 :                 segment->add(chord);
     276         3331 :                 for (size_t i = 0; i < graceNotes.size(); ++i) {
     277           52 :                     Chord* gc = graceNotes[i];
     278           52 :                     gc->setGraceIndex(static_cast<int>(i));
     279           52 :                     chord->add(gc);
     280              :                 }
     281         3279 :                 graceNotes.clear();
     282         3279 :                 if (tuplet) {
     283          160 :                     tuplet->add(chord);
     284              :                 }
     285         3279 :                 ctx.incTick(chord->actualTicks());
     286              :             }
     287         3331 :             if (fermata) {
     288            0 :                 segment->add(fermata);
     289            0 :                 fermata = nullptr;
     290              :             }
     291         2151 :         } else if (tag == "Rest") {
     292         1289 :             if (measure->isMMRest()) {
     293            9 :                 segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     294            9 :                 MMRest* mmr = Factory::createMMRest(segment);
     295            9 :                 mmr->setTrack(ctx.track());
     296            9 :                 TRead::read(mmr, e, ctx);
     297            9 :                 segment->add(mmr);
     298            9 :                 ctx.incTick(mmr->actualTicks());
     299              :             } else {
     300         1280 :                 segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     301         1280 :                 Rest* rest = Factory::createRest(segment);
     302         1280 :                 rest->setDurationType(DurationType::V_MEASURE);
     303         1280 :                 rest->setTicks(measure->timesig() / timeStretch);
     304         1280 :                 rest->setTrack(ctx.track());
     305         1280 :                 TRead::read(rest, e, ctx);
     306         1280 :                 if (startingBeam) {
     307            0 :                     startingBeam->add(rest); // also calls rest->setBeam(startingBeam)
     308            0 :                     startingBeam = nullptr;
     309              :                 }
     310              : 
     311         1280 :                 segment->add(rest);
     312         1280 :                 if (fermata) {
     313            0 :                     segment->add(fermata);
     314            0 :                     fermata = nullptr;
     315              :                 }
     316              : 
     317         1280 :                 if (!rest->ticks().isValid()) {    // hack
     318            0 :                     rest->setTicks(measure->timesig() / timeStretch);
     319              :                 }
     320              : 
     321         1280 :                 if (tuplet) {
     322           40 :                     tuplet->add(rest);
     323              :                 }
     324         1280 :                 ctx.incTick(rest->actualTicks());
     325              :             }
     326          862 :         } else if (tag == "Breath") {
     327            0 :             segment = measure->getSegment(SegmentType::Breath, ctx.tick());
     328            0 :             Breath* breath = Factory::createBreath(segment);
     329            0 :             breath->setTrack(ctx.track());
     330            0 :             breath->setPlacement(breath->track() & 1 ? PlacementV::BELOW : PlacementV::ABOVE);
     331            0 :             TRead::read(breath, e, ctx);
     332            0 :             segment->add(breath);
     333          862 :         } else if (tag == "Spanner") {
     334           82 :             TRead::readSpanner(e, ctx, measure, ctx.track());
     335          780 :         } else if (tag == "MeasureRepeat" || tag == "RepeatMeasure") {
     336              :             //             4.x                       3.x
     337            1 :             segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     338            1 :             MeasureRepeat* mr = Factory::createMeasureRepeat(segment);
     339            1 :             mr->setTrack(ctx.track());
     340            1 :             TRead::read(mr, e, ctx);
     341            1 :             if (!mr->numMeasures()) {
     342            0 :                 mr->setNumMeasures(1); // 3.x doesn't have any other possibilities
     343              :             }
     344            1 :             if (!measure->measureRepeatCount(staffIdx)) {
     345            0 :                 measure->setMeasureRepeatCount(1, staffIdx);
     346              :             }
     347            1 :             segment->add(mr);
     348            1 :             ctx.incTick(measure->ticks());
     349          779 :         } else if (tag == "Clef") {
     350           16 :             Clef* clef = Factory::createClef(ctx.dummy());
     351           16 :             clef->setTrack(ctx.track());
     352           16 :             bool isHeader = false;
     353           16 :             TRead::read(clef, e, ctx, &isHeader);
     354           16 :             clef->setGenerated(false);
     355              : 
     356           16 :             segment = measure->getSegment(isHeader ? SegmentType::HeaderClef : SegmentType::Clef, ctx.tick());
     357           16 :             segment->add(clef);
     358          763 :         } else if (tag == "TimeSig") {
     359          197 :             TimeSig* ts = Factory::createTimeSig(ctx.dummy());
     360          197 :             ts->setTrack(ctx.track());
     361          197 :             TRead::read(ts, e, ctx);
     362              : 
     363          197 :             Fraction currTick = ctx.tick();
     364          197 :             bool courtesySig = ts->isCourtesy();
     365          197 :             segment = measure->getSegment(courtesySig ? SegmentType::TimeSigAnnounce : SegmentType::TimeSig, currTick);
     366          197 :             segment->add(ts);
     367              : 
     368          197 :             if (!courtesySig) {
     369          197 :                 if (currTick == measure->endTick()) {
     370            1 :                     segment->setEndOfMeasureChange(true);
     371            1 :                     measure->setEndOfMeasureChange(true);
     372              :                 }
     373              : 
     374          197 :                 if (currTick == measure->tick()) {
     375          196 :                     timeStretch = ts->stretch().reduced();
     376          196 :                     measure->setTimesig(ts->sig() / timeStretch);
     377              : 
     378          196 :                     if (!irregular) {
     379          194 :                         measure->setTicks(measure->timesig());
     380              :                     }
     381              :                 }
     382              : 
     383          197 :                 if (currTick > measure->tick()) {
     384            1 :                     ctx.setTimeSigForNextMeasure(ts->sig() / ts->stretch().reduced());
     385              :                 }
     386              :             }
     387          566 :         } else if (tag == "KeySig") {
     388          148 :             KeySig* ks = Factory::createKeySig(ctx.dummy());
     389          148 :             ks->setTrack(ctx.track());
     390          148 :             TRead::read(ks, e, ctx);
     391              : 
     392          148 :             Fraction curTick = ctx.tick();
     393          148 :             bool courtesySig = ks->isCourtesy();
     394          148 :             segment = measure->getSegment(courtesySig ? SegmentType::KeySigAnnounce : SegmentType::KeySig, curTick);
     395          148 :             segment->add(ks);
     396              : 
     397          148 :             if (!courtesySig) {
     398          148 :                 if (curTick == measure->endTick()) {
     399            0 :                     segment->setEndOfMeasureChange(true);
     400            0 :                     measure->setEndOfMeasureChange(true);
     401              :                 }
     402              : 
     403          148 :                 staff->setKey(curTick, ks->keySigEvent());
     404              :             }
     405          418 :         } else if (tag == "Text") {
     406            0 :             segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     407            0 :             StaffText* t = Factory::createStaffText(segment);
     408            0 :             t->setTrack(ctx.track());
     409            0 :             TRead::read(t, e, ctx);
     410            0 :             if (t->empty()) {
     411            0 :                 LOGD("==reading empty text: deleted");
     412            0 :                 delete t;
     413              :             } else {
     414            0 :                 segment->add(t);
     415              :             }
     416              :         }
     417              :         //----------------------------------------------------
     418              :         // Annotation
     419          418 :         else if (tag == "Dynamic") {
     420           15 :             segment = measure->getChordRestOrTimeTickSegment(ctx.tick());
     421           15 :             Dynamic* dyn = Factory::createDynamic(segment);
     422           15 :             dyn->setTrack(ctx.track());
     423           15 :             TRead::read(dyn, e, ctx);
     424           15 :             segment->add(dyn);
     425          403 :         } else if (tag == "Expression") {
     426            0 :             segment = measure->getChordRestOrTimeTickSegment(ctx.tick());
     427            0 :             Expression* expr = Factory::createExpression(segment);
     428            0 :             expr->setTrack(ctx.track());
     429            0 :             TRead::read(expr, e, ctx);
     430            0 :             segment->add(expr);
     431          403 :         } else if (tag == "Harmony") {
     432           49 :             segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     433           49 :             Harmony* el = Factory::createHarmony(segment);
     434              : 
     435           49 :             el->setTrack(ctx.track());
     436           49 :             TRead::read(el, e, ctx);
     437           49 :             if (el->systemFlag() && el->isTopSystemObject()) {
     438            0 :                 el->setTrack(0); // original system object always goes on top
     439              :             }
     440           49 :             if (el->chords().empty()) {
     441              :                 // Invalid harmony
     442            0 :                 delete el;
     443              :             } else {
     444           49 :                 segment->add(el);
     445              :             }
     446          354 :         } else if (tag == "FretDiagram") {
     447           33 :             segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     448           33 :             FretDiagram* el = Factory::createFretDiagram(segment);
     449              : 
     450           33 :             el->setTrack(ctx.track());
     451           33 :             TRead::read(el, e, ctx);
     452           33 :             if (el->systemFlag() && el->isTopSystemObject()) {
     453            0 :                 el->setTrack(0); // original system object always goes on top
     454              :             }
     455           33 :             segment->add(el);
     456          321 :         } else if (tag == "TremoloBar") {
     457            0 :             segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     458            0 :             TremoloBar* el = Factory::createTremoloBar(segment);
     459            0 :             el->setTrack(ctx.track());
     460            0 :             TRead::read(el, e, ctx);
     461            0 :             if (el->systemFlag() && el->isTopSystemObject()) {
     462            0 :                 el->setTrack(0); // original system object always goes on top
     463              :             }
     464            0 :             segment->add(el);
     465          321 :         } else if (tag == "Symbol") {
     466            0 :             segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     467            0 :             Symbol* el = Factory::createSymbol(segment);
     468              : 
     469            0 :             el->setTrack(ctx.track());
     470            0 :             TRead::read(el, e, ctx);
     471            0 :             if (el->systemFlag() && el->isTopSystemObject()) {
     472            0 :                 el->setTrack(0); // original system object always goes on top
     473              :             }
     474            0 :             segment->add(el);
     475          321 :         } else if (tag == "Tempo") {
     476           13 :             segment = measure->getChordRestOrTimeTickSegment(ctx.tick());
     477           13 :             TempoText* el = Factory::createTempoText(segment);
     478              : 
     479           13 :             el->setTrack(ctx.track());
     480           13 :             TRead::read(el, e, ctx);
     481           13 :             if (el->systemFlag() && el->isTopSystemObject()) {
     482           13 :                 el->setTrack(0); // original system object always goes on top
     483              :             }
     484           13 :             segment->add(el);
     485          308 :         } else if (tag == "StaffText") {
     486          101 :             segment = measure->getChordRestOrTimeTickSegment(ctx.tick());
     487          101 :             StaffText* el = Factory::createStaffText(segment);
     488          101 :             el->setTrack(ctx.track());
     489          101 :             TRead::read(el, e, ctx);
     490          101 :             if (el->systemFlag() && el->isTopSystemObject()) {
     491            0 :                 el->setTrack(0);     // original system object always goes on top
     492              :             }
     493          101 :             segment->add(el);
     494          207 :         } else if (tag == "Sticking"
     495          207 :                    || tag == "SystemText"
     496          197 :                    || tag == "PlayTechAnnotation"
     497          169 :                    || tag == "Capo"
     498          161 :                    || tag == "StringTunings"
     499          161 :                    || tag == "RehearsalMark"
     500          161 :                    || tag == "InstrumentChange"
     501          161 :                    || tag == "StaffState"
     502          161 :                    || tag == "FiguredBass"
     503          414 :                    || tag == "HarpPedalDiagram"
     504              :                    ) {
     505           46 :             EngravingItem* el = Factory::createItemByName(tag, ctx.dummy());
     506           46 :             if (el->allowTimeAnchor()) {
     507            0 :                 segment = measure->getChordRestOrTimeTickSegment(ctx.tick());
     508              :             } else {
     509           46 :                 segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     510              :             }
     511              : 
     512           46 :             el->setTrack(ctx.track());
     513           46 :             TRead::readItem(el, e, ctx);
     514           46 :             if (el->systemFlag() && el->isTopSystemObject()) {
     515           10 :                 el->setTrack(0); // original system object always goes on top
     516              :             }
     517           46 :             segment->add(el);
     518          161 :         } else if (tag == "Fermata") {
     519            0 :             fermata = Factory::createFermata(ctx.dummy());
     520            0 :             fermata->setTrack(ctx.track());
     521            0 :             fermata->setPlacement(fermata->track() & 1 ? PlacementV::BELOW : PlacementV::ABOVE);
     522            0 :             TRead::read(fermata, e, ctx);
     523          161 :         } else if (tag == "Image") {
     524            0 :             if (MScore::noImages) {
     525            0 :                 e.skipCurrentElement();
     526              :             } else {
     527            0 :                 segment = measure->getSegment(SegmentType::ChordRest, ctx.tick());
     528            0 :                 Image* el = Factory::createImage(segment);
     529            0 :                 el->setTrack(ctx.track());
     530            0 :                 TRead::read(el, e, ctx);
     531            0 :                 segment->add(el);
     532              :             }
     533          161 :         } else if (tag == "PlayCountText") {
     534            0 :             segment = measure->getSegment(SegmentType::EndBarLine, ctx.tick());
     535            0 :             EngravingItem* el = Factory::createItemByName(tag, segment);
     536              : 
     537            0 :             el->setTrack(ctx.track());
     538            0 :             TRead::readItem(el, e, ctx);
     539            0 :             if (el->systemFlag() && el->isTopSystemObject()) {
     540            0 :                 el->setTrack(0); // original system object always goes on top
     541              :             }
     542            0 :             segment->add(el);
     543              :         }
     544              :         //----------------------------------------------------
     545          161 :         else if (tag == "Tuplet") {
     546           80 :             Tuplet* oldTuplet = tuplet;
     547           80 :             tuplet = Factory::createTuplet(measure);
     548           80 :             tuplet->setTrack(ctx.track());
     549           80 :             tuplet->setTick(ctx.tick());
     550           80 :             TRead::read(tuplet, e, ctx);
     551           80 :             if (oldTuplet) {
     552           40 :                 oldTuplet->add(tuplet);
     553              :             }
     554           81 :         } else if (tag == "endTuplet") {
     555           80 :             if (!tuplet) {
     556            0 :                 LOGD("Measure::read: encountered <endTuplet/> when no tuplet was started");
     557            0 :                 e.skipCurrentElement();
     558            0 :                 continue;
     559              :             }
     560           80 :             Tuplet* oldTuplet = tuplet;
     561           80 :             tuplet = tuplet->tuplet();
     562           80 :             if (oldTuplet->elements().empty()) {
     563              :                 // this should not happen and is a sign of input file corruption
     564            0 :                 LOGD("Measure:read: empty tuplet in measure index=%d, input file corrupted?", ctx.currentMeasureIndex());
     565            0 :                 if (tuplet) {
     566            0 :                     tuplet->remove(oldTuplet);
     567              :                 }
     568            0 :                 delete oldTuplet;
     569              :             }
     570           80 :             e.readNext();
     571            1 :         } else if (tag == "Beam") {
     572            1 :             Beam* beam = Factory::createBeam(ctx.score());
     573            1 :             beam->setTrack(ctx.track());
     574            1 :             TRead::read(beam, e, ctx);
     575            1 :             if (startingBeam) {
     576            0 :                 LOGD("The read beam was not used");
     577            0 :                 delete startingBeam;
     578              :             }
     579            1 :             startingBeam = beam;
     580            0 :         } else if (tag == "Segment" && segment) {
     581            0 :             TRead::read(segment, e, ctx);
     582            0 :         } else if (tag == "Ambitus") {
     583            0 :             segment = measure->getSegment(SegmentType::Ambitus, ctx.tick());
     584            0 :             Ambitus* range = Factory::createAmbitus(segment);
     585            0 :             TRead::read(range, e, ctx);
     586            0 :             range->setTrack(trackZeroVoice(ctx.track()));
     587            0 :             segment->add(range);
     588              :         } else {
     589            0 :             e.unknown();
     590              :         }
     591              :     }
     592         1785 :     if (startingBeam) {
     593            0 :         LOGD("The read beam was not used");
     594            0 :         delete startingBeam;
     595              :     }
     596         1785 :     if (tuplet) {
     597            0 :         LOGD("Measure:readVoice: measure index=%d, <endTuplet/> not found", ctx.currentMeasureIndex());
     598            0 :         if (tuplet->elements().empty()) {
     599            0 :             if (tuplet->tuplet()) {
     600            0 :                 tuplet->tuplet()->remove(tuplet);
     601              :             }
     602            0 :             delete tuplet;
     603              :         }
     604              :     }
     605         1785 :     if (fermata) {
     606            0 :         SegmentType st = (ctx.tick() == measure->endTick() ? SegmentType::EndBarLine : SegmentType::ChordRest);
     607            0 :         segment = measure->getSegment(st, ctx.tick());
     608            0 :         segment->add(fermata);
     609            0 :         fermata = nullptr;
     610              :     }
     611         1785 : }
        

Generated by: LCOV version 2.0-1