LCOV - code coverage report
Current view: top level - src/importexport/tabledit/internal - importtef.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 2 2
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) 2025 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              : #pragma once
      23              : 
      24              : #include <array>
      25              : #include <string>
      26              : #include <vector>
      27              : 
      28              : #include "engraving/dom/masterscore.h"
      29              : #include "engraving/engravingerrors.h"
      30              : #include "io/iodevice.h"
      31              : 
      32              : #include "note.h"
      33              : #include "voiceallocator.h"
      34              : 
      35              : namespace mu::iex::tabledit {
      36              : class MeasureHandler;
      37              : 
      38              : // offsets into the file header
      39              : static const uint8_t OFFSET_TBED = 0x38;
      40              : static const uint8_t OFFSET_CONTENTS = 0x3C;
      41              : static const uint8_t OFFSET_TITLE = 0x40;
      42              : static const uint8_t OFFSET_SUBTITLE = 0x44;
      43              : static const uint8_t OFFSET_COMMENT = 0x48;
      44              : static const uint8_t OFFSET_NOTES = 0x4C;
      45              : static const uint8_t OFFSET_TEXTS = 0x54;
      46              : static const uint8_t OFFSET_MEASURES = 0x5C;
      47              : static const uint8_t OFFSET_INSTRUMENTS = 0x60;
      48              : static const uint8_t OFFSET_READINGLIST = 0x80;
      49              : static const uint8_t OFFSET_INTERNETLINK = 0x84;
      50              : static const uint8_t OFFSET_COPYRIGHT = 0x8C;
      51              : static const uint8_t OFFSET_OLDNUM = 0xCA;
      52              : 
      53              : struct TefMeasure {
      54              :     int flag { 0 };
      55              :     bool isPickup { false };
      56              :     int key { 0 };
      57              :     int size { 0 };
      58              :     int numerator { 0 };
      59              :     int denominator { 0 };
      60              : };
      61              : 
      62              : struct TefReadingListItem {
      63              :     int firstMeasure { 0 };
      64              :     int lastMeasure { 0 };
      65              :     std::string label;
      66              : };
      67              : 
      68              : class TablEdit
      69              : {
      70              :     muse::io::IODevice* _file = nullptr;
      71              :     mu::engraving::MasterScore* score = nullptr;
      72              : 
      73              :     int8_t readInt8();
      74              :     uint8_t readUInt8();
      75              :     uint16_t readUInt16();
      76              :     uint32_t readUInt32();
      77              :     std::string readUtf8Text();
      78              :     std::string readUtf8TextIndirect(uint32_t positionOfPosition);
      79              : 
      80              :     struct TefHeader {
      81              :         int version { 0 };
      82              :         int subVersion { 0 };
      83              :         int tempo { 0 };
      84              :         int chorus { 0 };
      85              :         int reverb { 0 };
      86              :         int syncope { 0 };
      87              :         unsigned int securityCode { 0 }; // open file only if 0
      88              :         unsigned int securityFlags { 0 };
      89              :         int tbed { 0 }; // should be 0x64656274 ("tbed"), but is sometimes reversed (?)
      90              :         int wOldNum { 0 }; // must be 4
      91              :         int wFormat { 0 }; // hibyte > 9: v3.00 file, hibyte > 10: may no longer match v3.00 spec
      92              :         std::string title;
      93              :         std::string subTitle;
      94              :         std::string comment;
      95              :         std::string notes;
      96              :         std::string internetLink;
      97              :         std::string copyright;
      98              :     };
      99              : 
     100              :     struct TefInstrument {
     101              :         int stringNumber { 0 };
     102              :         int firstString { 0 };
     103              :         int available16U { 0 };
     104              :         int verticalSpacing { 0 };
     105              :         int midiVoice { 0 };
     106              :         int midiBank { 0 };
     107              :         int nBanjo5 { 0 };
     108              :         int uSpec { 0 };
     109              :         int nCapo { 0 };
     110              :         int fMiddleC { 0 };
     111              :         int fClef { 0 };
     112              :         int output { 0 };
     113              :         int options { 0 };
     114              :         std::array<int, 12> tuning = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     115              :         std::string name;
     116              :     };
     117              : 
     118              :     struct TefTextMarker {
     119              :         int position { 0 };
     120              :         int string { 0 };
     121              :         int index { 0 };
     122              :     };
     123              : 
     124              :     void allocateVoices(std::vector<VoiceAllocator>& allocator);
     125              :     void createCapos();
     126              :     void createContents(const MeasureHandler& measureHandler);
     127              :     void createEffects();
     128              :     void createLinkedTabs();
     129              :     void createMeasures(const MeasureHandler& measureHandler);
     130              :     void createNotesFrame();
     131              :     void createParts();
     132              :     void createProperties();
     133              :     void createRepeats();
     134              :     void createScore();
     135              :     void createTempo();
     136              :     void createTexts();
     137              :     void createTitleFrame();
     138              :     void initializeVoiceAllocators(std::vector<VoiceAllocator>& allocators);
     139              :     engraving::part_idx_t partIdx(size_t stringIdx, bool& ok) const;
     140              :     int stringNumberPreviousParts(engraving::part_idx_t partIdx) const;
     141              :     void readTefContents();
     142              :     void readTefHeader();
     143              :     void readTefInstruments();
     144              :     void readTefMeasures();
     145              :     void readTefReadingList();
     146              :     void readTefTexts();
     147              : 
     148              :     TefHeader tefHeader;
     149              :     std::vector<TefTextMarker> tefTextMarkers;
     150              :     std::vector<TefNote> tefContents; // notes (and rests) only
     151              :     std::vector<TefInstrument> tefInstruments;
     152              :     std::vector<TefMeasure> tefMeasures;
     153              :     std::vector<TefReadingListItem> tefReadingList;
     154              :     std::vector<std::string> tefTexts;
     155              : 
     156              :     std::map<const TefNote* const, mu::engraving::Note*> effectMap;
     157              : 
     158              : public:
     159           61 :     TablEdit(muse::io::IODevice* f, mu::engraving::MasterScore* s)
     160           61 :         : _file(f), score(s) {}
     161              :     mu::engraving::Err import();
     162              : };
     163              : } // namespace mu::iex::tabledit
        

Generated by: LCOV version 2.0-1