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