LCOV - code coverage report
Current view: top level - src/importexport/ove/internal - ove.h Coverage Total Hit
Test: filtered_coverage.info Lines: 58.4 % 77 45
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              : 
      23              : #ifndef OVE_DATA_H
      24              : #define OVE_DATA_H
      25              : 
      26              : #include <cmath>
      27              : 
      28              : #include <QList>
      29              : #include <QString>
      30              : #include <QTextCodec>
      31              : 
      32              : #ifdef WIN32
      33              : #define DLL_EXPORT extern "C" __declspec(dllexport)
      34              : #else
      35              : #define DLL_EXPORT
      36              : #endif
      37              : 
      38              : namespace ovebase {
      39              : class OveSong;
      40              : class Track;
      41              : class Page;
      42              : class Voice;
      43              : class Line;
      44              : class Staff;
      45              : class Measure;
      46              : class MeasureData;
      47              : class MusicData;
      48              : class OffsetElement;
      49              : class LineElement;
      50              : class PairEnds;
      51              : class Note;
      52              : class NoteContainer;
      53              : class Beam;
      54              : class Tie;
      55              : class Tuplet;
      56              : class Harmony;
      57              : class Clef;
      58              : class Lyric;
      59              : class Slur;
      60              : class MeasureText;
      61              : class Articulation;
      62              : class Glissando;
      63              : class Decorator;
      64              : class MeasureRepeat;
      65              : class Dynamics;
      66              : class Wedge;
      67              : class WedgeEndPoint;
      68              : class Pedal;
      69              : class KuoHao;
      70              : class Expressions;
      71              : class HarpPedal;
      72              : class MultiMeasureRest;
      73              : class OctaveShift;
      74              : class OctaveShiftEndPoint;
      75              : class BarNumber;
      76              : class Tempo;
      77              : class Text;
      78              : class TimeSignature;
      79              : class Key;
      80              : class RepeatSymbol;
      81              : class NumericEnding;
      82              : class MidiData;
      83              : class MidiController;
      84              : class MidiProgramChange;
      85              : class MidiChannelPressure;
      86              : class MidiPitchWheel;
      87              : 
      88              : const int TWELVE_TONE = 12;
      89              : const int INVALID_NOTE = -1;
      90              : const int OCTAVE = 7;
      91              : 
      92              : enum class CondType : char {
      93              :     None,
      94              :     Time_Parameters    = 0x09, // size - 7, TimeSignature
      95              :     Bar_Number         = 0x0A, // size, compatible with previous version
      96              :     Decorator          = 0x16,
      97              :     Tempo              = 0x1C, // size - 7
      98              :     Text               = 0x1D, // size - 7, Rehearsal | SystemText
      99              :     Expression         = 0x25, // size - 7, if set playback parameters in Expression, will store in COND
     100              :     Barline_Parameters = 0x30, // size - 7, include :|| repeat count
     101              :     Repeat             = 0x31, //
     102              :     Numeric_Ending     = 0x32,
     103              : };
     104              : 
     105              : enum class BdatType : unsigned char {
     106              :     None,
     107              :     Raw_Note              = 0x70,
     108              :     Rest                  = 0x80,
     109              :     Note                  = 0x90,
     110              :     Beam                  = 0x10,
     111              :     Harmony               = 0x11,
     112              :     Clef                  = 0x12,
     113              :     Dynamics              = 0x13,
     114              :     Wedge                 = 0x14, // crescendo, diminuendo
     115              :     Glissando             = 0x15,
     116              :     Decorator             = 0x16, // measure repeat | piano pedal | dotted barline
     117              :     Key                   = 0x17,
     118              :     Lyric                 = 0x18,
     119              :     Octave_Shift          = 0x19,
     120              :     Slur                  = 0x1B,
     121              :     Text                  = 0x1D,
     122              :     Tie                   = 0x1E,
     123              :     Tuplet                = 0x1F,
     124              :     Guitar_Bend           = 0x21, //
     125              :     Guitar_Barre          = 0x22, //
     126              :     Pedal                 = 0x23,
     127              :     KuoHao                = 0x24, // () [] {}
     128              :     Expressions           = 0x25,
     129              :     Harp_Pedal            = 0x26,
     130              :     Multi_Measure_Rest    = 0x27,
     131              :     Harmony_GuitarFrame   = 0x28,
     132              :     Graphics_40           = 0x40, // unknown
     133              :     Graphics_RoundRect    = 0x41,
     134              :     Graphics_Rect         = 0x42,
     135              :     Graphics_Round        = 0x43,
     136              :     Graphics_Line         = 0x44,
     137              :     Graphics_Curve        = 0x45,
     138              :     Graphics_WedgeSymbol  = 0x46,
     139              :     Midi_Controller       = 0xAB,
     140              :     Midi_Program_Change   = 0xAC,
     141              :     Midi_Channel_Pressure = 0xAD,
     142              :     Midi_Pitch_Wheel      = 0xAE,
     143              :     Bar_End               = 0xFF,
     144              : };
     145              : 
     146              : enum class MusicDataType : char {
     147              :     None,
     148              : 
     149              :     // attributes
     150              :     Clef,
     151              :     Key,
     152              :     Measure_Repeat,
     153              : 
     154              :     // sound
     155              :     Tempo,
     156              : 
     157              :     // direction
     158              :     Dynamics,
     159              :     Wedge,
     160              :     Wedge_EndPoint,
     161              :     OctaveShift,
     162              :     OctaveShift_EndPoint,
     163              :     Expressions,
     164              :     Repeat,
     165              :     Text,
     166              :     Harp_Pedal,
     167              :     Pedal,
     168              : 
     169              :     // note & harmony
     170              :     Note_Container,
     171              :     Harmony,
     172              : 
     173              :     // note's children
     174              :     Beam,
     175              :     Glissando,
     176              :     Lyric,
     177              :     Slur,
     178              :     Tie,
     179              :     Tuplet,
     180              : 
     181              :     // barline
     182              :     Numeric_Ending,
     183              : 
     184              :     KuoHao,
     185              :     Bar_End,
     186              :     Decorator,
     187              :     Multi_Measure_Rest,
     188              : };
     189              : 
     190              : enum class MidiType : signed char {
     191              :     None = -1,
     192              :     Controller,
     193              :     Program_Change,
     194              :     Channel_Pressure,
     195              :     Pitch_Wheel,
     196              : };
     197              : 
     198              : enum class ClefType : char {
     199              :     Treble = 0x00, // 0x00
     200              :     Bass,          // 0x01
     201              :     Alto,          // 0x02
     202              :     UpAlto,        // 0x03
     203              :     DownDownAlto,  // 0x04
     204              :     DownAlto,      // 0x05
     205              :     UpUpAlto,      // 0x06
     206              :     Treble8va,     // 0x07
     207              :     Bass8va,       // 0x08
     208              :     Treble8vb,     // 0x09
     209              :     Bass8vb,       // 0x0A
     210              :     Percussion1,   // 0x0B
     211              :     Percussion2,   // 0x0C
     212              :     TAB            // 0x0D
     213              : };
     214              : 
     215              : enum class GroupType : char {
     216              :     None = 0,
     217              :     Brace,
     218              :     Bracket
     219              : };
     220              : 
     221              : enum class AccidentalType : char {
     222              :     Normal              = 0x0,
     223              :     Sharp               = 0x1,
     224              :     Flat                = 0x2,
     225              :     Natural             = 0x3,
     226              :     DoubleSharp         = 0x4,
     227              :     DoubleFlat          = 0x5,
     228              :     Sharp_Caution       = 0x9,
     229              :     Flat_Caution        = 0xA,
     230              :     Natural_Caution     = 0xB,
     231              :     DoubleSharp_Caution = 0xC,
     232              :     DoubleFlat_Caution  = 0xD
     233              : };
     234              : 
     235              : enum class NoteHeadType : char {
     236              :     Standard = 0x00,
     237              :     Invisible,
     238              :     Rhythmic_Slash,
     239              :     Percussion,
     240              :     Closed_Rhythm,
     241              :     Open_Rhythm,
     242              :     Closed_Slash,
     243              :     Open_Slash,
     244              :     Closed_Do,
     245              :     Open_Do,
     246              :     Closed_Re,
     247              :     Open_Re,
     248              :     Closed_Mi,
     249              :     Open_Mi,
     250              :     Closed_Fa,
     251              :     Open_Fa,
     252              :     Closed_Sol,
     253              :     Open_Sol,
     254              :     Closed_La,
     255              :     Open_La,
     256              :     Closed_Ti,
     257              :     Open_Ti
     258              : };
     259              : 
     260              : enum class TiePos : char {
     261              :     None     = 0x0,
     262              :     LeftEnd  = 0x1,
     263              :     RightEnd = 0x2
     264              : };
     265              : 
     266              : enum class ArticulationType : char {
     267              :     Major_Trill                  = 0x00,
     268              :     Minor_Trill                  = 0x01,
     269              :     Trill_Section                = 0x02,
     270              :     Inverted_Short_Mordent       = 0x03,
     271              :     Inverted_Long_Mordent        = 0x04,
     272              :     Short_Mordent                = 0x05,
     273              :     Turn                         = 0x06,
     274              :     Finger_1                     = 0x07,
     275              :     Finger_2                     = 0x08,
     276              :     Finger_3                     = 0x09,
     277              :     Finger_4                     = 0x0A,
     278              :     Finger_5                     = 0x0B,
     279              :     Flat_Accidental_For_Trill    = 0x0C,
     280              :     Sharp_Accidental_For_Trill   = 0x0D,
     281              :     Natural_Accidental_For_Trill = 0x0E,
     282              :     Marcato                      = 0x0F,
     283              :     Marcato_Dot                  = 0x10,
     284              :     Heavy_Attack                 = 0x11,
     285              :     SForzando                    = 0x12,
     286              :     SForzando_Dot                = 0x13,
     287              :     Heavier_Attack               = 0x14,
     288              :     SForzando_Inverted           = 0x15,
     289              :     SForzando_Dot_Inverted       = 0x16,
     290              :     Staccatissimo                = 0x17,
     291              :     Staccato                     = 0x18,
     292              :     Tenuto                       = 0x19,
     293              :     Up_Bow                       = 0x1A,
     294              :     Down_Bow                     = 0x1B,
     295              :     Up_Bow_Inverted              = 0x1C,
     296              :     Down_Bow_Inverted            = 0x1D,
     297              :     Arpeggio                     = 0x1E,
     298              :     Tremolo_Eighth               = 0x1F,
     299              :     Tremolo_Sixteenth            = 0x20,
     300              :     Tremolo_Thirty_Second        = 0x21,
     301              :     Tremolo_Sixty_Fourth         = 0x22,
     302              :     Natural_Harmonic             = 0x23,
     303              :     Artificial_Harmonic          = 0x24,
     304              :     Plus_Sign                    = 0x25,
     305              :     Fermata                      = 0x26,
     306              :     Fermata_Inverted             = 0x27,
     307              :     Pedal_Down                   = 0x28,
     308              :     Pedal_Up                     = 0x29,
     309              :     Pause                        = 0x2A,
     310              :     Grand_Pause                  = 0x2B,
     311              :     Toe_Pedal                    = 0x2C,
     312              :     Heel_Pedal                   = 0x2D,
     313              :     Toe_To_Heel_Pedal            = 0x2E,
     314              :     Heel_To_Toe_Pedal            = 0x2F,
     315              :     Open_String                  = 0x30, // finger 0 in guitar
     316              :     Guitar_Lift                  = 0x46,
     317              :     Guitar_Slide_Up              = 0x47,
     318              :     Guitar_Rip                   = 0x48,
     319              :     Guitar_Fall_Off              = 0x49,
     320              :     Guitar_Slide_Down            = 0x4A,
     321              :     Guitar_Spill                 = 0x4B,
     322              :     Guitar_Flip                  = 0x4C,
     323              :     Guitar_Smear                 = 0x4D,
     324              :     Guitar_Bend                  = 0x4E,
     325              :     Guitar_Doit                  = 0x4F,
     326              :     Guitar_Plop                  = 0x50,
     327              :     Guitar_Wow_Wow               = 0x51,
     328              :     Guitar_Thumb                 = 0x64,
     329              :     Guitar_Index_Finger          = 0x65,
     330              :     Guitar_Middle_Finger         = 0x66,
     331              :     Guitar_Ring_Finger           = 0x67,
     332              :     Guitar_Pinky_Finger          = 0x68,
     333              :     Guitar_Tap                   = 0x69,
     334              :     Guitar_Hammer                = 0x6A,
     335              :     Guitar_Pluck                 = 0x6B,
     336              : 
     337              :     None
     338              : 
     339              :     /*
     340              :     Detached_Legato,
     341              :     Spiccato,
     342              :     Scoop,
     343              :     Plop,
     344              :     Doit,
     345              :     Falloff,
     346              :     Breath_Mark,
     347              :     Caesura
     348              :     */
     349              : };
     350              : 
     351              : enum class NoteType : char {
     352              :     Note_DoubleWhole = 0x0,
     353              :     Note_Whole       = 0x1,
     354              :     Note_Half        = 0x2,
     355              :     Note_Quarter     = 0x3,
     356              :     Note_Eight       = 0x4,
     357              :     Note_Sixteen     = 0x5,
     358              :     Note_32          = 0x6,
     359              :     Note_64          = 0x7,
     360              :     Note_128         = 0x8,
     361              :     Note_256         = 0x9,
     362              : //  Note_512         = 0xa,
     363              : //  Note_1024        = 0xb,
     364              : 
     365              :     Note_None
     366              : };
     367              : 
     368            0 : inline int NoteTypeToTick(NoteType type, int quarter)
     369              : {
     370            0 :     int c = int(pow(2.0, int(type)));
     371            0 :     return quarter * 4 * 2 / c;
     372              : }
     373              : 
     374              : enum class DynamicsType : char {
     375              :     PPPP = 0,
     376              :     PPP,
     377              :     PP,
     378              :     P,
     379              :     MP,
     380              :     MF,
     381              :     F,
     382              :     FF,
     383              :     FFF,
     384              :     FFFF,
     385              :     SF,
     386              :     FZ,
     387              :     SFZ,
     388              :     SFFZ,
     389              :     FP,
     390              :     SFP
     391              : };
     392              : 
     393              : enum class WedgeType : char {
     394              :     Cresc_Line = 0, // <
     395              :     Double_Line,    // <>, not appear in xml
     396              :     Dim_Line,       // >
     397              :     Cresc,          // cresc., not appear in xml, will create Expression
     398              :     Dim             // dim., not appear in xml, will create Expression
     399              : };
     400              : 
     401              : enum class KuoHaoType : char {
     402              :     Parentheses = 0,
     403              :     Brace,
     404              :     Bracket
     405              : };
     406              : 
     407              : enum class OctaveShiftType : char {
     408              :     OS_8 = 0,
     409              :     OS_Minus_8,
     410              :     OS_15,
     411              :     OS_Minus_15
     412              : };
     413              : 
     414              : enum class OctaveShiftPosition : char {
     415              :     Start = 0,
     416              :     Continue,
     417              :     Stop
     418              : };
     419              : 
     420              : enum class RepeatType : char {
     421              :     Segno = 0,
     422              :     Coda,
     423              :     ToCoda,
     424              :     DSAlCoda,
     425              :     DSAlFine,
     426              :     DCAlCoda,
     427              :     DCAlFine,
     428              :     Fine,
     429              : 
     430              :     Null
     431              : };
     432              : 
     433              : enum class BarLineType : char {
     434              :     Default = 0, // 0x00 will be | or final (at last measure)
     435              :     Double,      // 0x01 ||
     436              :     RepeatLeft,  // 0x02 ||:
     437              :     RepeatRight, // 0x03 :||
     438              :     Final,       // 0x04
     439              :     Dashed,      // 0x05
     440              :     Null         // 0x06
     441              : };
     442              : 
     443              : enum class NoteDuration {
     444              :     D_256 = 15,
     445              :     D_128 = D_256 * 2,           // 30
     446              :     D_64 = D_128 * 2,            // 60
     447              :     D_32 = D_64 * 2,             // 120
     448              :     D_16 = D_32 * 2,             // 240
     449              :     D_8 = D_16 * 2,              // 480
     450              :     D_4 = D_8 * 2,               // 960
     451              :     D_2 = D_4 * 2,               // 1920
     452              :     D_Whole = D_2 * 2,           // 3840
     453              :     D_Double_Whole = D_Whole * 2 // 7680
     454              : };
     455              : 
     456              : enum class ToneType : char {
     457              :     C = 0,
     458              :     D,
     459              :     E,
     460              :     F,
     461              :     G,
     462              :     A,
     463              :     B
     464              : };
     465              : 
     466              : enum class KeyType : char {
     467              :     Key_C = 0,   // C
     468              :     Key_Bass_1,  // F
     469              :     Key_Bass_2,  // Bb
     470              :     Key_Bass_3,  // Eb
     471              :     Key_Bass_4,  // Ab
     472              :     Key_Bass_5,  // Db
     473              :     Key_Bass_6,  // Gb
     474              :     Key_Bass_7,  // Cb
     475              :     Key_Sharp_1, // G
     476              :     Key_Sharp_2, // D
     477              :     Key_Sharp_3, // A
     478              :     Key_Sharp_4, // E
     479              :     Key_Sharp_5, // B
     480              :     Key_Sharp_6, // F#
     481              :     Key_Sharp_7  // C#
     482              : };
     483              : 
     484              : // IOveNotify.h
     485              : class IOveNotify
     486              : {
     487              : public:
     488              :     IOveNotify() {}
     489              :     virtual ~IOveNotify() {}
     490              : 
     491              : public:
     492              :     virtual void loadInfo(const QString& info) = 0;
     493              :     virtual void loadError() = 0;
     494              :     virtual void loadPosition(int currentMeasure, int totalMeasure, int currentTrack, int totalTrack) = 0;
     495              : };
     496              : 
     497              : class IOVEStreamLoader
     498              : {
     499              : public:
     500            4 :     IOVEStreamLoader() {}
     501            4 :     virtual ~IOVEStreamLoader() {}
     502              : 
     503              : public:
     504              :     virtual void setNotify(IOveNotify* notify) = 0;
     505              :     virtual void setFileStream(unsigned char* buffer, unsigned int size) = 0;
     506              :     virtual void setOve(OveSong* ove) = 0;
     507              : 
     508              :     // read stream, set read data to setOve(ove)
     509              :     virtual bool load() = 0;
     510              : 
     511              :     virtual void release() = 0;
     512              : };
     513              : 
     514              : DLL_EXPORT IOVEStreamLoader* createOveStreamLoader();
     515              : 
     516              : // basic element
     517              : class TickElement
     518              : {
     519              : public:
     520              :     TickElement();
     521           93 :     virtual ~TickElement() {}
     522              : 
     523              : public:
     524              :     void setTick(int tick);
     525              :     int getTick(void) const;
     526              : 
     527              : private:
     528              :     int m_tick;
     529              : };
     530              : 
     531              : class MeasurePos
     532              : {
     533              : public:
     534              :     MeasurePos();
     535          372 :     virtual ~MeasurePos() {}
     536              : 
     537              : public:
     538              :     void setMeasure(int measure);
     539              :     int getMeasure() const;
     540              : 
     541              :     void setOffset(int offset);
     542              :     int getOffset() const;
     543              : 
     544              :     MeasurePos shiftMeasure(int measure) const;
     545              :     MeasurePos shiftOffset(int offset) const; // ignore cross measure
     546              : 
     547              :     bool operator==(const MeasurePos& mp) const;
     548              :     bool operator!=(const MeasurePos& mp) const;
     549              :     bool operator<(const MeasurePos& mp) const;
     550              :     bool operator<=(const MeasurePos& mp) const;
     551              :     bool operator>(const MeasurePos& mp) const;
     552              :     bool operator>=(const MeasurePos& mp) const;
     553              : 
     554              : private:
     555              :     int m_measure;
     556              :     int m_offset;
     557              : };
     558              : 
     559              : class PairElement
     560              : {
     561              : public:
     562              :     PairElement();
     563              :     virtual ~PairElement();
     564              : 
     565              : public:
     566              :     MeasurePos* start() const;
     567              :     MeasurePos* stop() const;
     568              : 
     569              : private:
     570              :     MeasurePos* m_start;
     571              :     MeasurePos* m_stop;
     572              : };
     573              : 
     574              : class PairEnds
     575              : {
     576              : public:
     577              :     PairEnds();
     578              :     virtual ~PairEnds();
     579              : 
     580              : public:
     581              :     LineElement* getLeftLine() const;
     582              :     LineElement* getRightLine() const;
     583              : 
     584              :     OffsetElement* getLeftShoulder() const;
     585              :     OffsetElement* getRightShoulder() const;
     586              : 
     587              : private:
     588              :     LineElement* m_leftLine;
     589              :     LineElement* m_rightLine;
     590              :     OffsetElement* m_leftShoulder;
     591              :     OffsetElement* m_rightShoulder;
     592              : };
     593              : 
     594              : class LineElement
     595              : {
     596              : public:
     597              :     LineElement();
     598           54 :     virtual ~LineElement() {}
     599              : 
     600              : public:
     601              :     virtual void setLine(int line); // middle line (3rd line of each clef) is set 0
     602              :     virtual int getLine(void) const;
     603              : 
     604              : private:
     605              :     int m_line;
     606              : };
     607              : 
     608              : class OffsetElement
     609              : {
     610              : public:
     611              :     OffsetElement();
     612          135 :     virtual ~OffsetElement() {}
     613              : 
     614              : public:
     615              :     virtual void setXOffset(int offset);
     616              :     virtual int getXOffset() const;
     617              : 
     618              :     virtual void setYOffset(int offset);
     619              :     virtual int getYOffset() const;
     620              : 
     621              : private:
     622              :     int m_xOffset;
     623              :     int m_yOffset;
     624              : };
     625              : 
     626              : class LengthElement
     627              : {
     628              : public:
     629              :     LengthElement();
     630           30 :     virtual ~LengthElement() {}
     631              : 
     632              : public:
     633              :     void setLength(int length);
     634              :     int getLength() const;
     635              : 
     636              : private:
     637              :     int m_length; // tick
     638              : };
     639              : 
     640              : // base class of many ove music element
     641              : class MusicData : public TickElement, public PairElement, public OffsetElement
     642              : {
     643              : public:
     644              :     MusicData();
     645           93 :     virtual ~MusicData() {}
     646              : 
     647              : public:
     648              :     MusicDataType getMusicDataType() const;
     649              : 
     650              :     enum class XmlDataType : char {
     651              :         Attributes = 0, NoteBeam, Notations, Direction, None
     652              :     };
     653              :     static XmlDataType getXmlDataType(MusicDataType type);
     654              :     // static bool get_is_pair_element(MusicDataType type) ;
     655              : 
     656              :     // show / hide
     657              :     void setShow(bool show);
     658              :     bool getShow() const;
     659              : 
     660              :     // color
     661              :     void setColor(unsigned int color); // not exists in ove 3
     662              :     unsigned int getColor() const;
     663              : 
     664              :     void setVoice(unsigned int voice);
     665              :     unsigned int getVoice() const;
     666              : 
     667              :     void copyCommonBlock(const MusicData& source);
     668              : 
     669              : protected:
     670              :     MusicDataType m_musicDataType;
     671              : 
     672              : private:
     673              :     bool m_show;
     674              :     unsigned int m_color;
     675              :     unsigned int m_voice;
     676              : };
     677              : 
     678              : class MidiData : public TickElement
     679              : {
     680              : public:
     681              :     MidiData();
     682            0 :     virtual ~MidiData() {}
     683              : 
     684              : public:
     685              :     MidiType getMidiType() const;
     686              : 
     687              : protected:
     688              :     MidiType m_midiType;
     689              : };
     690              : 
     691              : class OveSong
     692              : {
     693              : public:
     694              :     OveSong();
     695              :     ~OveSong();
     696              : 
     697              : public:
     698              :     void setIsVersion4(bool version4 = true);
     699              :     bool getIsVersion4() const;
     700              : 
     701              :     void setQuarter(int tick);
     702              :     int getQuarter(void) const;
     703              : 
     704              :     void setShowPageMargin(bool show);
     705              :     bool getShowPageMargin() const;
     706              : 
     707              :     void setShowTransposeTrack(bool show);
     708              :     bool getShowTransposeTrack() const;
     709              : 
     710              :     void setShowLineBreak(bool show);
     711              :     bool getShowLineBreak() const;
     712              : 
     713              :     void setShowRuler(bool show);
     714              :     bool getShowRuler() const;
     715              : 
     716              :     void setShowColor(bool show);
     717              :     bool getShowColor() const;
     718              : 
     719              :     void setPlayRepeat(bool play);
     720              :     bool getPlayRepeat() const;
     721              : 
     722              :     enum class PlayStyle : char {
     723              :         Record, Swing, Notation
     724              :     };
     725              :     void setPlayStyle(PlayStyle style);
     726              :     PlayStyle getPlayStyle() const;
     727              : 
     728              :     void addTitle(const QString& str);
     729              :     QList<QString> getTitles(void) const;
     730              : 
     731              :     void addAnnotate(const QString& str);
     732              :     QList<QString> getAnnotates(void) const;
     733              : 
     734              :     void addWriter(const QString& str);
     735              :     QList<QString> getWriters(void) const;
     736              : 
     737              :     void addCopyright(const QString& str);
     738              :     QList<QString> getCopyrights(void) const;
     739              : 
     740              :     void addHeader(const QString& str);
     741              :     QList<QString> getHeaders(void) const;
     742              : 
     743              :     void addFooter(const QString& str);
     744              :     QList<QString> getFooters(void) const;
     745              : 
     746              :     void addTrack(Track* ptr);
     747              :     int getTrackCount(void) const;
     748              :     QList<Track*> getTracks() const;
     749              :     Track* getTrack(int part, int staff) const;
     750              : 
     751              :     void setTrackBarCount(int count);
     752              :     int getTrackBarCount() const;
     753              : 
     754              :     bool addPage(Page* page);
     755              :     int getPageCount() const;
     756              :     Page* getPage(int idx);
     757              : 
     758              :     void addLine(Line* ptr);
     759              :     int getLineCount() const;
     760              :     Line* getLine(int idx) const;
     761              : 
     762              :     void addMeasure(Measure* ptr);
     763              :     int getMeasureCount(void) const;
     764              :     Measure* getMeasure(int bar) const;
     765              : 
     766              :     void addMeasureData(MeasureData* ptr);
     767              :     int getMeasureDataCount(void) const;
     768              :     MeasureData* getMeasureData(int part, int staff /* = 0 */, int bar) const;
     769              :     MeasureData* getMeasureData(int track, int bar) const;
     770              : 
     771              :     // tool
     772              :     void setPartStaffCounts(const QList<int>& partStaffCounts);
     773              :     int getPartCount() const;
     774              :     int getStaffCount(int part) const;
     775              :     int getPartBarCount() const;
     776              : 
     777              :     void clear(void);
     778              : 
     779              :     QPair<int, int> trackToPartStaff(int track) const;
     780              : 
     781              :     void setTextCodecName(const QString& codecName);
     782              :     QString getCodecString(const QByteArray& text);
     783              : 
     784              : private:
     785              :     int partStaffToTrack(int part, int staff) const;
     786              : 
     787              : private:
     788              :     bool m_version4;
     789              :     int m_quarter;
     790              : 
     791              :     bool m_showPageMargin;
     792              :     bool m_showTransposeTrack;
     793              :     bool m_showLineBreak;
     794              :     bool m_showRuler;
     795              :     bool m_showColor;
     796              :     bool m_playRepeat;
     797              :     PlayStyle m_playStyle;
     798              : 
     799              :     QList<QString> m_titles;
     800              :     QList<QString> m_annotates;
     801              :     QList<QString> m_writers;
     802              :     QList<QString> m_copyrights;
     803              :     QList<QString> m_headers;
     804              :     QList<QString> m_footers;
     805              : 
     806              :     QList<Track*> m_tracks;
     807              :     QList<Page*> m_pages;
     808              :     QList<Line*> m_lines;
     809              :     QList<Measure*> m_measures;
     810              :     QList<MeasureData*> m_measureDatas;
     811              :     int m_trackBarCount; // equal to m_measures.size()
     812              : 
     813              :     QList<int> m_partStaffCounts;
     814              :     QTextCodec* m_codec;
     815              : };
     816              : 
     817              : class Voice
     818              : {
     819              : public:
     820              :     Voice();
     821           32 :     ~Voice() {}
     822              : 
     823              : public:
     824              :     void setChannel(int channel);
     825              :     int getChannel() const;
     826              : 
     827              :     void setVolume(int volume);
     828              :     int getVolume() const;
     829              : 
     830              :     void setPitchShift(int pitchShift);
     831              :     int getPitchShift() const;
     832              : 
     833              :     void setPan(int pan);
     834              :     int getPan() const;
     835              : 
     836              :     void setPatch(int patch);
     837              :     int getPatch() const;
     838              : 
     839              :     void setStemType(int stemType);
     840              :     int getStemType() const;
     841              : 
     842              :     static int getDefaultPatch();
     843              :     static int getDefaultVolume();
     844              : 
     845              : private:
     846              :     int m_channel;    // [0, 15]
     847              :     int m_volume;     // [-1, 127], -1 default
     848              :     int m_pitchShift; // [-36, 36]
     849              :     int m_pan;        // [-64, 63]
     850              :     int m_patch;      // [0, 127]
     851              :     int m_stemType;   // 0, 1, 2
     852              : };
     853              : 
     854              : class Track
     855              : {
     856              : public:
     857              :     Track();
     858              :     ~Track();
     859              : 
     860              : public:
     861              :     void setName(const QString& str);
     862              :     QString getName(void) const;
     863              : 
     864              :     void setBriefName(const QString& str);
     865              :     QString getBriefName(void) const;
     866              : 
     867              :     void setPatch(unsigned int patch); // -1: percussion
     868              :     unsigned int getPatch() const;
     869              : 
     870              :     void setChannel(int channel);
     871              :     int getChannel() const;
     872              : 
     873              :     void setShowName(bool show);
     874              :     bool getShowName() const;
     875              : 
     876              :     void setShowBriefName(bool show);
     877              :     bool getShowBriefName() const;
     878              : 
     879              :     void setMute(bool mute);
     880              :     bool getMute() const;
     881              : 
     882              :     void setSolo(bool solo);
     883              :     bool getSolo() const;
     884              : 
     885              :     void setShowKeyEachLine(bool show);
     886              :     bool getShowKeyEachLine() const;
     887              : 
     888              :     void setVoiceCount(int voices);
     889              :     int getVoiceCount() const;
     890              : 
     891              :     void addVoice(Voice* voice);
     892              :     QList<Voice*> getVoices() const;
     893              : 
     894              :     void setShowTranspose(bool show);
     895              :     bool getShowTranspose() const;
     896              : 
     897              :     void setTranspose(int transpose);
     898              :     int getTranspose() const;
     899              : 
     900              :     void setNoteShift(int shift);
     901              :     int getNoteShift() const;
     902              : 
     903              :     void setStartClef(int clef /* in ClefType */);
     904              :     ClefType getStartClef() const;
     905              : 
     906              :     void setTransposeClef(int clef /* in ClefType */);
     907              :     ClefType getTransposeClef() const;
     908              : 
     909              :     void setStartKey(int key /* in KeyType */);
     910              :     int getStartKey() const;
     911              : 
     912              :     void setDisplayPercent(unsigned int percent /* 25~100 */);
     913              :     unsigned int getDisplayPercent() const;
     914              : 
     915              :     void setShowLegerLine(bool show);
     916              :     bool getShowLegerLine() const;
     917              : 
     918              :     void setShowClef(bool show);
     919              :     bool getShowClef() const;
     920              : 
     921              :     void setShowTimeSignature(bool show);
     922              :     bool getShowTimeSignature() const;
     923              : 
     924              :     void setShowKeySignature(bool show);
     925              :     bool getShowKeySignature() const;
     926              : 
     927              :     void setShowBarline(bool show);
     928              :     bool getShowBarline() const;
     929              : 
     930              :     void setFillWithRest(bool fill);
     931              :     bool getFillWithRest() const;
     932              : 
     933              :     void setFlatTail(bool flat);
     934              :     bool getFlatTail() const;
     935              : 
     936              :     void setShowClefEachLine(bool show);
     937              :     bool getShowClefEachLine() const;
     938              : 
     939              :     struct DrumNode {
     940              :         int m_line;
     941              :         int m_headType;
     942              :         int m_pitch;
     943              :         int m_voice;
     944              : 
     945              :     public:
     946           64 :         DrumNode()
     947           64 :             : m_line(0), m_headType(0), m_pitch(0), m_voice(0) {}
     948              :     };
     949              :     void addDrum(const DrumNode& node);
     950              :     QList<DrumNode> getDrumKit() const;
     951              : 
     952              :     void clear(void);
     953              : 
     954              :     void setPart(int part);
     955              :     int getPart() const;
     956              : 
     957              : private:
     958              :     int m_number;
     959              :     QString m_name;
     960              :     QString m_briefName;
     961              :     unsigned int m_patch;
     962              :     int m_channel;
     963              :     int m_transpose;
     964              :     bool m_showTranspose;
     965              :     int m_noteShift;
     966              :     ClefType m_startClef;
     967              :     ClefType m_transposeClef;
     968              :     unsigned int m_displayPercent;
     969              :     int m_startKey;
     970              :     int m_voiceCount;
     971              :     QList<Voice*> m_voices;
     972              : 
     973              :     bool m_showName;
     974              :     bool m_showBriefName;
     975              :     bool m_showKeyEachLine;
     976              :     bool m_showLegerLine;
     977              :     bool m_showClef;
     978              :     bool m_showTimeSignature;
     979              :     bool m_showKeySignature;
     980              :     bool m_showBarline;
     981              :     bool m_showClefEachLine;
     982              : 
     983              :     bool m_fillWithRest;
     984              :     bool m_flatTail;
     985              : 
     986              :     bool m_mute;
     987              :     bool m_solo;
     988              : 
     989              :     QList<DrumNode> m_drumKit;
     990              : 
     991              :     int m_part;
     992              : };
     993              : 
     994              : class Page
     995              : {
     996              : public:
     997              :     Page();
     998            4 :     ~Page() {}
     999              : 
    1000              : public:
    1001              :     void setBeginLine(int line);
    1002              :     int getBeginLine() const;
    1003              : 
    1004              :     void setLineCount(int count);
    1005              :     int getLineCount() const;
    1006              : 
    1007              :     void setLineInterval(int interval); // between system
    1008              :     int getLineInterval() const;
    1009              : 
    1010              :     void setStaffInterval(int interval);
    1011              :     int getStaffInterval() const;
    1012              : 
    1013              :     void setStaffInlineInterval(int interval); // between treble-bass staff
    1014              :     int getStaffInlineInterval() const;
    1015              : 
    1016              :     void setLineBarCount(int count);
    1017              :     int getLineBarCount() const;
    1018              : 
    1019              :     void setPageLineCount(int count);
    1020              :     int getPageLineCount() const;
    1021              : 
    1022              :     void setLeftMargin(int margin);
    1023              :     int getLeftMargin() const;
    1024              : 
    1025              :     void setTopMargin(int margin);
    1026              :     int getTopMargin() const;
    1027              : 
    1028              :     void setRightMargin(int margin);
    1029              :     int getRightMargin() const;
    1030              : 
    1031              :     void setBottomMargin(int margin);
    1032              :     int getBottomMargin() const;
    1033              : 
    1034              :     void setPageWidth(int width);
    1035              :     int getPageWidth() const;
    1036              : 
    1037              :     void setPageHeight(int height);
    1038              :     int getPageHeight() const;
    1039              : 
    1040              : private:
    1041              :     int m_beginLine;
    1042              :     int m_lineCount;
    1043              : 
    1044              :     int m_lineInterval;
    1045              :     int m_staffInterval;
    1046              :     int m_staffInlineInterval;
    1047              : 
    1048              :     int m_lineBarCount;
    1049              :     int m_pageLineCount;
    1050              : 
    1051              :     int m_leftMargin;
    1052              :     int m_topMargin;
    1053              :     int m_rightMargin;
    1054              :     int m_bottomMargin;
    1055              : 
    1056              :     int m_pageWidth;
    1057              :     int m_pageHeight;
    1058              : };
    1059              : 
    1060              : class Line
    1061              : {
    1062              : public:
    1063              :     Line();
    1064              :     ~Line();
    1065              : 
    1066              : public:
    1067              :     void addStaff(Staff* staff);
    1068              :     int getStaffCount() const;
    1069              :     Staff* getStaff(int idx) const;
    1070              : 
    1071              :     void setBeginBar(unsigned int bar);
    1072              :     unsigned int getBeginBar() const;
    1073              : 
    1074              :     void setBarCount(unsigned int count);
    1075              :     unsigned int getBarCount() const;
    1076              : 
    1077              :     void setYOffset(int offset);
    1078              :     int getYOffset() const;
    1079              : 
    1080              :     void setLeftXOffset(int offset);
    1081              :     int getLeftXOffset() const;
    1082              : 
    1083              :     void setRightXOffset(int offset);
    1084              :     int getRightXOffset() const;
    1085              : 
    1086              : private:
    1087              :     QList<Staff*> m_staves;
    1088              :     unsigned int m_beginBar;
    1089              :     unsigned int m_barCount;
    1090              :     int m_yOffset;
    1091              :     int m_leftXOffset;
    1092              :     int m_rightXOffset;
    1093              : };
    1094              : 
    1095              : class Staff : public OffsetElement
    1096              : {
    1097              : public:
    1098              :     Staff();
    1099           12 :     virtual ~Staff() {}
    1100              : 
    1101              : public:
    1102              :     void setClefType(int clef);
    1103              :     ClefType getClefType() const;
    1104              : 
    1105              :     void setKeyType(int key);
    1106              :     int getKeyType() const;
    1107              : 
    1108              :     void setVisible(bool visible);
    1109              :     bool setVisible() const;
    1110              : 
    1111              :     void setGroupType(GroupType type);
    1112              :     GroupType getGroupType() const;
    1113              : 
    1114              :     void setGroupStaffCount(int count);
    1115              :     int getGroupStaffCount() const;
    1116              : 
    1117              : private:
    1118              :     ClefType m_clef;
    1119              :     int m_key;
    1120              :     bool m_visible;
    1121              :     GroupType m_groupType;
    1122              :     int m_groupStaffCount;
    1123              : };
    1124              : 
    1125              : class Note : public LineElement
    1126              : {
    1127              : public:
    1128              :     Note();
    1129           24 :     virtual ~Note() {}
    1130              : 
    1131              : public:
    1132              :     void setIsRest(bool rest);
    1133              :     bool getIsRest() const;
    1134              : 
    1135              :     void setNote(unsigned int note);
    1136              :     unsigned int getNote() const;
    1137              : 
    1138              :     void setAccidental(int type); // AccidentalType
    1139              :     AccidentalType getAccidental() const;
    1140              : 
    1141              :     void setShowAccidental(bool show);
    1142              :     bool getShowAccidental() const;
    1143              : 
    1144              :     void setOnVelocity(unsigned int velocity);
    1145              :     unsigned int getOnVelocity() const;
    1146              : 
    1147              :     void setOffVelocity(unsigned int velocity);
    1148              :     unsigned int getOffVelocity() const;
    1149              : 
    1150              :     void setHeadType(int type); // NoteHeadType
    1151              :     NoteHeadType getHeadType() const;
    1152              : 
    1153              :     void setTiePos(int tiePos);
    1154              :     TiePos getTiePos() const;
    1155              : 
    1156              :     void setOffsetStaff(int offset); // cross staff notes
    1157              :     int getOffsetStaff() const;
    1158              : 
    1159              :     void setShow(bool show);
    1160              :     bool getShow() const;
    1161              : 
    1162              :     void setOffsetTick(int offset);
    1163              :     int getOffsetTick() const;
    1164              : 
    1165              : private:
    1166              :     bool m_rest;
    1167              :     unsigned int m_note;
    1168              :     AccidentalType m_accidental;
    1169              :     bool m_showAccidental;
    1170              :     unsigned int m_onVelocity;
    1171              :     unsigned int m_offVelocity;
    1172              :     NoteHeadType m_headType;
    1173              :     TiePos m_tiePos;
    1174              :     int m_offsetStaff;
    1175              :     bool m_show;
    1176              :     int m_offsetTick; // for playback
    1177              : };
    1178              : 
    1179              : class Articulation : public OffsetElement
    1180              : {
    1181              : public:
    1182              :     Articulation();
    1183            0 :     virtual ~Articulation() {}
    1184              : 
    1185              : public:
    1186              :     void setArtType(int type); // ArticulationType
    1187              :     ArticulationType getArtType() const;
    1188              : 
    1189              :     void setPlacementAbove(bool above);
    1190              :     bool getPlacementAbove() const;
    1191              : 
    1192              :     // for midi
    1193              :     bool willAffectNotes() const;
    1194              : 
    1195              :     static bool isTrill(ArticulationType type);
    1196              : 
    1197              :     // for xml
    1198              :     enum class XmlType : char {
    1199              :         Articulation,
    1200              :         Technical,
    1201              :         Arpeggiate,
    1202              :         Ornament,
    1203              :         Fermata,
    1204              :         Direction,
    1205              : 
    1206              :         Unknown
    1207              :     };
    1208              :     XmlType getXmlType() const;
    1209              : 
    1210              :     // sound setting
    1211              :     bool getChangeSoundEffect() const;
    1212              :     void setSoundEffect(int soundFrom, int soundTo);
    1213              :     QPair<int, int> getSoundEffect() const;
    1214              : 
    1215              :     bool getChangeLength() const;
    1216              :     void setLengthPercentage(int percentage);
    1217              :     int getLengthPercentage() const;
    1218              : 
    1219              :     bool getChangeVelocity() const;
    1220              :     enum class VelocityType : char {
    1221              :         Offset,
    1222              :         SetValue,
    1223              :         Percentage
    1224              :     };
    1225              :     void setVelocityType(VelocityType type);
    1226              :     VelocityType getVelocityType() const;
    1227              : 
    1228              :     void setVelocityValue(int value);
    1229              :     int getVelocityValue() const;
    1230              : 
    1231              :     bool getChangeExtraLength() const;
    1232              :     void setExtraLength(int length);
    1233              :     int getExtraLength() const;
    1234              : 
    1235              :     // trill
    1236              :     enum class TrillInterval : char {
    1237              :         Diatonic = 0,
    1238              :         Chromatic,
    1239              :         Whole
    1240              :     };
    1241              :     void setTrillInterval(int interval);
    1242              :     TrillInterval getTrillInterval() const;
    1243              : 
    1244              :     void setAuxiliaryFirst(bool first);
    1245              :     bool getAuxiliaryFirst() const;
    1246              : 
    1247              :     void setTrillRate(NoteType rate);
    1248              :     NoteType getTrillRate() const;
    1249              : 
    1250              :     void setTrillNoteLength(int length);
    1251              :     int getTrillNoteLength() const;
    1252              : 
    1253              :     enum class AccelerateType : char {
    1254              :         None = 0,
    1255              :         Slow,
    1256              :         Normal,
    1257              :         Fast
    1258              :     };
    1259              :     void setAccelerateType(int type);
    1260              :     AccelerateType getAccelerateType() const;
    1261              : 
    1262              : private:
    1263              :     ArticulationType m_type;
    1264              :     bool m_above;
    1265              : 
    1266              :     bool m_changeSoundEffect;
    1267              :     QPair<int, int> m_soundEffect;
    1268              :     bool m_changeLength;
    1269              :     int m_lengthPercentage;
    1270              :     bool m_changeVelocity;
    1271              :     VelocityType m_velocityType;
    1272              :     int m_velocityValue;
    1273              :     bool m_changeExtraLength;
    1274              :     int m_extraLength;
    1275              : 
    1276              :     // trill
    1277              :     TrillInterval m_trillInterval;
    1278              :     bool m_auxiliaryFirst;
    1279              :     NoteType m_trillRate;
    1280              :     int m_trillNoteLength;
    1281              :     AccelerateType m_accelerateType;
    1282              : };
    1283              : 
    1284              : class NoteContainer : public MusicData, public LengthElement
    1285              : {
    1286              : public:
    1287              :     NoteContainer();
    1288              :     virtual ~NoteContainer();
    1289              : 
    1290              : public:
    1291              :     void setIsGrace(bool grace);
    1292              :     bool getIsGrace() const;
    1293              : 
    1294              :     void setIsCue(bool cue);
    1295              :     bool getIsCue() const;
    1296              : 
    1297              :     void setIsRest(bool rest /* or note */);
    1298              :     bool getIsRest() const;
    1299              : 
    1300              :     void setIsRaw(bool raw);
    1301              :     bool getIsRaw() const;
    1302              : 
    1303              :     void setNoteType(NoteType type);
    1304              :     NoteType getNoteType() const;
    1305              : 
    1306              :     void setDot(int dot);
    1307              :     int getDot() const;
    1308              : 
    1309              :     void setGraceNoteType(NoteType type);
    1310              :     NoteType getGraceNoteType() const;
    1311              : 
    1312              :     void setInBeam(bool in);
    1313              :     bool getInBeam() const;
    1314              : 
    1315              :     void setStemUp(bool up);
    1316              :     bool getStemUp(void) const;
    1317              : 
    1318              :     void setShowStem(bool show);
    1319              :     bool getShowStem() const;
    1320              : 
    1321              :     void setStemLength(int line);
    1322              :     int getStemLength() const;
    1323              : 
    1324              :     void setTuplet(int tuplet);
    1325              :     int getTuplet() const;
    1326              : 
    1327              :     void setSpace(int space);
    1328              :     int getSpace() const;
    1329              : 
    1330              :     void addNoteRest(Note* note);
    1331              :     QList<Note*> getNotesRests() const;
    1332              : 
    1333              :     void addArticulation(Articulation* art);
    1334              :     QList<Articulation*> getArticulations() const;
    1335              : 
    1336              :     void setNoteShift(int octave);
    1337              :     int getNoteShift() const;
    1338              : 
    1339              :     int getOffsetStaff() const;
    1340              : 
    1341              :     int getDuration() const;
    1342              : 
    1343              : private:
    1344              :     bool m_grace;
    1345              :     bool m_cue;
    1346              :     bool m_rest;
    1347              :     bool m_raw;
    1348              :     NoteType m_noteType;
    1349              :     int m_dot;
    1350              :     NoteType m_graceNoteType;
    1351              :     int m_tuplet;
    1352              :     int m_space;
    1353              :     bool m_inBeam;
    1354              :     bool m_stemUp;
    1355              :     bool m_showStem;
    1356              :     int m_stemLength; // line count span
    1357              :     int m_noteShift;
    1358              : 
    1359              :     QList<Note*> m_notes;
    1360              :     QList<Articulation*> m_articulations;
    1361              : };
    1362              : 
    1363              : class Beam : public MusicData, public PairEnds
    1364              : {
    1365              : public:
    1366              :     Beam();
    1367            0 :     virtual ~Beam() {}
    1368              : 
    1369              : public:
    1370              :     void setIsGrace(bool grace);
    1371              :     bool getIsGrace() const;
    1372              : 
    1373              :     void addLine(const MeasurePos& startMp, const MeasurePos& endMp);
    1374              :     const QList<QPair<MeasurePos, MeasurePos> > getLines() const;
    1375              : 
    1376              : private:
    1377              :     bool m_grace;
    1378              :     QList<QPair<MeasurePos, MeasurePos> > m_lines;
    1379              : };
    1380              : 
    1381              : class Tie : public MusicData, public PairEnds
    1382              : {
    1383              : public:
    1384              :     Tie();
    1385            0 :     virtual ~Tie() {}
    1386              : 
    1387              : public:
    1388              :     void setShowOnTop(bool top);
    1389              :     bool getShowOnTop() const;
    1390              : 
    1391              :     void setNote(int note); // note value tie point to
    1392              :     int getNote() const;
    1393              : 
    1394              :     void setHeight(int height);
    1395              :     int getHeight() const;
    1396              : 
    1397              : private:
    1398              :     bool m_showOnTop;
    1399              :     int m_note;
    1400              :     int m_height;
    1401              : };
    1402              : 
    1403              : class Glissando : public MusicData, public PairEnds
    1404              : {
    1405              : public:
    1406              :     Glissando();
    1407            0 :     virtual ~Glissando() {}
    1408              : 
    1409              : public:
    1410              :     void setStraightWavy(bool straight);
    1411              :     bool getStraightWavy() const;
    1412              : 
    1413              :     void setText(const QString& text);
    1414              :     QString getText() const;
    1415              : 
    1416              :     void setLineThick(int thick);
    1417              :     int getLineThick() const;
    1418              : 
    1419              : private:
    1420              :     bool m_straight;
    1421              :     QString m_text;
    1422              :     int m_lineThick;
    1423              : };
    1424              : 
    1425              : class Decorator : public MusicData
    1426              : {
    1427              : public:
    1428              :     Decorator();
    1429            0 :     virtual ~Decorator() {}
    1430              : 
    1431              : public:
    1432              :     enum class Type : char {
    1433              :         Dotted_Barline = 0,
    1434              :         Articulation
    1435              :     };
    1436              :     void setDecoratorType(Type type);
    1437              :     Type getDecoratorType() const;
    1438              : 
    1439              :     void setArticulationType(ArticulationType type);
    1440              :     ArticulationType getArticulationType() const;
    1441              : 
    1442              : private:
    1443              :     Type m_decoratorType;
    1444              :     ArticulationType m_artType;
    1445              : };
    1446              : 
    1447              : class MeasureRepeat : public MusicData
    1448              : {
    1449              : public:
    1450              :     MeasureRepeat();
    1451            0 :     virtual ~MeasureRepeat() {}
    1452              : 
    1453              : public:
    1454              :     void setSingleRepeat(bool single); // false : double
    1455              :     bool getSingleRepeat() const;
    1456              : 
    1457              : private:
    1458              :     bool m_singleRepeat;
    1459              : };
    1460              : 
    1461              : class Tuplet : public MusicData, public PairEnds
    1462              : {
    1463              : public:
    1464              :     Tuplet();
    1465              :     virtual ~Tuplet();
    1466              : 
    1467              : public:
    1468              :     void setTuplet(int tuplet=3);
    1469              :     int getTuplet() const;
    1470              : 
    1471              :     void setSpace(int space=2);
    1472              :     int getSpace() const;
    1473              : 
    1474              :     void setHeight(int height);
    1475              :     int getHeight() const;
    1476              : 
    1477              :     void setNoteType(NoteType type);
    1478              :     NoteType getNoteType() const;
    1479              : 
    1480              :     OffsetElement* getMarkHandle() const;
    1481              : 
    1482              : private:
    1483              :     int m_tuplet;
    1484              :     int m_space;
    1485              :     int m_height;
    1486              :     NoteType m_noteType;
    1487              :     OffsetElement* m_mark;
    1488              : };
    1489              : 
    1490              : class Harmony : public MusicData, public LengthElement
    1491              : {
    1492              : public:
    1493              :     Harmony();
    1494            0 :     virtual ~Harmony() {}
    1495              : 
    1496              : public:
    1497              :     void setHarmonyType(QString type);
    1498              :     QString getHarmonyType() const;
    1499              : 
    1500              :     void setRoot(int root=0); // C
    1501              :     int getRoot() const;
    1502              : 
    1503              :     void setBass(int bass);
    1504              :     int getBass() const;
    1505              : 
    1506              :     void setAlterRoot(int val);
    1507              :     int getAlterRoot() const;
    1508              : 
    1509              :     void setAlterBass(int val);
    1510              :     int getAlterBass() const;
    1511              : 
    1512              :     void setBassOnBottom(bool on);
    1513              :     bool getBassOnBottom() const;
    1514              : 
    1515              :     void setAngle(int angle);
    1516              :     int getAngle() const;
    1517              : 
    1518              : private:
    1519              :     QString m_harmonyType;
    1520              :     int m_root;
    1521              :     int m_bass;
    1522              :     int m_alterRoot;
    1523              :     int m_alterBass;
    1524              :     bool m_bassOnBottom;
    1525              :     int m_angle;
    1526              : };
    1527              : 
    1528              : class Clef : public MusicData, public LineElement
    1529              : {
    1530              : public:
    1531              :     Clef();
    1532           36 :     virtual ~Clef() {}
    1533              : 
    1534              : public:
    1535              :     void setClefType(int type); // ClefType
    1536              :     ClefType getClefType() const;
    1537              : 
    1538              : private:
    1539              :     ClefType m_clefType;
    1540              : };
    1541              : 
    1542              : class Lyric : public MusicData
    1543              : {
    1544              : public:
    1545              :     Lyric();
    1546            0 :     virtual ~Lyric() {}
    1547              : 
    1548              : public:
    1549              :     void setLyric(const QString& lyricText);
    1550              :     QString getLyric() const;
    1551              : 
    1552              :     void setVerse(int verse);
    1553              :     int getVerse() const;
    1554              : 
    1555              : private:
    1556              :     QString m_lyric;
    1557              :     int m_verse;
    1558              : };
    1559              : 
    1560              : class Slur : public MusicData, public PairEnds
    1561              : {
    1562              : public:
    1563              :     Slur();
    1564              :     virtual ~Slur();
    1565              : 
    1566              : public:
    1567              :     void setContainerCount(int count); // span
    1568              :     int getContainerCount() const;
    1569              : 
    1570              :     void setShowOnTop(bool top);
    1571              :     bool getShowOnTop() const;
    1572              : 
    1573              :     OffsetElement* getHandle2() const;
    1574              :     OffsetElement* getHandle3() const;
    1575              : 
    1576              :     void setNoteTimePercent(int percent); // 50% ~ 200%
    1577              :     int getNoteTimePercent() const;
    1578              : 
    1579              : private:
    1580              :     int m_containerCount;
    1581              :     bool m_showOnTop;
    1582              :     int m_noteTimePercent;
    1583              :     OffsetElement* m_handle_2;
    1584              :     OffsetElement* m_handle_3;
    1585              : };
    1586              : 
    1587              : class Dynamics : public MusicData
    1588              : {
    1589              : public:
    1590              :     Dynamics();
    1591            0 :     virtual ~Dynamics() {}
    1592              : 
    1593              : public:
    1594              :     void setDynamicsType(int type); // DynamicsType
    1595              :     DynamicsType getDynamicsType() const;
    1596              : 
    1597              :     void setIsPlayback(bool play);
    1598              :     bool getIsPlayback() const;
    1599              : 
    1600              :     void setVelocity(int vel);
    1601              :     int getVelocity() const;
    1602              : 
    1603              : private:
    1604              :     DynamicsType m_dynamicsType;
    1605              :     bool m_playback;
    1606              :     int m_velocity;
    1607              : };
    1608              : 
    1609              : class WedgeEndPoint : public MusicData
    1610              : {
    1611              : public:
    1612              :     WedgeEndPoint();
    1613            0 :     virtual ~WedgeEndPoint() {}
    1614              : 
    1615              : public:
    1616              :     void setWedgeType(WedgeType type);
    1617              :     WedgeType getWedgeType() const;
    1618              : 
    1619              :     void setHeight(int height);
    1620              :     int getHeight() const;
    1621              : 
    1622              :     void setWedgeStart(bool wedgeStart);
    1623              :     bool getWedgeStart() const;
    1624              : 
    1625              : private:
    1626              :     int m_height;
    1627              :     WedgeType m_wedgeType;
    1628              :     bool m_wedgeStart;
    1629              : };
    1630              : 
    1631              : class Wedge : public MusicData
    1632              : {
    1633              : public:
    1634              :     Wedge();
    1635            0 :     virtual ~Wedge() {}
    1636              : 
    1637              : public:
    1638              :     void setWedgeType(WedgeType type);
    1639              :     WedgeType getWedgeType() const;
    1640              : 
    1641              :     void setHeight(int height);
    1642              :     int getHeight() const;
    1643              : 
    1644              : private:
    1645              :     int m_height;
    1646              :     WedgeType m_wedgeType;
    1647              : };
    1648              : 
    1649              : class Pedal : public MusicData, public PairEnds
    1650              : {
    1651              : public:
    1652              :     Pedal();
    1653              :     virtual ~Pedal();
    1654              : 
    1655              : public:
    1656              :     void setHalf(bool half);
    1657              :     bool getHalf() const;
    1658              : 
    1659              :     void setIsPlayback(bool playback);
    1660              :     bool getIsPlayback() const;
    1661              : 
    1662              :     void setPlayOffset(int offset); // -127~127
    1663              :     int getPlayOffset() const;
    1664              : 
    1665              :     OffsetElement* getPedalHandle() const; // only on half pedal
    1666              : 
    1667              : private:
    1668              :     bool m_half;
    1669              :     bool m_playback;
    1670              :     int m_playOffset;
    1671              :     OffsetElement* m_pedalHandle;
    1672              : };
    1673              : 
    1674              : class KuoHao : public MusicData, public PairEnds
    1675              : {
    1676              : public:
    1677              :     KuoHao();
    1678            0 :     virtual ~KuoHao() {}
    1679              : 
    1680              : public:
    1681              :     void setHeight(int height);
    1682              :     int getHeight() const;
    1683              : 
    1684              :     void setKuohaoType(int type); // KuoHaoType
    1685              :     KuoHaoType getKuohaoType() const;
    1686              : 
    1687              : private:
    1688              :     int m_height;
    1689              :     KuoHaoType m_kuohaoType;
    1690              : };
    1691              : 
    1692              : class Expressions : public MusicData
    1693              : {
    1694              : public:
    1695              :     Expressions();
    1696            0 :     virtual ~Expressions() {}
    1697              : 
    1698              : public:
    1699              :     void setText(const QString& str);
    1700              :     QString getText() const;
    1701              : 
    1702              : private:
    1703              :     QString m_text;
    1704              : };
    1705              : 
    1706              : class HarpPedal : public MusicData
    1707              : {
    1708              : public:
    1709              :     HarpPedal();
    1710            0 :     virtual ~HarpPedal() {}
    1711              : 
    1712              : public:
    1713              :     void setShowType(int type); // 0: graph, 1: char, 2: char cut, 3: change
    1714              :     int getShowType() const;
    1715              : 
    1716              :     void setShowCharFlag(int flag); // each bit is a bool, total 7 bools
    1717              :     int getShowCharFlag() const;
    1718              : 
    1719              : private:
    1720              :     int m_showType;
    1721              :     int m_showCharFlag;
    1722              : };
    1723              : 
    1724              : class OctaveShift : public MusicData, public LengthElement
    1725              : {
    1726              : public:
    1727              :     OctaveShift();
    1728            0 :     virtual ~OctaveShift() {}
    1729              : 
    1730              : public:
    1731              :     void setOctaveShiftType(OctaveShiftType type);
    1732              :     OctaveShiftType getOctaveShiftType() const;
    1733              : 
    1734              :     void setOctaveShiftPosition(OctaveShiftPosition position);
    1735              :     OctaveShiftPosition getOctaveShiftPosition() const;
    1736              : 
    1737              :     int getNoteShift() const;
    1738              : 
    1739              :     void setEndTick(int tick);
    1740              :     int getEndTick() const;
    1741              : 
    1742              : private:
    1743              :     OctaveShiftType m_octaveShiftType;
    1744              :     OctaveShiftPosition m_octaveShiftPosition;
    1745              :     int m_endTick;
    1746              : };
    1747              : 
    1748              : class OctaveShiftEndPoint : public MusicData, public LengthElement
    1749              : {
    1750              : public:
    1751              :     OctaveShiftEndPoint();
    1752            0 :     virtual ~OctaveShiftEndPoint() {}
    1753              : 
    1754              : public:
    1755              :     void setOctaveShiftType(OctaveShiftType type);
    1756              :     OctaveShiftType getOctaveShiftType() const;
    1757              : 
    1758              :     void setOctaveShiftPosition(OctaveShiftPosition position);
    1759              :     OctaveShiftPosition getOctaveShiftPosition() const;
    1760              : 
    1761              :     void setEndTick(int tick);
    1762              :     int getEndTick() const;
    1763              : 
    1764              : private:
    1765              :     OctaveShiftType m_octaveShiftType;
    1766              :     OctaveShiftPosition m_octaveShiftPosition;
    1767              :     int m_endTick;
    1768              : };
    1769              : 
    1770              : class MultiMeasureRest : public MusicData
    1771              : {
    1772              : public:
    1773              :     MultiMeasureRest();
    1774            0 :     virtual ~MultiMeasureRest() {}
    1775              : 
    1776              : public:
    1777              :     void setMeasureCount(int count);
    1778              :     int getMeasureCount() const;
    1779              : 
    1780              : private:
    1781              :     int m_measureCount;
    1782              : };
    1783              : 
    1784              : class Tempo : public MusicData
    1785              : {
    1786              : public:
    1787              :     Tempo();
    1788            6 :     virtual ~Tempo() {}
    1789              : 
    1790              : public:
    1791              :     void setLeftNoteType(int type); // NoteType
    1792              :     NoteType getLeftNoteType() const;
    1793              : 
    1794              :     void setShowMark(bool show);
    1795              :     bool getShowMark() const;
    1796              : 
    1797              :     void setShowBeforeText(bool show);
    1798              :     bool getShowBeforeText() const;
    1799              : 
    1800              :     void setShowParenthesis(bool show);
    1801              :     bool getShowParenthesis() const;
    1802              : 
    1803              :     void setTypeTempo(double tempo); // 0x2580 = 96.00
    1804              :     double getTypeTempo() const;
    1805              :     double getQuarterTempo() const;
    1806              : 
    1807              :     void setLeftText(const QString& str); // string at left of the mark
    1808              :     QString getLeftText() const;
    1809              : 
    1810              :     void setRightText(const QString& str);
    1811              :     QString getRightText() const;
    1812              : 
    1813              :     void setSwingEighth(bool swing);
    1814              :     bool getSwingEighth() const;
    1815              : 
    1816              :     void setRightNoteType(int type);
    1817              :     NoteType getRightNoteType() const;
    1818              : 
    1819              :     void setLeftNoteDot(bool showDot);
    1820              :     bool getLeftNoteDot() const;
    1821              : 
    1822              :     void setRightNoteDot(bool showDot);
    1823              :     bool getRightNoteDot() const;
    1824              : 
    1825              :     void setRightSideType(int type);
    1826              :     int getRightSideType() const;
    1827              : 
    1828              : private:
    1829              :     int m_leftNoteType;
    1830              :     bool m_showMark;
    1831              :     bool m_showText;
    1832              :     bool m_showParenthesis;
    1833              :     double m_typeTempo;
    1834              :     QString m_leftText;
    1835              :     QString m_rightText;
    1836              :     bool m_swingEighth;
    1837              :     int m_rightNoteType;
    1838              :     bool m_leftNoteDot;
    1839              :     bool m_rightNoteDot;
    1840              :     int m_rightSideType;
    1841              : };
    1842              : 
    1843              : class Text : public MusicData, public LengthElement
    1844              : {
    1845              : public:
    1846              :     Text();
    1847            0 :     virtual ~Text() {}
    1848              : 
    1849              : public:
    1850              :     enum class Type : char {
    1851              :         Rehearsal,
    1852              :         SystemText,
    1853              :         MeasureText
    1854              :     };
    1855              : 
    1856              :     void setTextType(Type type);
    1857              :     Type getTextType() const;
    1858              : 
    1859              :     void setHorizontalMargin(int margin);
    1860              :     int getHorizontalMargin() const;
    1861              : 
    1862              :     void setVerticalMargin(int margin);
    1863              :     int getVerticalMargin() const;
    1864              : 
    1865              :     void setLineThick(int thick);
    1866              :     int getLineThick() const;
    1867              : 
    1868              :     void setText(const QString& text);
    1869              :     QString getText() const;
    1870              : 
    1871              :     void setWidth(int width);
    1872              :     int getWidth() const;
    1873              : 
    1874              :     void setHeight(int height);
    1875              :     int getHeight() const;
    1876              : 
    1877              : private:
    1878              :     Type m_textType;
    1879              :     int m_horiMargin;
    1880              :     int m_vertMargin;
    1881              :     int m_lineThick;
    1882              :     QString m_text;
    1883              :     int m_width;
    1884              :     int m_height;
    1885              : };
    1886              : 
    1887              : class TimeSignature : public MusicData
    1888              : {
    1889              : public:
    1890              :     TimeSignature();
    1891           36 :     virtual ~TimeSignature() {}
    1892              : 
    1893              : public:
    1894              :     void setNumerator(int numerator);
    1895              :     int getNumerator() const;
    1896              : 
    1897              :     void setDenominator(int denominator);
    1898              :     int getDenominator() const;
    1899              : 
    1900              :     void setIsSymbol(bool symbol); // 4/4: common, 2/2: cut
    1901              :     bool getIsSymbol() const;
    1902              : 
    1903              :     void setBeatLength(int length); // tick
    1904              :     int getBeatLength() const;
    1905              : 
    1906              :     void setBarLength(int length); // tick
    1907              :     int getBarLength() const;
    1908              : 
    1909              :     void addBeat(int startUnit, int lengthUnit, int startTick);
    1910              :     void endAddBeat();
    1911              :     int getUnits() const;
    1912              : 
    1913              :     void setReplaceFont(bool replace);
    1914              :     bool getReplaceFont() const;
    1915              : 
    1916              :     void setShowBeatGroup(bool show);
    1917              :     bool getShowBeatGroup() const;
    1918              : 
    1919              :     void setGroupNumerator1(int numerator);
    1920              :     void setGroupNumerator2(int numerator);
    1921              :     void setGroupNumerator3(int numerator);
    1922              :     void setGroupDenominator1(int denominator);
    1923              :     void setGroupDenominator2(int denominator);
    1924              :     void setGroupDenominator3(int denominator);
    1925              : 
    1926              :     void setBeamGroup1(int count);
    1927              :     void setBeamGroup2(int count);
    1928              :     void setBeamGroup3(int count);
    1929              :     void setBeamGroup4(int count);
    1930              : 
    1931              :     void set16thBeamCount(int count);
    1932              :     void set32ndBeamCount(int count);
    1933              : 
    1934              : private:
    1935              :     int m_numerator;
    1936              :     int m_denominator;
    1937              :     bool m_isSymbol;
    1938              :     int m_beatLength;
    1939              :     int m_barLength;
    1940              : 
    1941              :     struct BeatNode {
    1942              :         int m_startUnit;
    1943              :         int m_lengthUnit;
    1944              :         int m_startTick;
    1945              : 
    1946           36 :         BeatNode()
    1947           36 :             : m_startUnit(0),
    1948           36 :             m_lengthUnit(0),
    1949           36 :             m_startTick(0)
    1950              :         {
    1951           36 :         }
    1952              :     };
    1953              :     QList<BeatNode> m_beats;
    1954              :     int m_barLengthUnits;
    1955              : 
    1956              :     bool m_replaceFont;
    1957              :     bool m_showBeatGroup;
    1958              : 
    1959              :     int m_groupNumerator1;
    1960              :     int m_groupNumerator2;
    1961              :     int m_groupNumerator3;
    1962              :     int m_groupDenominator1;
    1963              :     int m_groupDenominator2;
    1964              :     int m_groupDenominator3;
    1965              : 
    1966              :     int m_beamGroup1;
    1967              :     int m_beamGroup2;
    1968              :     int m_beamGroup3;
    1969              :     int m_beamGroup4;
    1970              : 
    1971              :     int m_beamCount16th;
    1972              :     int m_beamCount32nd;
    1973              : };
    1974              : 
    1975              : class Key : public MusicData
    1976              : {
    1977              : public:
    1978              :     Key();
    1979           36 :     virtual ~Key() {}
    1980              : 
    1981              : public:
    1982              :     void setKey(int key); // C = 0x0, G = 0x8, C# = 0xE, F = 0x1, Db = 0x7
    1983              :     int getKey() const;
    1984              :     bool getSetKey() const;
    1985              : 
    1986              :     void setPreviousKey(int key);
    1987              :     int getPreviousKey() const;
    1988              : 
    1989              :     void setSymbolCount(int count);
    1990              :     int getSymbolCount() const;
    1991              : 
    1992              : private:
    1993              :     int m_key;
    1994              :     bool m_set;
    1995              :     int m_previousKey;
    1996              :     int m_symbolCount;
    1997              : };
    1998              : 
    1999              : class RepeatSymbol : public MusicData
    2000              : {
    2001              : public:
    2002              :     RepeatSymbol();
    2003            0 :     virtual ~RepeatSymbol() {}
    2004              : 
    2005              : public:
    2006              :     void setText(const QString& text);
    2007              :     QString getText() const;
    2008              : 
    2009              :     void setRepeatType(int repeatType);
    2010              :     RepeatType getRepeatType() const;
    2011              : 
    2012              : private:
    2013              :     QString m_text;
    2014              :     RepeatType m_repeatType;
    2015              : };
    2016              : 
    2017              : class NumericEnding : public MusicData, public PairEnds
    2018              : {
    2019              : public:
    2020              :     NumericEnding();
    2021              :     virtual ~NumericEnding();
    2022              : 
    2023              : public:
    2024              :     OffsetElement* getNumericHandle() const;
    2025              : 
    2026              :     void setHeight(int height);
    2027              :     int getHeight() const;
    2028              : 
    2029              :     void setText(const QString& text);
    2030              :     QString getText() const;
    2031              :     QList<int> getNumbers() const;
    2032              :     int getJumpCount() const;
    2033              : 
    2034              : private:
    2035              :     int m_height;
    2036              :     QString m_text;
    2037              :     OffsetElement* m_numericHandle;
    2038              : };
    2039              : 
    2040              : class BarNumber : public MusicData
    2041              : {
    2042              : public:
    2043              :     BarNumber();
    2044           36 :     virtual ~BarNumber() {}
    2045              : 
    2046              : public:
    2047              :     void setIndex(int index);
    2048              :     int getIndex() const;
    2049              : 
    2050              :     void setShowOnParagraphStart(bool show);
    2051              :     bool getShowOnParagraphStart() const;
    2052              : 
    2053              :     void setAlign(int align); // 0: left, 1: center, 2: right
    2054              :     int getAlign() const;
    2055              : 
    2056              :     void setShowFlag(int flag); // 0: page, 1: staff, 2: bar, 3: none
    2057              :     int getShowFlag() const;
    2058              : 
    2059              :     void setShowEveryBarCount(int count);
    2060              :     int getShowEveryBarCount() const;
    2061              : 
    2062              :     void setPrefix(const QString& str);
    2063              :     QString getPrefix() const;
    2064              : 
    2065              : private:
    2066              :     int m_index;
    2067              :     bool m_showOnParagraphStart;
    2068              :     int m_align;
    2069              :     int m_showFlag;
    2070              :     int m_barRange;
    2071              :     QString m_prefix;
    2072              : };
    2073              : 
    2074              : // MIDI
    2075              : class MidiController : public MidiData
    2076              : {
    2077              : public:
    2078              :     MidiController();
    2079            0 :     virtual ~MidiController() {}
    2080              : 
    2081              : public:
    2082              :     void setController(int number);
    2083              :     int getController() const;
    2084              : 
    2085              :     void setValue(int value);
    2086              :     int getValue() const;
    2087              : 
    2088              : private:
    2089              :     int m_controller;
    2090              :     int m_value;
    2091              : };
    2092              : 
    2093              : class MidiProgramChange : public MidiData
    2094              : {
    2095              : public:
    2096              :     MidiProgramChange();
    2097            0 :     virtual ~MidiProgramChange() {}
    2098              : 
    2099              : public:
    2100              :     void setPatch(int patch);
    2101              :     int getPatch() const;
    2102              : 
    2103              : private:
    2104              :     int m_patch;
    2105              : };
    2106              : 
    2107              : class MidiChannelPressure : public MidiData
    2108              : {
    2109              : public:
    2110              :     MidiChannelPressure();
    2111            0 :     virtual ~MidiChannelPressure() {}
    2112              : 
    2113              : public:
    2114              :     void setPressure(int pressure);
    2115              :     int getPressure() const;
    2116              : 
    2117              : private:
    2118              :     int m_pressure;
    2119              : };
    2120              : 
    2121              : class MidiPitchWheel : public MidiData
    2122              : {
    2123              : public:
    2124              :     MidiPitchWheel();
    2125            0 :     virtual ~MidiPitchWheel() {}
    2126              : 
    2127              : public:
    2128              :     void setValue(int value);
    2129              :     int getValue() const;
    2130              : 
    2131              : private:
    2132              :     int m_value;
    2133              : };
    2134              : 
    2135              : class Measure : public LengthElement
    2136              : {
    2137              : public:
    2138              :     Measure(int index = 0);
    2139              :     virtual ~Measure();
    2140              : 
    2141              : private:
    2142              :     Measure();
    2143              : 
    2144              : public:
    2145              :     BarNumber* getBarNumber() const;
    2146              :     TimeSignature* getTime() const;
    2147              : 
    2148              :     void setLeftBarline(int barline /* in BarLineType */);
    2149              :     BarLineType getLeftBarline() const;
    2150              : 
    2151              :     void setRightBarline(int barline /* in BarLineType */);
    2152              :     BarLineType getRightBarline() const;
    2153              : 
    2154              :     // set when rightBarline == Baline_Backward
    2155              :     void setBackwardRepeatCount(int repeatCount);
    2156              :     int getBackwardRepeatCount() const;
    2157              : 
    2158              :     void setTypeTempo(double tempo);
    2159              :     double getTypeTempo() const;
    2160              : 
    2161              :     void setIsPickup(bool pickup);
    2162              :     bool getIsPickup() const;
    2163              : 
    2164              :     void setIsMultiMeasureRest(bool rest);
    2165              :     bool getIsMultiMeasureRest() const;
    2166              : 
    2167              :     void setMultiMeasureRestCount(int count);
    2168              :     int getMultiMeasureRestCount() const;
    2169              : 
    2170              : private:
    2171              :     void clear();
    2172              : 
    2173              :     BarNumber* m_barNumber;
    2174              :     TimeSignature* m_time;
    2175              : 
    2176              :     BarLineType m_leftBarline;
    2177              :     BarLineType m_rightBarline;
    2178              :     int m_repeatCount;
    2179              :     double m_typeTempo; // based on some type
    2180              :     bool m_pickup;
    2181              :     bool m_multiMeasureRest;
    2182              :     int m_multiMeasureRestCount;
    2183              : };
    2184              : 
    2185              : class MeasureData
    2186              : {
    2187              : public:
    2188              :     MeasureData();
    2189              :     ~MeasureData();
    2190              : 
    2191              : public:
    2192              :     Clef* getClef() const;
    2193              :     Key* getKey() const;
    2194              : 
    2195              :     void addNoteContainer(NoteContainer* ptr);
    2196              :     QList<NoteContainer*> getNoteContainers() const;
    2197              : 
    2198              :     // put Tempo, Text, RepeatSymbol to MeasureData at part=0 && staff=0
    2199              :     void addMusicData(MusicData* ptr);
    2200              :     // if type==MusicData_None, return all
    2201              :     QList<MusicData*> getMusicDatas(MusicDataType type); // MusicXML: note | direction | harmony
    2202              : 
    2203              :     // put NumericEnding to MeasureData at part = 0 && staff = 0
    2204              :     void addCrossMeasureElement(MusicData* ptr, bool start);
    2205              :     enum class PairType : char {
    2206              :         Start,
    2207              :         Stop,
    2208              :         All
    2209              :     };
    2210              :     QList<MusicData*> getCrossMeasureElements(MusicDataType type, PairType pairType);
    2211              : 
    2212              :     // for midi
    2213              :     void addMidiData(MidiData* ptr);
    2214              :     QList<MidiData*> getMidiDatas(MidiType type);
    2215              : 
    2216              : private:
    2217              :     Key* m_key;
    2218              :     Clef* m_clef;
    2219              :     QList<MusicData*> m_musicDatas;
    2220              :     QList<NoteContainer*> m_noteContainers;
    2221              :     QList<QPair<MusicData*, bool> > m_crossMeasureElements;
    2222              :     QList<MidiData*> m_midiDatas;
    2223              : };
    2224              : 
    2225              : class StreamHandle
    2226              : {
    2227              : public:
    2228              :     StreamHandle(unsigned char* p, int size);
    2229              :     virtual ~StreamHandle();
    2230              : 
    2231              : private:
    2232              :     StreamHandle();
    2233              : 
    2234              : public:
    2235              :     virtual bool read(char* buff, int size);
    2236              :     virtual bool write(char* buff, int size);
    2237              : 
    2238              : private:
    2239              :     int m_size;
    2240              :     int m_curPos;
    2241              :     unsigned char* m_point;
    2242              : };
    2243              : 
    2244              : // base block, or resizable block in ove to store data
    2245              : class Block
    2246              : {
    2247              : public:
    2248              :     Block();
    2249              :     explicit Block(unsigned int size);
    2250         1211 :     virtual ~Block()
    2251         1145 :     {
    2252         1211 :     }
    2253              : 
    2254              : public:
    2255              :     // size > 0, check this in use code
    2256              :     virtual void resize(unsigned int count);
    2257              : 
    2258              :     const unsigned char* data() const;
    2259              :     unsigned char* data();
    2260              :     int size() const;
    2261              : 
    2262              :     bool operator==(const Block& block) const;
    2263              :     bool operator!=(const Block& block) const;
    2264              : 
    2265              :     bool toBoolean() const;
    2266              :     unsigned int toUnsignedInt() const;
    2267              :     int toInt() const;
    2268              :     QByteArray toStrByteArray() const;                // string
    2269              :     QByteArray fixedSizeBufferToStrByteArray() const; // string
    2270              : 
    2271              : private:
    2272              :     void doResize(unsigned int count);
    2273              : 
    2274              : private:
    2275              :     // char [-128, 127], unsigned char [0, 255]
    2276              :     QList<unsigned char> m_data;
    2277              : };
    2278              : 
    2279              : class FixedBlock : public Block
    2280              : {
    2281              : public:
    2282              :     explicit FixedBlock(unsigned int count);
    2283          288 :     virtual ~FixedBlock()
    2284          288 :     {
    2285          288 :     }
    2286              : 
    2287              : private:
    2288              :     FixedBlock();
    2289              : 
    2290              : private:
    2291              :     // can't resize
    2292              :     virtual void resize(unsigned int count);
    2293              : };
    2294              : 
    2295              : // 4 byte block in ove to store size
    2296              : class SizeBlock : public FixedBlock
    2297              : {
    2298              : public:
    2299              :     SizeBlock();
    2300          132 :     virtual ~SizeBlock()
    2301           66 :     {
    2302          132 :     }
    2303              : 
    2304              : public:
    2305              :     // void fromUnsignedInt(unsigned int count);
    2306              : 
    2307              :     unsigned int toSize() const;
    2308              : };
    2309              : 
    2310              : // 4 bytes block in ove to store name
    2311              : class NameBlock : public FixedBlock
    2312              : {
    2313              : public:
    2314              :     NameBlock();
    2315          206 :     virtual ~NameBlock()
    2316          206 :     {
    2317          206 :     }
    2318              : 
    2319              : public:
    2320              :     // ignore data more than 4 bytes
    2321              :     bool isEqual(const QString& name) const;
    2322              : };
    2323              : 
    2324              : // 2 bytes block in ove to store count
    2325              : class CountBlock : public FixedBlock
    2326              : {
    2327              : public:
    2328              :     CountBlock();
    2329           32 :     virtual ~CountBlock()
    2330           16 :     {
    2331           32 :     }
    2332              : 
    2333              : public:
    2334              :     // void setValue(unsigned short count);
    2335              : 
    2336              :     unsigned short toCount() const;
    2337              : };
    2338              : 
    2339              : // content : name
    2340              : class Chunk
    2341              : {
    2342              : public:
    2343              :     Chunk();
    2344           82 :     virtual ~Chunk()
    2345           82 :     {
    2346           82 :     }
    2347              : 
    2348              : public:
    2349              :     const static QString TrackName;
    2350              :     const static QString PageName;
    2351              :     const static QString LineName;
    2352              :     const static QString StaffName;
    2353              :     const static QString MeasureName;
    2354              :     const static QString ConductName;
    2355              :     const static QString BdatName;
    2356              : 
    2357              :     NameBlock getName() const;
    2358              : 
    2359              : protected:
    2360              :     NameBlock m_nameBlock;
    2361              : };
    2362              : 
    2363              : // content : name / size / data
    2364              : class SizeChunk : public Chunk
    2365              : {
    2366              : public:
    2367              :     SizeChunk();
    2368              :     virtual ~SizeChunk();
    2369              : 
    2370              : public:
    2371              :     SizeBlock* getSizeBlock() const;
    2372              :     Block* getDataBlock() const;
    2373              : 
    2374              :     const static unsigned int version3TrackSize;
    2375              : 
    2376              : protected:
    2377              :     SizeBlock* m_sizeBlock;
    2378              :     Block* m_dataBlock;
    2379              : };
    2380              : 
    2381              : // content : name / count
    2382              : class GroupChunk : public Chunk
    2383              : {
    2384              : public:
    2385              :     GroupChunk();
    2386              :     virtual ~GroupChunk();
    2387              : 
    2388              : public:
    2389              :     CountBlock* getCountBlock() const;
    2390              : 
    2391              : protected:
    2392              :     CountBlock* m_childCount;
    2393              : };
    2394              : 
    2395              : // ChunkParse.h
    2396              : class BasicParse
    2397              : {
    2398              : public:
    2399              :     BasicParse(OveSong* ove);
    2400              :     virtual ~BasicParse();
    2401              : 
    2402              : private:
    2403              :     BasicParse();
    2404              : 
    2405              : public:
    2406              :     void setNotify(IOveNotify* notify);
    2407              :     virtual bool parse();
    2408              : 
    2409              : protected:
    2410              :     bool readBuffer(Block& placeHolder, int size);
    2411              :     bool jump(int offset);
    2412              : 
    2413              :     void messageOut(const QString& str);
    2414              : 
    2415              : protected:
    2416              :     OveSong* m_ove;
    2417              :     StreamHandle* m_handle;
    2418              :     IOveNotify* m_notify;
    2419              : };
    2420              : 
    2421              : class OvscParse : public BasicParse
    2422              : {
    2423              : public:
    2424              :     OvscParse(OveSong* ove);
    2425              :     virtual ~OvscParse();
    2426              : 
    2427              : public:
    2428              :     void setOvsc(SizeChunk* chunk);
    2429              : 
    2430              :     virtual bool parse();
    2431              : 
    2432              : private:
    2433              :     SizeChunk* m_chunk;
    2434              : };
    2435              : 
    2436              : class TrackParse : public BasicParse
    2437              : {
    2438              : public:
    2439              :     TrackParse(OveSong* ove);
    2440              :     virtual ~TrackParse();
    2441              : 
    2442              : public:
    2443              :     void setTrack(SizeChunk* chunk);
    2444              : 
    2445              :     virtual bool parse();
    2446              : 
    2447              : private:
    2448              :     SizeChunk* m_chunk;
    2449              : };
    2450              : 
    2451              : class GroupParse : BasicParse
    2452              : {
    2453              : public:
    2454              :     GroupParse(OveSong* ove);
    2455              :     virtual ~GroupParse();
    2456              : 
    2457              : public:
    2458              :     void addSizeChunk(SizeChunk* sizeChunk);
    2459              : 
    2460              :     virtual bool parse();
    2461              : 
    2462              : private:
    2463              :     QList<SizeChunk*> m_sizeChunks;
    2464              : };
    2465              : 
    2466              : class PageGroupParse : public BasicParse
    2467              : {
    2468              : public:
    2469              :     PageGroupParse(OveSong* ove);
    2470              :     virtual ~PageGroupParse();
    2471              : 
    2472              : public:
    2473              :     void addPage(SizeChunk* chunk);
    2474              : 
    2475              :     virtual bool parse();
    2476              : 
    2477              : private:
    2478              :     bool parsePage(SizeChunk* chunk, Page* page);
    2479              : 
    2480              : private:
    2481              :     QList<SizeChunk*> m_pageChunks;
    2482              : };
    2483              : 
    2484              : class StaffCountGetter : public BasicParse
    2485              : {
    2486              : public:
    2487              :     StaffCountGetter(OveSong* ove);
    2488            6 :     virtual ~StaffCountGetter() {}
    2489              : 
    2490              : public:
    2491              :     unsigned int getStaffCount(SizeChunk* chunk);
    2492              : };
    2493              : 
    2494              : class LineGroupParse : public BasicParse
    2495              : {
    2496              : public:
    2497              :     LineGroupParse(OveSong* ove);
    2498              :     virtual ~LineGroupParse();
    2499              : 
    2500              : public:
    2501              :     void setLineGroup(GroupChunk* chunk);
    2502              :     void addLine(SizeChunk* chunk);
    2503              :     void addStaff(SizeChunk* chunk);
    2504              : 
    2505              :     virtual bool parse();
    2506              : 
    2507              : private:
    2508              :     bool parseLine(SizeChunk* chunk, Line* line);
    2509              :     bool parseStaff(SizeChunk* chunk, Staff* staff);
    2510              : 
    2511              : private:
    2512              :     GroupChunk* m_chunk;
    2513              :     QList<SizeChunk*> m_lineChunks;
    2514              :     QList<SizeChunk*> m_staffChunks;
    2515              : };
    2516              : 
    2517              : class BarsParse : public BasicParse
    2518              : {
    2519              : public:
    2520              :     BarsParse(OveSong* ove);
    2521              :     virtual ~BarsParse();
    2522              : 
    2523              : public:
    2524              :     void addMeasure(SizeChunk* chunk);
    2525              :     void addConduct(SizeChunk* chunk);
    2526              :     void addBdat(SizeChunk* chunk);
    2527              : 
    2528              :     virtual bool parse();
    2529              : 
    2530              : private:
    2531              :     bool parseMeas(Measure* measure, SizeChunk* chunk);
    2532              :     bool parseCond(Measure* measure, MeasureData* measureData, SizeChunk* chunk);
    2533              :     bool parseBdat(Measure* measure, MeasureData* measureData, SizeChunk* chunk);
    2534              : 
    2535              :     bool getCondElementType(unsigned int byteData, CondType& type);
    2536              :     bool getBdatElementType(unsigned int byteData, BdatType& type);
    2537              : 
    2538              :     // COND
    2539              :     bool parseTimeSignature(Measure* measure, int length);
    2540              :     bool parseTimeSignatureParameters(Measure* measure, int length);
    2541              :     bool parseRepeatSymbol(MeasureData* measureData, int length);
    2542              :     bool parseNumericEndings(MeasureData* measureData, int length);
    2543              :     bool parseTempo(MeasureData* measureData, int length);
    2544              :     bool parseBarNumber(Measure* measure, int length);
    2545              :     bool parseText(MeasureData* measureData, int length);
    2546              :     bool parseBarlineParameters(Measure* measure, int length);
    2547              : 
    2548              :     // BDAT
    2549              :     bool parseNoteRest(MeasureData* measureData, int length, BdatType type);
    2550              :     bool parseBeam(MeasureData* measureData, int length);
    2551              :     bool parseTie(MeasureData* measureData, int length);
    2552              :     bool parseTuplet(MeasureData* measureData, int length);
    2553              :     bool parseHarmony(MeasureData* measureData, int length);
    2554              :     bool parseClef(MeasureData* measureData, int length);
    2555              :     bool parseLyric(MeasureData* measureData, int length);
    2556              :     bool parseSlur(MeasureData* measureData, int length);
    2557              :     bool parseGlissando(MeasureData* measureData, int length);
    2558              :     bool parseDecorators(MeasureData* measureData, int length);
    2559              :     bool parseDynamics(MeasureData* measureData, int length);
    2560              :     bool parseWedge(MeasureData* measureData, int length);
    2561              :     bool parseKey(MeasureData* measureData, int length);
    2562              :     bool parsePedal(MeasureData* measureData, int length);
    2563              :     bool parseKuohao(MeasureData* measureData, int length);
    2564              :     bool parseExpressions(MeasureData* measureData, int length);
    2565              :     bool parseHarpPedal(MeasureData* measureData, int length);
    2566              :     bool parseMultiMeasureRest(MeasureData* measureData, int length);
    2567              :     bool parseHarmonyGuitarFrame(MeasureData* measureData, int length);
    2568              :     bool parseOctaveShift(MeasureData* measureData, int length);
    2569              :     bool parseMidiController(MeasureData* measureData, int length);
    2570              :     bool parseMidiProgramChange(MeasureData* measureData, int length);
    2571              :     bool parseMidiChannelPressure(MeasureData* measureData, int length);
    2572              :     bool parseMidiPitchWheel(MeasureData* measureData, int length);
    2573              : 
    2574              :     bool parseSizeBlock(int length);
    2575              :     bool parseMidiCommon(MidiData* ptr);
    2576              :     bool parseCommonBlock(MusicData* ptr);
    2577              :     bool parseOffsetCommonBlock(MusicData* ptr);
    2578              :     bool parsePairLinesBlock(PairEnds* ptr); // size == 2
    2579              :     bool parseOffsetElement(OffsetElement* ptr); // size == 2
    2580              : 
    2581              : private:
    2582              :     QList<SizeChunk*> m_measureChunks;
    2583              :     QList<SizeChunk*> m_conductChunks;
    2584              :     QList<SizeChunk*> m_bdatChunks;
    2585              : };
    2586              : 
    2587              : class LyricChunkParse : public BasicParse
    2588              : {
    2589              : public:
    2590              :     LyricChunkParse(OveSong* ove);
    2591            0 :     virtual ~LyricChunkParse() {}
    2592              : 
    2593              : public:
    2594              :     void setLyricChunk(SizeChunk* chunk);
    2595              : 
    2596              :     virtual bool parse();
    2597              : 
    2598              : private:
    2599              :     struct LyricInfo {
    2600              :         int m_track;
    2601              :         int m_measure;
    2602              :         int m_verse;
    2603              :         int m_voice;
    2604              :         int m_wordCount;
    2605              :         int m_lyricSize;
    2606              :         QString m_name;
    2607              :         QString m_lyric;
    2608              :         int m_font;
    2609              :         int m_fontSize;
    2610              :         int m_fontStyle;
    2611              : 
    2612            0 :         LyricInfo()
    2613            0 :             : m_track(0), m_measure(0), m_verse(0), m_voice(0), m_wordCount(0),
    2614            0 :             m_lyricSize(0), m_name(QString()), m_lyric(QString()),
    2615            0 :             m_font(0), m_fontSize(12), m_fontStyle(0) {}
    2616              :     };
    2617              : 
    2618              :     void processLyricInfo(const LyricInfo& info);
    2619              : 
    2620              : private:
    2621              :     SizeChunk* m_chunk;
    2622              : };
    2623              : 
    2624              : class TitleChunkParse : public BasicParse
    2625              : {
    2626              : public:
    2627              :     TitleChunkParse(OveSong* ove);
    2628           16 :     virtual ~TitleChunkParse() {}
    2629              : 
    2630              : public:
    2631              :     void setTitleChunk(SizeChunk* chunk);
    2632              : 
    2633              :     virtual bool parse();
    2634              : 
    2635              : private:
    2636              :     void addToOve(const QString& str, unsigned int titleType);
    2637              : 
    2638              : private:
    2639              :     unsigned int m_titleType;
    2640              :     unsigned int m_annotateType;
    2641              :     unsigned int m_writerType;
    2642              :     unsigned int m_copyrightType;
    2643              :     unsigned int m_headerType;
    2644              :     unsigned int m_footerType;
    2645              : 
    2646              :     SizeChunk* m_chunk;
    2647              : };
    2648              : 
    2649              : // OveOrganizer.h
    2650              : class OveOrganizer
    2651              : {
    2652              : public:
    2653              :     OveOrganizer(OveSong* ove);
    2654            2 :     virtual ~OveOrganizer() {}
    2655              : 
    2656              : public:
    2657              :     void organize();
    2658              : 
    2659              : private:
    2660              :     void organizeAttributes();
    2661              :     void organizeTracks();
    2662              :     void organizeMeasures();
    2663              :     void organizeMeasure(int part, int track, Measure* measure, MeasureData* measureData);
    2664              : 
    2665              :     void organizeContainers(int part, int track, Measure* measure, MeasureData* measureData);
    2666              :     void organizeMusicDatas(int part, int track, Measure* measure, MeasureData* measureData);
    2667              :     void organizeCrossMeasureElements(int part, int track, Measure* measure, MeasureData* measureData);
    2668              : 
    2669              :     void organizePairElement(MusicData* data, int part, int track, Measure* measure, MeasureData* measureData);
    2670              :     void organizeOctaveShift(OctaveShift* octave, Measure* measure, MeasureData* measureData);
    2671              :     void organizeWedge(Wedge* wedge, int part, int track, Measure* measure, MeasureData* measureData);
    2672              : 
    2673              : private:
    2674              :     OveSong* m_ove;
    2675              : };
    2676              : 
    2677              : class StreamHandle;
    2678              : class Block;
    2679              : class NameBlock;
    2680              : class Chunk;
    2681              : class SizeChunk;
    2682              : class GroupChunk;
    2683              : 
    2684              : class OveSerialize : public IOVEStreamLoader
    2685              : {
    2686              : public:
    2687              :     OveSerialize();
    2688              :     virtual ~OveSerialize();
    2689              : 
    2690              : public:
    2691              :     virtual void setOve(OveSong* ove);
    2692              :     virtual void setFileStream(unsigned char* buffer, unsigned int size);
    2693              :     virtual void setNotify(IOveNotify* notify);
    2694              :     virtual bool load(void);
    2695              : 
    2696              :     virtual void release();
    2697              : 
    2698              : private:
    2699              :     bool readNameBlock(NameBlock& nameBlock);
    2700              :     bool readChunkName(Chunk* chunk, const QString& name);
    2701              :     bool readSizeChunk(SizeChunk* sizeChunk); // contains a SizeChunk and data buffer
    2702              :     bool readDataChunk(Block* block, unsigned int size);
    2703              :     bool readGroupChunk(GroupChunk* groupChunk);
    2704              : 
    2705              :     bool readHeader();
    2706              :     bool readHeadData(SizeChunk* ovscChunk);
    2707              :     bool readTracksData();
    2708              :     bool readPagesData();
    2709              :     bool readLinesData();
    2710              :     bool readBarsData();
    2711              :     bool readOveEnd();
    2712              : 
    2713              :     void messageOutError();
    2714              :     void messageOut(const QString& str);
    2715              : 
    2716              : private:
    2717              :     OveSong* m_ove;
    2718              :     StreamHandle* m_streamHandle;
    2719              :     IOveNotify* m_notify;
    2720              : };
    2721              : }
    2722              : 
    2723              : #endif
        

Generated by: LCOV version 2.0-1