27 #include <QStringList> 71 class MultiMeasureRest;
73 class OctaveShiftEndPoint;
83 class MidiProgramChange;
84 class MidiChannelPressure;
87 const int TWELVE_TONE = 12 ;
88 const int INVALID_NOTE = -1 ;
89 const int OCTAVE = 7 ;
92 Cond_Time_Parameters = 0x09,
93 Cond_Bar_Number = 0x0A,
94 Cond_Decorator = 0x16,
97 Cond_Expression = 0x25,
98 Cond_Barline_Parameters = 0x30,
100 Cond_Numeric_Ending = 0x32,
106 Bdat_Raw_Note = 0x70,
112 Bdat_Dynamics = 0x13,
114 Bdat_Glissando = 0x15,
115 Bdat_Decorator = 0x16,
118 Bdat_Octave_Shift = 0x19,
123 Bdat_Guitar_Bend = 0x21,
124 Bdat_Guitar_Barre = 0x22,
127 Bdat_Expressions = 0x25,
128 Bdat_Harp_Pedal = 0x26,
129 Bdat_Multi_Measure_Rest = 0x27,
130 Bdat_Harmony_GuitarFrame = 0x28,
131 Bdat_Graphics_40 = 0x40,
132 Bdat_Graphics_RoundRect = 0x41,
133 Bdat_Graphics_Rect = 0x42,
134 Bdat_Graphics_Round = 0x43,
135 Bdat_Graphics_Line = 0x44,
136 Bdat_Graphics_Curve = 0x45,
137 Bdat_Graphics_WedgeSymbol = 0x46,
138 Bdat_Midi_Controller = 0xAB,
139 Bdat_Midi_Program_Change = 0xAC,
140 Bdat_Midi_Channel_Pressure = 0xAD,
141 Bdat_Midi_Pitch_Wheel = 0xAE,
153 MusicData_Measure_Repeat,
161 MusicData_Wedge_EndPoint,
162 MusicData_OctaveShift,
163 MusicData_OctaveShift_EndPoint,
164 MusicData_Expressions,
167 MusicData_Harp_Pedal,
171 MusicData_Note_Container,
183 MusicData_Numeric_Ending,
188 MusicData_Multi_Measure_Rest,
196 Midi_Channel_Pressure,
225 enum AccidentalType {
226 Accidental_Normal = 0x0,
227 Accidental_Sharp = 0x1,
228 Accidental_Flat = 0x2,
229 Accidental_Natural = 0x3,
230 Accidental_DoubleSharp = 0x4,
231 Accidental_DoubleFlat = 0x5,
232 Accidental_Sharp_Caution = 0x9,
233 Accidental_Flat_Caution = 0xA,
234 Accidental_Natural_Caution = 0xB,
235 Accidental_DoubleSharp_Caution = 0xC,
236 Accidental_DoubleFlat_Caution = 0xD
240 NoteHead_Standard = 0x00,
242 NoteHead_Rhythmic_Slash,
244 NoteHead_Closed_Rhythm,
245 NoteHead_Open_Rhythm,
246 NoteHead_Closed_Slash,
270 enum ArticulationType {
271 Articulation_Major_Trill = 0x00,
272 Articulation_Minor_Trill = 0x01,
273 Articulation_Trill_Section = 0x02,
274 Articulation_Inverted_Short_Mordent = 0x03,
275 Articulation_Inverted_Long_Mordent = 0x04,
276 Articulation_Short_Mordent = 0x05,
277 Articulation_Turn = 0x06,
278 Articulation_Finger_1 = 0x07,
279 Articulation_Finger_2 = 0x08,
280 Articulation_Finger_3 = 0x09,
281 Articulation_Finger_4 = 0x0A,
282 Articulation_Finger_5 = 0x0B,
283 Articulation_Flat_Accidental_For_Trill = 0x0C,
284 Articulation_Sharp_Accidental_For_Trill = 0x0D,
285 Articulation_Natural_Accidental_For_Trill = 0x0E,
286 Articulation_Marcato = 0x0F,
287 Articulation_Marcato_Dot = 0x10,
288 Articulation_Heavy_Attack = 0x11,
289 Articulation_SForzando = 0x12,
290 Articulation_SForzando_Dot = 0x13,
291 Articulation_Heavier_Attack = 0x14,
292 Articulation_SForzando_Inverted = 0x15,
293 Articulation_SForzando_Dot_Inverted = 0x16,
294 Articulation_Staccatissimo = 0x17,
295 Articulation_Staccato = 0x18,
296 Articulation_Tenuto = 0x19,
297 Articulation_Up_Bow = 0x1A,
298 Articulation_Down_Bow = 0x1B,
299 Articulation_Up_Bow_Inverted = 0x1C,
300 Articulation_Down_Bow_Inverted = 0x1D,
301 Articulation_Arpeggio = 0x1E,
302 Articulation_Tremolo_Eighth = 0x1F,
303 Articulation_Tremolo_Sixteenth = 0x20,
304 Articulation_Tremolo_Thirty_Second = 0x21,
305 Articulation_Tremolo_Sixty_Fourth = 0x22,
306 Articulation_Natural_Harmonic = 0x23,
307 Articulation_Artificial_Harmonic = 0x24,
308 Articulation_Plus_Sign = 0x25,
309 Articulation_Fermata = 0x26,
310 Articulation_Fermata_Inverted = 0x27,
311 Articulation_Pedal_Down = 0x28,
312 Articulation_Pedal_Up = 0x29,
313 Articulation_Pause = 0x2A,
314 Articulation_Grand_Pause = 0x2B,
315 Articulation_Toe_Pedal = 0x2C,
316 Articulation_Heel_Pedal = 0x2D,
317 Articulation_Toe_To_Heel_Pedal = 0x2E,
318 Articulation_Heel_To_Toe_Pedal = 0x2F,
319 Articulation_Open_String = 0x30,
320 Articulation_Guitar_Lift = 0x46,
321 Articulation_Guitar_Slide_Up = 0x47,
322 Articulation_Guitar_Rip = 0x48,
323 Articulation_Guitar_Fall_Off = 0x49,
324 Articulation_Guitar_Slide_Down = 0x4A,
325 Articulation_Guitar_Spill = 0x4B,
326 Articulation_Guitar_Flip = 0x4C,
327 Articulation_Guitar_Smear = 0x4D,
328 Articulation_Guitar_Bend = 0x4E,
329 Articulation_Guitar_Doit = 0x4F,
330 Articulation_Guitar_Plop = 0x50,
331 Articulation_Guitar_Wow_Wow = 0x51,
332 Articulation_Guitar_Thumb = 0x64,
333 Articulation_Guitar_Index_Finger = 0x65,
334 Articulation_Guitar_Middle_Finger = 0x66,
335 Articulation_Guitar_Ring_Finger = 0x67,
336 Articulation_Guitar_Pinky_Finger = 0x68,
337 Articulation_Guitar_Tap = 0x69,
338 Articulation_Guitar_Hammer = 0x6A,
339 Articulation_Guitar_Pluck = 0x6B,
354 Note_DoubleWhole= 0x0,
368 inline int NoteTypeToTick(NoteType type,
int quarter) {
369 int c = int(pow(2.0, (
int)type)) ;
370 return quarter * 4 * 2 / c ;
476 KuoHao_Parentheses = 0,
481 enum OctaveShiftType {
488 enum OctaveShiftPosition {
489 OctavePosition_Start = 0 ,
490 OctavePosition_Continue,
518 NoteDuration_256 = 15,
519 NoteDuration_128 = NoteDuration_256 * 2,
520 NoteDuration_64 = NoteDuration_128 * 2,
521 NoteDuration_32 = NoteDuration_64 * 2,
522 NoteDuration_16 = NoteDuration_32 * 2,
523 NoteDuration_8 = NoteDuration_16 * 2,
524 NoteDuration_4 = NoteDuration_8 * 2,
525 NoteDuration_2 = NoteDuration_4 * 2,
526 NoteDuration_Whole = NoteDuration_2 * 2,
527 NoteDuration_Double_Whole = NoteDuration_Whole * 2
562 virtual ~IOveNotify() {}
565 virtual void loadInfo(
const QString& info) = 0;
566 virtual void loadError() = 0;
567 virtual void loadPosition(
int currentMeasure,
int totalMeasure,
int currentTrack,
int totalTrack) = 0;
570 class IOVEStreamLoader {
572 IOVEStreamLoader() {}
573 virtual ~IOVEStreamLoader() {}
576 virtual void setNotify(IOveNotify* notify) = 0;
577 virtual void setFileStream(
unsigned char* buffer,
unsigned int size) = 0;
578 virtual void setOve(OveSong* ove) = 0;
581 virtual bool load() = 0;
583 virtual void release() = 0;
586 IOVEStreamLoader* createOveStreamLoader();
593 virtual ~TickElement() {}
596 void setTick(
int tick);
597 int getTick(
void)
const;
606 virtual ~MeasurePos() {}
609 void setMeasure(
int measure);
610 int getMeasure()
const;
612 void setOffset(
int offset);
613 int getOffset()
const;
615 MeasurePos shiftMeasure(
int measure)
const;
616 MeasurePos shiftOffset(
int offset)
const;
618 bool operator ==(
const MeasurePos& mp)
const;
619 bool operator !=(
const MeasurePos& mp)
const;
620 bool operator <(
const MeasurePos& mp)
const;
621 bool operator <=(
const MeasurePos& mp)
const;
622 bool operator >(
const MeasurePos& mp)
const;
623 bool operator >=(
const MeasurePos& mp)
const;
633 virtual ~PairElement();
636 MeasurePos* start()
const;
637 MeasurePos* stop()
const;
650 LineElement* getLeftLine()
const;
651 LineElement* getRightLine()
const;
653 OffsetElement* getLeftShoulder()
const;
654 OffsetElement* getRightShoulder()
const;
657 LineElement* leftLine_;
658 LineElement* rightLine_;
659 OffsetElement* leftShoulder_;
660 OffsetElement* rightShoulder_;
666 virtual ~LineElement() {}
669 virtual void setLine(
int line);
670 virtual int getLine(
void)
const;
676 class OffsetElement {
679 virtual ~OffsetElement() {}
682 virtual void setXOffset(
int offset);
683 virtual int getXOffset()
const;
685 virtual void setYOffset(
int offset);
686 virtual int getYOffset()
const;
693 class LengthElement {
696 virtual ~LengthElement() {}
699 void setLength(
int length);
700 int getLength()
const;
707 class MusicData:
public TickElement,
public PairElement,
public OffsetElement {
710 virtual ~MusicData() {}
713 MusicDataType getMusicDataType()
const;
716 Attributes = 0, NoteBeam, Notations, Direction, None
718 static XmlDataType getXmlDataType(MusicDataType type);
722 void setShow(
bool show);
723 bool getShow()
const;
726 void setColor(
unsigned int color);
727 unsigned int getColor()
const;
729 void setVoice(
unsigned int voice);
730 unsigned int getVoice()
const;
732 void copyCommonBlock(
const MusicData& source);
735 MusicDataType musicDataType_;
743 class MidiData:
public TickElement {
746 virtual ~MidiData() {}
749 MidiType getMidiType()
const;
763 void setIsVersion4(
bool version4 =
true);
764 bool getIsVersion4()
const;
766 void setQuarter(
int tick);
767 int getQuarter(
void)
const;
769 void setShowPageMargin(
bool show);
770 bool getShowPageMargin()
const;
772 void setShowTransposeTrack(
bool show);
773 bool getShowTransposeTrack()
const;
775 void setShowLineBreak(
bool show);
776 bool getShowLineBreak()
const;
778 void setShowRuler(
bool show);
779 bool getShowRuler()
const;
781 void setShowColor(
bool show);
782 bool getShowColor()
const;
784 void setPlayRepeat(
bool play);
785 bool getPlayRepeat()
const;
788 Record, Swing, Notation
790 void setPlayStyle(PlayStyle style);
791 PlayStyle getPlayStyle()
const;
793 void addTitle(
const QString& str);
794 QList<QString> getTitles(
void)
const;
796 void addAnnotate(
const QString& str);
797 QList<QString> getAnnotates(
void)
const;
799 void addWriter(
const QString& str);
800 QList<QString> getWriters(
void)
const;
802 void addCopyright(
const QString& str);
803 QList<QString> getCopyrights(
void)
const;
805 void addHeader(
const QString& str);
806 QList<QString> getHeaders(
void)
const;
808 void addFooter(
const QString& str);
809 QList<QString> getFooters(
void)
const;
811 void addTrack(Track* ptr);
812 int getTrackCount(
void)
const;
813 QList<Track*> getTracks()
const;
814 Track* getTrack(
int part,
int staff)
const;
816 void setTrackBarCount(
int count);
817 int getTrackBarCount()
const;
819 bool addPage(Page* page);
820 int getPageCount()
const;
821 Page* getPage(
int idx);
823 void addLine(Line* ptr);
824 int getLineCount()
const;
825 Line* getLine(
int idx)
const;
827 void addMeasure(Measure* ptr);
828 int getMeasureCount(
void)
const;
829 Measure* getMeasure(
int bar)
const;
831 void addMeasureData(MeasureData* ptr);
832 int getMeasureDataCount(
void)
const;
833 MeasureData* getMeasureData(
int part,
int staff,
int bar)
const;
834 MeasureData* getMeasureData(
int track,
int bar)
const;
837 void setPartStaffCounts(
const QList<int>& partStaffCounts);
838 int getPartCount()
const;
839 int getStaffCount(
int part)
const;
840 int getPartBarCount()
const;
844 QPair<int, int> trackToPartStaff(
int track)
const;
846 void setTextCodecName(
const QString& codecName);
847 QString getCodecString(
const QByteArray& text);
850 int partStaffToTrack(
int part,
int staff)
const;
856 bool showPageMargin_;
857 bool showTransposeTrack;
862 PlayStyle playStyle_;
864 QList<QString> titles_;
865 QList<QString> annotates_;
866 QList<QString> writers_;
867 QList<QString> copyrights_;
868 QList<QString> headers_;
869 QList<QString> footers_;
871 QList<Track*> tracks_;
874 QList<Measure*> measures_;
875 QList<MeasureData*> measureDatas_;
878 QList<int> partStaffCounts_;
888 void setChannel(
int channel);
889 int getChannel()
const;
891 void setVolume(
int volume);
892 int getVolume()
const;
894 void setPitchShift(
int pitchShift);
895 int getPitchShift()
const;
897 void setPan(
int pan);
900 void setPatch(
int patch);
901 int getPatch()
const;
903 void setStemType(
int stemType);
904 int getStemType()
const;
906 static int getDefaultPatch();
907 static int getDefaultVolume();
924 void setName(
const QString& str);
925 QString getName(
void)
const;
927 void setBriefName(
const QString& str);
928 QString getBriefName(
void)
const;
930 void setPatch(
unsigned int patch);
931 unsigned int getPatch()
const;
933 void setChannel(
int channel);
934 int getChannel()
const;
936 void setShowName(
bool show);
937 bool getShowName()
const;
939 void setShowBriefName(
bool show);
940 bool getShowBriefName()
const;
942 void setMute(
bool mute);
943 bool getMute()
const;
945 void setSolo(
bool solo);
946 bool getSolo()
const;
948 void setShowKeyEachLine(
bool show);
949 bool getShowKeyEachLine()
const;
951 void setVoiceCount(
int voices);
952 int getVoiceCount()
const;
954 void addVoice(Voice* voice);
955 QList<Voice*> getVoices()
const;
957 void setShowTranspose(
bool show);
958 bool getShowTranspose()
const;
960 void setTranspose(
int transpose);
961 int getTranspose()
const;
963 void setNoteShift(
int shift);
964 int getNoteShift()
const;
966 void setStartClef(
int clef);
967 ClefType getStartClef()
const;
969 void setTransposeClef(
int clef);
970 int getTansposeClef()
const;
972 void setStartKey(
int key);
973 int getStartKey()
const;
975 void setDisplayPercent(
unsigned int percent);
976 unsigned int getDisplayPercent()
const;
978 void setShowLegerLine(
bool show);
979 bool getShowLegerLine()
const;
981 void setShowClef(
bool show);
982 bool getShowClef()
const;
984 void setShowTimeSignature(
bool show);
985 bool getShowTimeSignature()
const;
987 void setShowKeySignature(
bool show);
988 bool getShowKeySignature()
const;
990 void setShowBarline(
bool show);
991 bool getShowBarline()
const;
993 void setFillWithRest(
bool fill);
994 bool getFillWithRest()
const;
996 void setFlatTail(
bool flat);
997 bool getFlatTail()
const;
999 void setShowClefEachLine(
bool show);
1000 bool getShowClefEachLine()
const;
1009 DrumNode():line_(0), headType_(0), pitch_(0), voice_(0){}
1011 void addDrum(
const DrumNode& node);
1012 QList<DrumNode> getDrumKit()
const;
1017 void setPart(
int part);
1018 int getPart()
const;
1024 unsigned int patch_;
1027 bool showTranspose_;
1031 unsigned int displayPercent_;
1034 QList<Voice*> voices_;
1037 bool showBriefName_;
1038 bool showKeyEachLine_;
1039 bool showLegerLine_;
1041 bool showTimeSignature_;
1042 bool showKeySignature_;
1044 bool showClefEachLine_;
1052 QList<DrumNode> drumKit_;
1064 void setBeginLine(
int line);
1065 int getBeginLine()
const;
1067 void setLineCount(
int count);
1068 int getLineCount()
const;
1070 void setLineInterval(
int interval);
1071 int getLineInterval()
const;
1073 void setStaffInterval(
int interval);
1074 int getStaffInterval()
const;
1076 void setStaffInlineInterval(
int interval);
1077 int getStaffInlineInterval()
const;
1079 void setLineBarCount(
int count);
1080 int getLineBarCount()
const;
1082 void setPageLineCount(
int count);
1083 int getPageLineCount()
const;
1085 void setLeftMargin(
int margin);
1086 int getLeftMargin()
const;
1088 void setTopMargin(
int margin);
1089 int getTopMargin()
const;
1091 void setRightMargin(
int margin);
1092 int getRightMargin()
const;
1094 void setBottomMargin(
int margin);
1095 int getBottomMargin()
const;
1097 void setPageWidth(
int width);
1098 int getPageWidth()
const;
1100 void setPageHeight(
int height);
1101 int getPageHeight()
const;
1109 int staffInlineInterval_;
1129 void addStaff(Staff* staff);
1130 int getStaffCount()
const;
1131 Staff* getStaff(
int idx)
const;
1133 void setBeginBar(
unsigned int bar);
1134 unsigned int getBeginBar()
const;
1136 void setBarCount(
unsigned int count);
1137 unsigned int getBarCount()
const;
1139 void setYOffset(
int offset);
1140 int getYOffset()
const;
1142 void setLeftXOffset(
int offset);
1143 int getLeftXOffset()
const;
1145 void setRightXOffset(
int offset);
1146 int getRightXOffset()
const;
1149 QList<Staff*> staffs_;
1150 unsigned int beginBar_;
1151 unsigned int barCount_;
1157 class Staff :
public OffsetElement {
1163 void setClefType(
int clef);
1164 ClefType getClefType()
const;
1166 void setKeyType(
int key);
1167 int getKeyType()
const;
1169 void setVisible(
bool visible);
1170 bool setVisible()
const;
1172 void setGroupType(GroupType type);
1173 GroupType getGroupType()
const;
1175 void setGroupStaffCount(
int count);
1176 int getGroupStaffCount()
const;
1182 GroupType groupType_;
1183 int groupStaffCount_;
1188 class Note :
public LineElement {
1194 void setIsRest(
bool rest);
1195 bool getIsRest()
const;
1197 void setNote(
unsigned int note);
1198 unsigned int getNote()
const;
1200 void setAccidental(
int type);
1201 AccidentalType getAccidental()
const;
1203 void setShowAccidental(
bool show);
1204 bool getShowAccidental()
const;
1206 void setOnVelocity(
unsigned int velocity);
1207 unsigned int getOnVelocity()
const;
1209 void setOffVelocity(
unsigned int velocity);
1210 unsigned int getOffVelocity()
const;
1212 void setHeadType(
int type);
1213 NoteHeadType getHeadType()
const;
1215 void setTiePos(
int tiePos);
1216 TiePos getTiePos()
const;
1218 void setOffsetStaff(
int offset);
1219 int getOffsetStaff()
const;
1221 void setShow(
bool show);
1222 bool getShow()
const;
1224 void setOffsetTick(
int offset);
1225 int getOffsetTick()
const;
1230 AccidentalType accidental_;
1231 bool showAccidental_;
1232 unsigned int onVelocity_;
1233 unsigned int offVelocity_;
1234 NoteHeadType headType_;
1241 class Articulation :
public OffsetElement {
1244 virtual ~Articulation(){}
1247 void setArtType(
int type);
1248 ArticulationType getArtType()
const;
1250 void setPlacementAbove(
bool above);
1251 bool getPlacementAbove()
const;
1254 bool willAffectNotes()
const;
1256 static bool isTrill(ArticulationType type);
1269 XmlType getXmlType()
const;
1272 bool getChangeSoundEffect()
const;
1273 void setSoundEffect(
int soundFrom,
int soundTo);
1274 QPair<int, int> getSoundEffect()
const;
1276 bool getChangeLength()
const;
1277 void setLengthPercentage(
int percentage);
1278 int getLengthPercentage()
const;
1280 bool getChangeVelocity()
const;
1287 void setVelocityType(VelocityType type);
1288 VelocityType getVelocityType()
const;
1290 void setVelocityValue(
int value);
1291 int getVelocityValue()
const;
1293 bool getChangeExtraLength()
const;
1294 void setExtraLength(
int length);
1295 int getExtraLength()
const;
1298 enum TrillInterval {
1299 TrillInterval_Diatonic = 0,
1300 TrillInterval_Chromatic,
1303 void setTrillInterval(
int interval);
1304 TrillInterval getTrillInterval()
const;
1306 void setAuxiliaryFirst(
bool first);
1307 bool getAuxiliaryFirst()
const;
1309 void setTrillRate(NoteType rate);
1310 NoteType getTrillRate()
const;
1312 void setTrillNoteLength(
int length);
1313 int getTrillNoteLength()
const;
1315 enum AccelerateType {
1316 Accelerate_None = 0 ,
1321 void setAccelerateType(
int type);
1322 AccelerateType getAccelerateType()
const;
1325 ArticulationType type_;
1328 bool changeSoundEffect_;
1329 QPair<int, int> soundEffect_;
1331 int lengthPercentage_;
1332 bool changeVelocity_;
1333 VelocityType velocityType_;
1335 bool changeExtraLength_;
1339 TrillInterval trillInterval_;
1340 bool auxiliaryFirst_;
1341 NoteType trillRate_;
1342 int trillNoteLength_;
1343 AccelerateType accelerateType_;
1346 class NoteContainer :
public MusicData,
public LengthElement {
1349 virtual ~NoteContainer();
1352 void setIsGrace(
bool grace);
1353 bool getIsGrace()
const;
1355 void setIsCue(
bool cue);
1356 bool getIsCue()
const;
1358 void setIsRest(
bool rest);
1359 bool getIsRest()
const;
1361 void setIsRaw(
bool raw);
1362 bool getIsRaw()
const;
1364 void setNoteType(NoteType type);
1365 NoteType getNoteType()
const;
1367 void setDot(
int dot);
1370 void setGraceNoteType(NoteType type);
1371 NoteType getGraceNoteType()
const;
1373 void setInBeam(
bool in);
1374 bool getInBeam()
const;
1376 void setStemUp(
bool up);
1377 bool getStemUp(
void)
const;
1379 void setShowStem(
bool show);
1380 bool getShowStem()
const;
1382 void setStemLength(
int line);
1383 int getStemLength()
const;
1385 void setTuplet(
int tuplet);
1386 int getTuplet()
const;
1388 void setSpace(
int space);
1389 int getSpace()
const;
1391 void addNoteRest(Note* note);
1392 QList<Note*> getNotesRests()
const;
1394 void addArticulation(Articulation* art);
1395 QList<Articulation*> getArticulations()
const;
1397 void setNoteShift(
int octave);
1398 int getNoteShift()
const;
1400 int getOffsetStaff()
const;
1402 int getDuration()
const;
1411 NoteType graceNoteType_;
1420 QList<Note*> notes_;
1421 QList<Articulation*> articulations_;
1424 class Beam :
public MusicData,
public PairEnds {
1430 void setIsGrace(
bool grace);
1431 bool getIsGrace()
const;
1433 void addLine(
const MeasurePos& startMp,
const MeasurePos& endMp);
1434 const QList<QPair<MeasurePos, MeasurePos> > getLines()
const;
1438 QList<QPair<MeasurePos, MeasurePos> > lines_;
1441 class Tie :
public MusicData,
public PairEnds {
1447 void setShowOnTop(
bool top);
1448 bool getShowOnTop()
const;
1450 void setNote(
int note);
1451 int getNote()
const;
1453 void setHeight(
int height);
1454 int getHeight()
const;
1462 class Glissando :
public MusicData,
public PairEnds {
1465 virtual ~Glissando(){}
1468 void setStraightWavy(
bool straight);
1469 bool getStraightWavy()
const;
1471 void setText(
const QString& text);
1472 QString getText()
const;
1474 void setLineThick(
int thick);
1475 int getLineThick()
const;
1483 class Decorator :
public MusicData {
1486 virtual ~Decorator(){}
1489 enum DecoratorType {
1490 Decorator_Dotted_Barline = 0,
1491 Decorator_Articulation
1493 void setDecoratorType(DecoratorType type);
1494 DecoratorType getDecoratorType()
const;
1496 void setArticulationType(ArticulationType type);
1497 ArticulationType getArticulationType()
const;
1500 DecoratorType decoratorType_;
1501 ArticulationType artType_;
1504 class MeasureRepeat :
public MusicData {
1507 virtual ~MeasureRepeat(){}
1510 void setSingleRepeat(
bool single);
1511 bool getSingleRepeat()
const;
1517 class Tuplet :
public MusicData,
public PairEnds {
1523 void setTuplet(
int tuplet=3);
1524 int getTuplet()
const;
1526 void setSpace(
int space=2);
1527 int getSpace()
const;
1529 void setHeight(
int height);
1530 int getHeight()
const;
1532 void setNoteType(NoteType type);
1533 NoteType getNoteType()
const;
1535 OffsetElement* getMarkHandle()
const;
1542 OffsetElement* mark_;
1545 class Harmony :
public MusicData,
public LengthElement {
1548 virtual ~Harmony(){}
1551 void setHarmonyType(HarmonyType type);
1552 HarmonyType getHarmonyType()
const;
1554 void setRoot(
int root=0);
1555 int getRoot()
const;
1557 void setBass(
int bass);
1558 int getBass()
const;
1560 void setBassOnBottom(
bool on);
1561 bool getBassOnBottom()
const;
1563 void setAngle(
int angle);
1564 int getAngle()
const;
1567 HarmonyType harmonyType_;
1574 class Clef :
public MusicData,
public LineElement {
1580 void setClefType(
int type);
1581 ClefType getClefType()
const;
1587 class Lyric :
public MusicData {
1593 void setLyric(
const QString& lyricText);
1594 QString getLyric()
const;
1596 void setVerse(
int verse);
1597 int getVerse()
const;
1604 class Slur:
public MusicData,
public PairEnds {
1610 void setContainerCount(
int count);
1611 int getContainerCount()
const;
1613 void setShowOnTop(
bool top);
1614 bool getShowOnTop()
const;
1616 OffsetElement* getHandle2()
const;
1617 OffsetElement* getHandle3()
const;
1619 void setNoteTimePercent(
int percent);
1620 int getNoteTimePercent()
const;
1623 int containerCount_;
1625 int noteTimePercent_;
1626 OffsetElement* handle_2_;
1627 OffsetElement* handle_3_;
1630 class Dynamics:
public MusicData {
1633 virtual ~Dynamics() {}
1636 void setDynamicsType(
int type);
1637 DynamicsType getDynamicsType()
const;
1639 void setIsPlayback(
bool play);
1640 bool getIsPlayback()
const;
1642 void setVelocity(
int vel);
1643 int getVelocity()
const;
1646 DynamicsType dynamicsType_;
1651 class WedgeEndPoint:
public MusicData {
1654 virtual ~WedgeEndPoint() {}
1657 void setWedgeType(WedgeType type);
1658 WedgeType getWedgeType()
const;
1660 void setHeight(
int height);
1661 int getHeight()
const;
1663 void setWedgeStart(
bool wedgeStart);
1664 bool getWedgeStart()
const;
1668 WedgeType wedgeType_;
1672 class Wedge:
public MusicData {
1678 void setWedgeType(WedgeType type);
1679 WedgeType getWedgeType()
const;
1681 void setHeight(
int height);
1682 int getHeight()
const;
1686 WedgeType wedgeType_;
1689 class Pedal:
public MusicData,
public PairEnds {
1695 void setHalf(
bool half);
1696 bool getHalf()
const;
1698 void setIsPlayback(
bool playback);
1699 bool getIsPlayback()
const;
1701 void setPlayOffset(
int offset);
1702 int getPlayOffset()
const;
1704 OffsetElement* getPedalHandle()
const;
1710 OffsetElement* pedalHandle_;
1713 class KuoHao:
public MusicData,
public PairEnds {
1716 virtual ~KuoHao() {}
1719 void setHeight(
int height);
1720 int getHeight()
const;
1722 void setKuohaoType(
int type);
1723 KuoHaoType getKuohaoType()
const;
1727 KuoHaoType kuohaoType_;
1730 class Expressions:
public MusicData {
1733 virtual ~Expressions() {}
1736 void setText(
const QString& str);
1737 QString getText()
const;
1743 class HarpPedal:
public MusicData {
1746 virtual ~HarpPedal() {}
1749 void setShowType(
int type);
1750 int getShowType()
const;
1752 void setShowCharFlag(
int flag);
1753 int getShowCharFlag()
const;
1760 class OctaveShift:
public MusicData,
public LengthElement {
1763 virtual ~OctaveShift() {}
1766 void setOctaveShiftType(
int type);
1767 OctaveShiftType getOctaveShiftType()
const;
1769 int getNoteShift()
const;
1771 void setEndTick(
int tick);
1772 int getEndTick()
const;
1775 OctaveShiftType octaveShiftType_;
1776 OctaveShiftPosition octaveShiftPosition_;
1780 class OctaveShiftEndPoint:
public MusicData,
public LengthElement {
1782 OctaveShiftEndPoint();
1783 virtual ~OctaveShiftEndPoint() {}
1786 void setOctaveShiftType(
int type);
1787 OctaveShiftType getOctaveShiftType()
const;
1789 void setOctaveShiftPosition(
int position);
1790 OctaveShiftPosition getOctaveShiftPosition()
const;
1792 void setEndTick(
int tick);
1793 int getEndTick()
const;
1796 OctaveShiftType octaveShiftType_;
1797 OctaveShiftPosition octaveShiftPosition_;
1801 class MultiMeasureRest:
public MusicData {
1804 virtual ~MultiMeasureRest() {}
1807 void setMeasureCount(
int count);
1808 int getMeasureCount()
const;
1814 class Tempo:
public MusicData {
1820 void setLeftNoteType(
int type);
1821 NoteType getLeftNoteType()
const;
1823 void setShowMark(
bool show);
1824 bool getShowMark()
const;
1826 void setShowBeforeText(
bool show);
1827 bool getShowBeforeText()
const;
1829 void setShowParenthesis(
bool show);
1830 bool getShowParenthesis()
const;
1832 void setTypeTempo(
int tempo);
1833 int getTypeTempo()
const;
1834 int getQuarterTempo()
const;
1836 void setLeftText(
const QString& str);
1837 QString getLeftText()
const;
1839 void setRightText(
const QString& str);
1840 QString getRightText()
const;
1842 void setSwingEighth(
bool swing);
1843 bool getSwingEighth()
const;
1845 void setRightNoteType(
int type);
1846 int getRightNoteType()
const;
1852 bool showParenthesis_;
1860 class Text:
public MusicData,
public LengthElement {
1872 void setTextType(TextType type);
1873 TextType getTextType()
const;
1875 void setHorizontalMargin(
int margin);
1876 int getHorizontalMargin()
const;
1878 void setVerticalMargin(
int margin);
1879 int getVerticalMargin()
const;
1881 void setLineThick(
int thick);
1882 int getLineThick()
const;
1884 void setText(
const QString& text);
1885 QString getText()
const;
1887 void setWidth(
int width);
1888 int getWidth()
const;
1890 void setHeight(
int height);
1891 int getHeight()
const;
1905 class TimeSignature:
public MusicData {
1908 virtual ~TimeSignature() {}
1911 void setNumerator(
int numerator);
1912 int getNumerator()
const;
1914 void setDenominator(
int denominator);
1915 int getDenominator()
const;
1917 void setIsSymbol(
bool symbol);
1918 bool getIsSymbol()
const;
1920 void setBeatLength(
int length);
1921 int getBeatLength()
const;
1923 void setBarLength(
int length);
1924 int getBarLength()
const;
1926 void addBeat(
int startUnit,
int lengthUnit,
int startTick);
1928 int getUnits()
const;
1930 void setReplaceFont(
bool replace);
1931 bool getReplaceFont()
const;
1933 void setShowBeatGroup(
bool show);
1934 bool getShowBeatGroup()
const;
1936 void setGroupNumerator1(
int numerator);
1937 void setGroupNumerator2(
int numerator);
1938 void setGroupNumerator3(
int numerator);
1939 void setGroupDenominator1(
int denominator);
1940 void setGroupDenominator2(
int denominator);
1941 void setGroupDenominator3(
int denominator);
1943 void setBeamGroup1(
int count);
1944 void setBeamGroup2(
int count);
1945 void setBeamGroup3(
int count);
1946 void setBeamGroup4(
int count);
1948 void set16thBeamCount(
int count);
1949 void set32thBeamCount(
int count);
1969 QList<BeatNode> beats_;
1970 int barLengthUnits_;
1973 bool showBeatGroup_;
1975 int groupNumerator1_;
1976 int groupNumerator2_;
1977 int groupNumerator3_;
1978 int groupDenominator1_;
1979 int groupDenominator2_;
1980 int groupDenominator3_;
1991 class Key:
public MusicData {
1997 void setKey(
int key);
1999 bool getSetKey()
const;
2001 void setPreviousKey(
int key);
2002 int getPreviousKey()
const;
2004 void setSymbolCount(
int count);
2005 int getSymbolCount()
const;
2014 class RepeatSymbol:
public MusicData {
2017 virtual ~RepeatSymbol() {}
2020 void setText(
const QString& text);
2021 QString getText()
const;
2023 void setRepeatType(
int repeatType);
2024 RepeatType getRepeatType()
const;
2028 RepeatType repeatType_;
2031 class NumericEnding:
public MusicData,
public PairEnds {
2034 virtual ~NumericEnding();
2037 OffsetElement* getNumericHandle()
const;
2039 void setHeight(
int height);
2040 int getHeight()
const;
2042 void setText(
const QString& text);
2043 QString getText()
const;
2044 QList<int> getNumbers()
const;
2045 int getJumpCount()
const;
2050 OffsetElement* numericHandle_;
2053 class BarNumber:
public MusicData {
2056 virtual ~BarNumber() {}
2059 void setIndex(
int index);
2060 int getIndex()
const;
2062 void setShowOnParagraphStart(
bool show);
2063 bool getShowOnParagraphStart()
const;
2065 void setAlign(
int align);
2066 int getAlign()
const;
2068 void setShowFlag(
int flag);
2069 int getShowFlag()
const;
2071 void setShowEveryBarCount(
int count);
2072 int getShowEveryBarCount()
const;
2074 void setPrefix(
const QString& str);
2075 QString getPrefix()
const;
2079 bool showOnParagraphStart_;
2088 class MidiController:
public MidiData {
2091 virtual ~MidiController() {}
2094 void setController(
int number);
2095 int getController()
const;
2097 void setValue(
int value);
2098 int getValue()
const;
2105 class MidiProgramChange:
public MidiData {
2107 MidiProgramChange();
2108 virtual ~MidiProgramChange() {}
2111 void setPatch(
int patch);
2112 int getPatch()
const;
2118 class MidiChannelPressure:
public MidiData {
2120 MidiChannelPressure();
2121 virtual ~MidiChannelPressure() {}
2124 void setPressure(
int pressure);
2125 int getPressure()
const;
2131 class MidiPitchWheel:
public MidiData {
2134 virtual ~MidiPitchWheel() {}
2137 void setValue(
int value);
2138 int getValue()
const;
2145 class Measure:
public LengthElement {
2147 Measure(
int index = 0);
2154 BarNumber* getBarNumber()
const;
2155 TimeSignature* getTime()
const;
2157 void setLeftBarline(
int barline);
2158 BarlineType getLeftBarline()
const;
2160 void setRightBarline(
int barline);
2161 BarlineType getRightBarline()
const;
2164 void setBackwardRepeatCount(
int repeatCount);
2165 int getBackwardRepeatCount()
const;
2167 void setTypeTempo(
double tempo);
2168 double getTypeTempo()
const;
2170 void setIsPickup(
bool pickup);
2171 bool getIsPickup()
const;
2173 void setIsMultiMeasureRest(
bool rest);
2174 bool getIsMultiMeasureRest()
const;
2176 void setMultiMeasureRestCount(
int count);
2177 int getMultiMeasureRestCount()
const;
2182 BarNumber* barNumber_;
2183 TimeSignature* time_;
2185 BarlineType leftBarline_;
2186 BarlineType rightBarline_;
2190 bool multiMeasureRest_;
2191 int multiMeasureRestCount_;
2200 Clef* getClef()
const;
2201 Key* getKey()
const;
2203 void addNoteContainer(NoteContainer* ptr);
2204 QList<NoteContainer*> getNoteContainers()
const;
2207 void addMusicData(MusicData* ptr);
2209 QList<MusicData*> getMusicDatas(MusicDataType type);
2212 void addCrossMeasureElement(MusicData* ptr,
bool start);
2218 QList<MusicData*> getCrossMeasureElements(MusicDataType type, PairType pairType);
2221 void addMidiData(MidiData* ptr);
2222 QList<MidiData*> getMidiDatas(MidiType type);
2227 QList<MusicData*> musicDatas_;
2228 QList<NoteContainer*> noteContainers_;
2229 QList<QPair<MusicData*, bool> > crossMeasureElements_;
2230 QList<MidiData*> midiDatas_;
2234 class StreamHandle {
2236 StreamHandle(
unsigned char* p,
int size);
2237 virtual ~StreamHandle();
2243 virtual bool read(
char* buff,
int size);
2244 virtual bool write(
char* buff,
int size);
2249 unsigned char* point_;
2257 explicit Block(
unsigned int size);
2263 virtual void resize(
unsigned int count);
2265 const unsigned char* data()
const;
2266 unsigned char* data();
2267 unsigned int size()
const;
2269 bool operator ==(
const Block& block)
const;
2270 bool operator !=(
const Block& block)
const;
2272 bool toBoolean()
const;
2273 unsigned int toUnsignedInt()
const;
2275 QByteArray toStrByteArray()
const;
2276 QByteArray fixedSizeBufferToStrByteArray()
const;
2279 void doResize(
unsigned int count);
2283 QList<unsigned char> data_;
2286 class FixedBlock:
public Block {
2288 explicit FixedBlock(
unsigned int count);
2289 virtual ~FixedBlock() {
2297 virtual void resize(
unsigned int count);
2302 class SizeBlock:
public FixedBlock {
2305 virtual ~SizeBlock() {
2311 unsigned int toSize()
const;
2315 class NameBlock:
public FixedBlock {
2318 virtual ~NameBlock() {
2323 bool isEqual(
const QString& name)
const;
2327 class CountBlock:
public FixedBlock {
2330 virtual ~CountBlock() {
2336 unsigned short toCount()
const;
2348 const static QString TrackName;
2349 const static QString PageName;
2350 const static QString LineName;
2351 const static QString StaffName;
2352 const static QString MeasureName;
2353 const static QString ConductName;
2354 const static QString BdatName;
2356 NameBlock getName()
const;
2359 NameBlock nameBlock_;
2363 class SizeChunk:
public Chunk {
2366 virtual ~SizeChunk();
2369 SizeBlock* getSizeBlock()
const;
2370 Block* getDataBlock()
const;
2372 const static unsigned int version3TrackSize;
2375 SizeBlock* sizeBlock_;
2380 class GroupChunk:
public Chunk {
2383 virtual ~GroupChunk();
2386 CountBlock* getCountBlock()
const;
2389 CountBlock* childCount_;
2395 BasicParse(OveSong* ove);
2396 virtual ~BasicParse();
2402 void setNotify(IOveNotify* notify);
2403 virtual bool parse();
2406 bool readBuffer(Block& placeHolder,
unsigned int size);
2407 bool jump(
int offset);
2409 void messageOut(
const QString& str);
2413 StreamHandle* handle_;
2414 IOveNotify* notify_;
2419 class OvscParse:
public BasicParse {
2421 OvscParse(OveSong* ove);
2422 virtual ~OvscParse();
2425 void setOvsc(SizeChunk* chunk);
2427 virtual bool parse();
2433 class TrackParse:
public BasicParse {
2435 TrackParse(OveSong* ove);
2436 virtual ~TrackParse();
2439 void setTrack(SizeChunk* chunk);
2441 virtual bool parse();
2447 class GroupParse: BasicParse {
2449 GroupParse(OveSong* ove);
2450 virtual ~GroupParse();
2453 void addSizeChunk(SizeChunk* sizeChunk);
2455 virtual bool parse();
2458 QList<SizeChunk*> sizeChunks_;
2461 class PageGroupParse:
public BasicParse {
2463 PageGroupParse(OveSong* ove);
2464 virtual ~PageGroupParse();
2467 void addPage(SizeChunk* chunk);
2469 virtual bool parse();
2472 bool parsePage(SizeChunk* chunk, Page* page);
2475 QList<SizeChunk*> pageChunks_;
2478 class StaffCountGetter:
public BasicParse {
2480 StaffCountGetter(OveSong* ove);
2481 virtual ~StaffCountGetter() {}
2484 unsigned int getStaffCount(SizeChunk* chunk);
2487 class LineGroupParse:
public BasicParse {
2489 LineGroupParse(OveSong* ove);
2490 virtual ~LineGroupParse();
2493 void setLineGroup(GroupChunk* chunk);
2494 void addLine(SizeChunk* chunk);
2495 void addStaff(SizeChunk* chunk);
2497 virtual bool parse();
2500 bool parseLine(SizeChunk* chunk, Line* line);
2501 bool parseStaff(SizeChunk* chunk, Staff* staff);
2505 QList<SizeChunk*> lineChunks_;
2506 QList<SizeChunk*> staffChunks_;
2509 class BarsParse:
public BasicParse {
2511 BarsParse(OveSong* ove);
2512 virtual ~BarsParse();
2515 void addMeasure(SizeChunk* chunk);
2516 void addConduct(SizeChunk* chunk);
2517 void addBdat(SizeChunk* chunk);
2519 virtual bool parse();
2522 bool parseMeas(Measure* measure, SizeChunk* chunk);
2523 bool parseCond(Measure* measure, MeasureData* measureData, SizeChunk* chunk);
2524 bool parseBdat(Measure* measure, MeasureData* measureData, SizeChunk* chunk);
2526 bool getCondElementType(
unsigned int byteData, CondType& type);
2527 bool getBdatElementType(
unsigned int byteData, BdatType& type);
2530 bool parseTimeSignature(Measure* measure,
int length);
2531 bool parseTimeSignatureParameters(Measure* measure,
int length);
2532 bool parseRepeatSymbol(MeasureData* measureData,
int length);
2533 bool parseNumericEndings(MeasureData* measureData,
int length);
2534 bool parseTempo(MeasureData* measureData,
int length);
2535 bool parseBarNumber(Measure* measure,
int length);
2536 bool parseText(MeasureData* measureData,
int length);
2537 bool parseBarlineParameters(Measure* measure,
int length);
2540 bool parseNoteRest(MeasureData* measureData,
int length, BdatType type);
2541 bool parseBeam(MeasureData* measureData,
int length);
2542 bool parseTie(MeasureData* measureData,
int length);
2543 bool parseTuplet(MeasureData* measureData,
int length);
2544 bool parseHarmony(MeasureData* measureData,
int length);
2545 bool parseClef(MeasureData* measureData,
int length);
2546 bool parseLyric(MeasureData* measureData,
int length);
2547 bool parseSlur(MeasureData* measureData,
int length);
2548 bool parseGlissando(MeasureData* measureData,
int length);
2549 bool parseDecorators(MeasureData* measureData,
int length);
2550 bool parseDynamics(MeasureData* measureData,
int length);
2551 bool parseWedge(MeasureData* measureData,
int length);
2552 bool parseKey(MeasureData* measureData,
int length);
2553 bool parsePedal(MeasureData* measureData,
int length);
2554 bool parseKuohao(MeasureData* measureData,
int length);
2555 bool parseExpressions(MeasureData* measureData,
int length);
2556 bool parseHarpPedal(MeasureData* measureData,
int length);
2557 bool parseMultiMeasureRest(MeasureData* measureData,
int length);
2558 bool parseHarmonyGuitarFrame(MeasureData* measureData,
int length);
2559 bool parseOctaveShift(MeasureData* measureData,
int length);
2560 bool parseMidiController(MeasureData* measureData,
int length);
2561 bool parseMidiProgramChange(MeasureData* measureData,
int length);
2562 bool parseMidiChannelPressure(MeasureData* measureData,
int length);
2563 bool parseMidiPitchWheel(MeasureData* measureData,
int length);
2565 bool parseSizeBlock(
int length);
2566 bool parseMidiCommon(MidiData* ptr);
2567 bool parseCommonBlock(MusicData* ptr);
2568 bool parseOffsetCommonBlock(MusicData* ptr);
2569 bool parsePairLinesBlock(PairEnds* ptr);
2570 bool parseOffsetElement(OffsetElement* ptr);
2573 QList<SizeChunk*> measureChunks_;
2574 QList<SizeChunk*> conductChunks_;
2575 QList<SizeChunk*> bdatChunks_;
2578 class LyricChunkParse:
public BasicParse {
2580 LyricChunkParse(OveSong* ove);
2581 virtual ~LyricChunkParse() {}
2584 void setLyricChunk(SizeChunk* chunk);
2586 virtual bool parse();
2603 track_(0), measure_(0), verse_(0), voice_(0), wordCount_(0),
2604 lyricSize_(0), name_(QString()), lyric_(QString()),
2605 font_(0), fontSize_(12), fontStyle_(0) {}
2608 void processLyricInfo(
const LyricInfo& info);
2614 class TitleChunkParse:
public BasicParse {
2616 TitleChunkParse(OveSong* ove);
2617 virtual ~TitleChunkParse() {}
2620 void setTitleChunk(SizeChunk* chunk);
2622 virtual bool parse();
2625 void addToOve(
const QString& str,
unsigned int titleType);
2628 unsigned int titleType_;
2629 unsigned int annotateType_;
2630 unsigned int writerType_;
2631 unsigned int copyrightType_;
2632 unsigned int headerType_;
2633 unsigned int footerType_;
2639 class OveOrganizer {
2641 OveOrganizer(OveSong* ove) ;
2642 virtual ~OveOrganizer(){}
2648 void organizeAttributes() ;
2649 void organizeTracks() ;
2650 void organizeMeasures() ;
2651 void organizeMeasure(
int part,
int track, Measure* measure, MeasureData* measureData) ;
2653 void organizeContainers(
int part,
int track, Measure* measure, MeasureData* measureData) ;
2654 void organizeMusicDatas(
int part,
int track, Measure* measure, MeasureData* measureData) ;
2655 void organizeCrossMeasureElements(
int part,
int track, Measure* measure, MeasureData* measureData) ;
2657 void organizePairElement(MusicData* data,
int part,
int track, Measure* measure, MeasureData* measureData) ;
2658 void organizeOctaveShift(OctaveShift* octave, Measure* measure, MeasureData* measureData) ;
2659 void organizeWedge(Wedge* wedge,
int part,
int track, Measure* measure, MeasureData* measureData) ;
2673 class OveSerialize:
public IOVEStreamLoader {
2676 virtual ~OveSerialize();
2679 virtual void setOve(OveSong* ove);
2680 virtual void setFileStream(
unsigned char* buffer,
unsigned int size);
2681 virtual void setNotify(IOveNotify* notify);
2682 virtual bool load(
void);
2684 virtual void release();
2687 bool readNameBlock(NameBlock& nameBlock);
2688 bool readChunkName(Chunk* chunk,
const QString& name);
2689 bool readSizeChunk(SizeChunk* sizeChunk);
2690 bool readDataChunk(Block* block,
unsigned int size);
2691 bool readGroupChunk(GroupChunk* groupChunk);
2694 bool readHeadData(SizeChunk* ovscChunk);
2695 bool readTracksData();
2696 bool readPagesData();
2697 bool readLinesData();
2698 bool readBarsData();
2701 void messageOutError();
2702 void messageOut(
const QString& str);
2706 StreamHandle* streamHandle_;
2707 IOveNotify* notify_;
2719 TickElement::TickElement() {
2723 void TickElement::setTick(
int tick) {
2727 int TickElement::getTick(
void)
const {
2732 MeasurePos::MeasurePos() {
2737 void MeasurePos::setMeasure(
int measure) {
2741 int MeasurePos::getMeasure()
const {
2745 void MeasurePos::setOffset(
int offset) {
2749 int MeasurePos::getOffset()
const {
2753 MeasurePos MeasurePos::shiftMeasure(
int measure)
const {
2755 mp.setMeasure(getMeasure() + measure);
2756 mp.setOffset(getOffset());
2761 MeasurePos MeasurePos::shiftOffset(
int offset)
const {
2763 mp.setMeasure(getMeasure());
2764 mp.setOffset(getOffset() + offset);
2769 bool MeasurePos::operator ==(
const MeasurePos& mp)
const {
2770 return getMeasure() == mp.getMeasure() && getOffset() == mp.getOffset();
2773 bool MeasurePos::operator !=(
const MeasurePos& mp)
const {
2774 return !(*
this == mp);
2777 bool MeasurePos::operator <(
const MeasurePos& mp)
const {
2778 if (getMeasure() != mp.getMeasure()) {
2779 return getMeasure() < mp.getMeasure();
2782 return getOffset() < mp.getOffset();
2785 bool MeasurePos::operator <=(
const MeasurePos& mp)
const {
2786 if (getMeasure() != mp.getMeasure()) {
2787 return getMeasure() <= mp.getMeasure();
2790 return getOffset() <= mp.getOffset();
2793 bool MeasurePos::operator >(
const MeasurePos& mp)
const {
2794 return !(*
this <= mp);
2797 bool MeasurePos::operator >=(
const MeasurePos& mp)
const {
2798 return !(*
this < mp);
2802 PairElement::PairElement() {
2803 start_ =
new MeasurePos();
2804 stop_ =
new MeasurePos();
2807 PairElement::~PairElement(){
2812 MeasurePos* PairElement::start()
const {
2816 MeasurePos* PairElement::stop()
const {
2821 PairEnds::PairEnds() {
2822 leftLine_ =
new LineElement();
2823 rightLine_ =
new LineElement();
2824 leftShoulder_ =
new OffsetElement();
2825 rightShoulder_ =
new OffsetElement();
2828 PairEnds::~PairEnds(){
2831 delete leftShoulder_;
2832 delete rightShoulder_;
2835 LineElement* PairEnds::getLeftLine()
const {
2839 LineElement* PairEnds::getRightLine()
const {
2843 OffsetElement* PairEnds::getLeftShoulder()
const {
2844 return leftShoulder_;
2847 OffsetElement* PairEnds::getRightShoulder()
const {
2848 return rightShoulder_;
2852 LineElement::LineElement() {
2856 void LineElement::setLine(
int line) {
2860 int LineElement::getLine(
void)
const {
2865 OffsetElement::OffsetElement() {
2870 void OffsetElement::setXOffset(
int offset) {
2874 int OffsetElement::getXOffset()
const {
2878 void OffsetElement::setYOffset(
int offset) {
2882 int OffsetElement::getYOffset()
const {
2887 LengthElement::LengthElement() {
2891 void LengthElement::setLength(
int length) {
2895 int LengthElement::getLength()
const {
2900 MusicData::MusicData() {
2901 musicDataType_ = MusicData_None;
2907 MusicDataType MusicData::getMusicDataType()
const {
2908 return musicDataType_;
2911 MusicData::XmlDataType MusicData::getXmlDataType(MusicDataType type) {
2912 XmlDataType xmlType = None;
2915 case MusicData_Measure_Repeat: {
2916 xmlType = Attributes;
2919 case MusicData_Beam: {
2923 case MusicData_Slur:
2924 case MusicData_Glissando:
2925 case MusicData_Tuplet:
2926 case MusicData_Tie: {
2927 xmlType = Notations;
2930 case MusicData_Text:
2931 case MusicData_Repeat:
2932 case MusicData_Wedge:
2933 case MusicData_Dynamics:
2934 case MusicData_Pedal:
2935 case MusicData_OctaveShift_EndPoint: {
2936 xmlType = Direction;
2976 void MusicData::setShow(
bool show) {
2980 bool MusicData::getShow()
const {
2984 void MusicData::setColor(
unsigned int color) {
2988 unsigned int MusicData::getColor()
const {
2992 void MusicData::setVoice(
unsigned int voice) {
2996 unsigned int MusicData::getVoice()
const {
3000 void MusicData::copyCommonBlock(
const MusicData& source) {
3001 setTick(source.getTick());
3002 start()->setOffset(source.start()->getOffset());
3003 setColor(source.getColor());
3007 MidiData::MidiData() {
3008 midiType_ = Midi_None;
3011 MidiType MidiData::getMidiType()
const {
3016 OveSong::OveSong() :
3021 OveSong::~OveSong() {
3025 void OveSong::setIsVersion4(
bool version4){
3026 version4_ = version4;
3029 bool OveSong::getIsVersion4()
const {
3033 void OveSong::setQuarter(
int tick) {
3037 int OveSong::getQuarter(
void)
const {
3041 void OveSong::setShowPageMargin(
bool show){
3042 showPageMargin_ = show;
3045 bool OveSong::getShowPageMargin()
const {
3046 return showPageMargin_;
3049 void OveSong::setShowTransposeTrack(
bool show) {
3050 showTransposeTrack = show;
3053 bool OveSong::getShowTransposeTrack()
const {
3054 return showTransposeTrack;
3057 void OveSong::setShowLineBreak(
bool show) {
3058 showLineBreak_ = show;
3061 bool OveSong::getShowLineBreak()
const {
3062 return showLineBreak_;
3065 void OveSong::setShowRuler(
bool show) {
3069 bool OveSong::getShowRuler()
const {
3073 void OveSong::setShowColor(
bool show) {
3077 bool OveSong::getShowColor()
const {
3081 void OveSong::setPlayRepeat(
bool play) {
3085 bool OveSong::getPlayRepeat()
const {
3089 void OveSong::setPlayStyle(PlayStyle style) {
3093 OveSong::PlayStyle OveSong::getPlayStyle()
const {
3097 void OveSong::addTitle(
const QString& str) {
3098 titles_.push_back(str);
3101 QList<QString> OveSong::getTitles(
void)
const {
3105 void OveSong::addAnnotate(
const QString& str) {
3106 annotates_.push_back(str);
3109 QList<QString> OveSong::getAnnotates(
void)
const {
3113 void OveSong::addWriter(
const QString& str) {
3114 writers_.push_back(str);
3117 QList<QString> OveSong::getWriters(
void)
const {
3121 void OveSong::addCopyright(
const QString& str) {
3122 copyrights_.push_back(str);
3125 QList<QString> OveSong::getCopyrights(
void)
const {
3129 void OveSong::addHeader(
const QString& str) {
3130 headers_.push_back(str);
3133 QList<QString> OveSong::getHeaders(
void)
const {
3137 void OveSong::addFooter(
const QString& str) {
3138 footers_.push_back(str);
3141 QList<QString> OveSong::getFooters(
void)
const {
3145 void OveSong::addTrack(Track* ptr) {
3146 tracks_.push_back(ptr);
3149 int OveSong::getTrackCount(
void)
const {
3150 return tracks_.size();
3153 QList<Track*> OveSong::getTracks()
const {
3157 void OveSong::setTrackBarCount(
int count) {
3158 trackBarCount_ = count;
3161 int OveSong::getTrackBarCount()
const {
3162 return trackBarCount_;
3165 Track* OveSong::getTrack(
int part,
int staff)
const {
3166 int trackId = partStaffToTrack(part, staff);
3168 if( trackId >=0 && trackId < (
int)tracks_.size() ) {
3169 return tracks_[trackId];
3175 bool OveSong::addPage(Page* page) {
3176 pages_.push_back(page);
3180 int OveSong::getPageCount()
const {
3181 return pages_.size();
3184 Page* OveSong::getPage(
int idx) {
3185 if( idx>=0 && idx<(
int)pages_.size() ) {
3192 void OveSong::addLine(Line* ptr) {
3193 lines_.push_back(ptr);
3196 int OveSong::getLineCount()
const {
3197 return lines_.size();
3200 Line* OveSong::getLine(
int idx)
const {
3201 if( idx >=0 && idx<(
int)lines_.size() ) {
3208 void OveSong::addMeasure(Measure* ptr) {
3209 measures_.push_back(ptr);
3212 int OveSong::getMeasureCount(
void)
const {
3213 return measures_.size();
3216 Measure* OveSong::getMeasure(
int bar)
const {
3217 if( bar >= 0 && bar < (
int)measures_.size() ) {
3218 return measures_[bar];
3224 void OveSong::addMeasureData(MeasureData* ptr) {
3225 measureDatas_.push_back(ptr);
3228 int OveSong::getMeasureDataCount(
void)
const {
3229 return measureDatas_.size();
3232 MeasureData* OveSong::getMeasureData(
int part,
int staff,
int bar)
const {
3233 int trackId = partStaffToTrack(part, staff);
3234 int trackBarCount = getTrackBarCount();
3236 if( bar >= 0 && bar < trackBarCount ) {
3237 int measureId = trackBarCount * trackId + bar;
3239 if( measureId >=0 && measureId < (
int)measureDatas_.size() ) {
3240 return measureDatas_[measureId];
3247 MeasureData* OveSong::getMeasureData(
int track,
int bar)
const {
3248 int id = trackBarCount_*track + bar;
3250 if(
id >=0 &&
id < (
int)measureDatas_.size() ) {
3251 return measureDatas_[id];
3257 void OveSong::setPartStaffCounts(
const QList<int>& partStaffCounts) {
3259 for(
int i=0; i<partStaffCounts.size(); ++i) {
3260 partStaffCounts_.push_back(partStaffCounts[i]);
3264 int OveSong::getPartCount()
const {
3265 return partStaffCounts_.size();
3268 int OveSong::getStaffCount(
int part)
const {
3269 if( part>=0 && part<(
int)partStaffCounts_.size() ) {
3270 return partStaffCounts_[part];
3276 int OveSong::getPartBarCount()
const {
3277 return measureDatas_.size() / tracks_.size();
3280 QPair<int, int> OveSong::trackToPartStaff(
int track)
const {
3281 QPair<int, int> partStaff;
3285 for( i=0; i<partStaffCounts_.size(); ++i ) {
3286 if( staffCount + partStaffCounts_[i] > track ) {
3287 return qMakePair((
int)i, track-staffCount);
3290 staffCount += partStaffCounts_[i];
3293 return qMakePair((
int)partStaffCounts_.size(), 0);
3296 int OveSong::partStaffToTrack(
int part,
int staff)
const {
3298 unsigned int staffCount = 0;
3300 for( i=0; i<partStaffCounts_.size(); ++i ) {
3301 if( part == (
int)i && staff>=0 && staff<(int)partStaffCounts_[i] ) {
3302 int trackId = staffCount + staff;
3304 if( trackId >=0 && trackId < (
int)tracks_.size() ) {
3309 staffCount += partStaffCounts_[i];
3312 return tracks_.size();
3315 void OveSong::setTextCodecName(
const QString& codecName) {
3316 codec_ = QTextCodec::codecForName(codecName.toLatin1());
3319 QString OveSong::getCodecString(
const QByteArray& text) {
3324 s = codec_->toUnicode(text);
3329 void OveSong::clear(
void)
3333 showPageMargin_ =
false;
3334 showTransposeTrack =
false;
3335 showLineBreak_ =
false;
3339 playStyle_ = Record;
3342 copyrights_.clear();
3349 for(
int i=0; i<tracks_.size(); ++i){
3352 for(
int i=0; i<pages_.size(); ++i){
3355 for(
int i=0; i<lines_.size(); ++i){
3358 for(
int i=0; i<measures_.size(); ++i){
3359 delete measures_[i];
3361 for(
int i=0; i<measureDatas_.size(); ++i){
3362 delete measureDatas_[i];
3368 measureDatas_.clear();
3370 partStaffCounts_.clear();
3383 void Voice::setChannel(
int channel) {
3387 int Voice::getChannel()
const {
3391 void Voice::setVolume(
int volume) {
3395 int Voice::getVolume()
const {
3399 void Voice::setPitchShift(
int pitchShift) {
3400 pitchShift_ = pitchShift;
3403 int Voice::getPitchShift()
const {
3407 void Voice::setPan(
int pan) {
3411 int Voice::getPan()
const {
3415 void Voice::setPatch(
int patch) {
3419 int Voice::getPatch()
const {
3423 void Voice::setStemType(
int stemType) {
3424 stemType_ = stemType;
3427 int Voice::getStemType()
const {
3431 int Voice::getDefaultPatch() {
3435 int Voice::getDefaultVolume() {
3448 void Track::setName(
const QString& str) {
3452 QString Track::getName(
void)
const {
3456 void Track::setBriefName(
const QString& str) {
3460 QString Track::getBriefName(
void)
const {
3464 void Track::setPatch(
unsigned int patch) {
3468 unsigned int Track::getPatch()
const {
3472 void Track::setChannel(
int channel) {
3476 int Track::getChannel()
const {
3480 void Track::setShowName(
bool show) {
3484 bool Track::getShowName()
const {
3488 void Track::setShowBriefName(
bool show) {
3489 showBriefName_ = show;
3492 bool Track::getShowBriefName()
const {
3493 return showBriefName_;
3496 void Track::setMute(
bool mute) {
3500 bool Track::getMute()
const {
3504 void Track::setSolo(
bool solo) {
3508 bool Track::getSolo()
const {
3512 void Track::setShowKeyEachLine(
bool show) {
3513 showKeyEachLine_ = show;
3516 bool Track::getShowKeyEachLine()
const {
3517 return showKeyEachLine_;
3520 void Track::setVoiceCount(
int voices) {
3521 voiceCount_ = voices;
3524 int Track::getVoiceCount()
const {
3528 void Track::addVoice(Voice* voice) {
3529 voices_.push_back(voice);
3532 QList<Voice*> Track::getVoices()
const {
3536 void Track::setShowTranspose(
bool show) {
3537 showTranspose_ = show;
3540 bool Track::getShowTranspose()
const {
3541 return showTranspose_;
3544 void Track::setTranspose(
int transpose) {
3545 transpose_ = transpose;
3548 int Track::getTranspose()
const {
3552 void Track::setNoteShift(
int shift) {
3556 int Track::getNoteShift()
const {
3560 void Track::setStartClef(
int clef) {
3564 ClefType Track::getStartClef()
const {
3565 return (ClefType)startClef_;
3568 void Track::setTransposeClef(
int clef) {
3569 transposeClef_ = clef;
3572 int Track::getTansposeClef()
const {
3573 return transposeClef_;
3576 void Track::setStartKey(
int key) {
3580 int Track::getStartKey()
const {
3584 void Track::setDisplayPercent(
unsigned int percent) {
3585 displayPercent_ = percent;
3588 unsigned int Track::getDisplayPercent()
const {
3589 return displayPercent_;
3592 void Track::setShowLegerLine(
bool show) {
3593 showLegerLine_ = show;
3596 bool Track::getShowLegerLine()
const {
3597 return showLegerLine_;
3600 void Track::setShowClef(
bool show) {
3604 bool Track::getShowClef()
const {
3608 void Track::setShowTimeSignature(
bool show) {
3609 showTimeSignature_ = show;
3612 bool Track::getShowTimeSignature()
const {
3613 return showTimeSignature_;
3616 void Track::setShowKeySignature(
bool show) {
3617 showKeySignature_ = show;
3620 bool Track::getShowKeySignature()
const {
3621 return showKeySignature_;
3624 void Track::setShowBarline(
bool show) {
3625 showBarline_ = show;
3628 bool Track::getShowBarline()
const {
3629 return showBarline_;
3632 void Track::setFillWithRest(
bool fill) {
3633 fillWithRest_ = fill;
3636 bool Track::getFillWithRest()
const {
3637 return fillWithRest_;
3640 void Track::setFlatTail(
bool flat) {
3644 bool Track::getFlatTail()
const {
3648 void Track::setShowClefEachLine(
bool show) {
3649 showClefEachLine_ = show;
3652 bool Track::getShowClefEachLine()
const {
3653 return showClefEachLine_;
3656 void Track::addDrum(
const DrumNode& node) {
3662 drumKit_.push_back(node);
3665 QList<Track::DrumNode> Track::getDrumKit()
const {
3669 void Track::setPart(
int part) {
3673 int Track::getPart()
const {
3677 void Track::clear(
void) {
3685 showTranspose_ =
false;
3687 startClef_ = Clef_Treble;
3688 transposeClef_ = Clef_Treble;
3689 displayPercent_ = 100;
3694 showBriefName_ =
false;
3695 showKeyEachLine_ =
false;
3696 showLegerLine_ =
true;
3698 showTimeSignature_ =
true;
3699 showKeySignature_ =
true;
3700 showBarline_ =
true;
3701 showClefEachLine_ =
false;
3703 fillWithRest_ =
true;
3713 for(
int i=0; i<voices_.size(); ++i){
3726 staffInlineInterval_ = 6;
3733 rightMargin_ = 0xA8;
3734 bottomMargin_ = 0xA8;
3736 pageWidth_ = 0x0B40;
3737 pageHeight_ = 0x0E90;
3740 void Page::setBeginLine(
int line) {
3744 int Page::getBeginLine()
const {
3748 void Page::setLineCount(
int count) {
3752 int Page::getLineCount()
const {
3756 void Page::setLineInterval(
int interval) {
3757 lineInterval_ = interval;
3760 int Page::getLineInterval()
const {
3761 return lineInterval_;
3764 void Page::setStaffInterval(
int interval) {
3765 staffInterval_ = interval;
3768 int Page::getStaffInterval()
const {
3769 return staffInterval_;
3772 void Page::setStaffInlineInterval(
int interval) {
3773 staffInlineInterval_ = interval;
3776 int Page::getStaffInlineInterval()
const {
3777 return staffInlineInterval_;
3780 void Page::setLineBarCount(
int count) {
3781 lineBarCount_ = count;
3784 int Page::getLineBarCount()
const {
3785 return lineBarCount_;
3788 void Page::setPageLineCount(
int count) {
3789 pageLineCount_ = count;
3792 int Page::getPageLineCount()
const {
3793 return pageLineCount_;
3796 void Page::setLeftMargin(
int margin) {
3797 leftMargin_ = margin;
3800 int Page::getLeftMargin()
const {
3804 void Page::setTopMargin(
int margin) {
3805 topMargin_ = margin;
3808 int Page::getTopMargin()
const {
3812 void Page::setRightMargin(
int margin) {
3813 rightMargin_ = margin;
3816 int Page::getRightMargin()
const {
3817 return rightMargin_;
3820 void Page::setBottomMargin(
int margin) {
3821 bottomMargin_ = margin;
3824 int Page::getBottomMargin()
const {
3825 return bottomMargin_;
3828 void Page::setPageWidth(
int width) {
3832 int Page::getPageWidth()
const {
3836 void Page::setPageHeight(
int height) {
3837 pageHeight_ = height;
3840 int Page::getPageHeight()
const {
3854 for(
int i=0; i<staffs_.size(); ++i){
3860 void Line::addStaff(Staff* staff) {
3861 staffs_.push_back(staff);
3864 int Line::getStaffCount()
const {
3865 return staffs_.size();
3868 Staff* Line::getStaff(
int idx)
const {
3869 if (idx >= 0 && idx < (
int) staffs_.size()) {
3870 return staffs_[idx];
3876 void Line::setBeginBar(
unsigned int bar) {
3880 unsigned int Line::getBeginBar()
const {
3884 void Line::setBarCount(
unsigned int count) {
3888 unsigned int Line::getBarCount()
const {
3892 void Line::setYOffset(
int offset) {
3896 int Line::getYOffset()
const {
3900 void Line::setLeftXOffset(
int offset) {
3901 leftXOffset_ = offset;
3904 int Line::getLeftXOffset()
const {
3905 return leftXOffset_;
3908 void Line::setRightXOffset(
int offset) {
3909 rightXOffset_ = offset;
3912 int Line::getRightXOffset()
const {
3913 return rightXOffset_;
3918 clef_ = Clef_Treble;
3921 groupType_ = Group_None;
3922 groupStaffCount_ = 0;
3925 void Staff::setClefType(
int clef) {
3926 clef_ = (ClefType) clef;
3929 ClefType Staff::getClefType()
const {
3933 void Staff::setKeyType(
int key) {
3937 int Staff::getKeyType()
const {
3941 void Staff::setVisible(
bool visible) {
3945 bool Staff::setVisible()
const {
3949 void Staff::setGroupType(GroupType type){
3953 GroupType Staff::getGroupType()
const {
3957 void Staff::setGroupStaffCount(
int count) {
3958 groupStaffCount_ = count;
3961 int Staff::getGroupStaffCount()
const {
3962 return groupStaffCount_;
3969 accidental_ = Accidental_Normal;
3970 showAccidental_ =
false;
3971 offVelocity_ = 0x40;
3973 headType_ = NoteHead_Standard;
3980 void Note::setIsRest(
bool rest) {
3984 bool Note::getIsRest()
const {
3988 void Note::setNote(
unsigned int note) {
3992 unsigned int Note::getNote()
const {
3996 void Note::setAccidental(
int type) {
3997 accidental_ = (AccidentalType) type;
4000 AccidentalType Note::getAccidental()
const {
4004 void Note::setShowAccidental(
bool show) {
4005 showAccidental_ = show;
4008 bool Note::getShowAccidental()
const {
4009 return showAccidental_;
4012 void Note::setOnVelocity(
unsigned int velocity) {
4013 onVelocity_ = velocity;
4016 unsigned int Note::getOnVelocity()
const {
4020 void Note::setOffVelocity(
unsigned int velocity) {
4021 offVelocity_ = velocity;
4024 unsigned int Note::getOffVelocity()
const {
4025 return offVelocity_;
4028 void Note::setHeadType(
int type) {
4029 headType_ = (NoteHeadType) type;
4032 NoteHeadType Note::getHeadType()
const {
4036 void Note::setTiePos(
int tiePos) {
4037 tiePos_ = (TiePos) tiePos;
4040 TiePos Note::getTiePos()
const {
4044 void Note::setOffsetStaff(
int offset) {
4045 offsetStaff_ = offset;
4048 int Note::getOffsetStaff()
const {
4049 return offsetStaff_;
4052 void Note::setShow(
bool show) {
4056 bool Note::getShow()
const {
4060 void Note::setOffsetTick(
int offset) {
4061 offsetTick_ = offset;
4064 int Note::getOffsetTick()
const {
4069 Articulation::Articulation() {
4070 type_ = Articulation_Marcato;
4073 changeSoundEffect_ =
false;
4074 changeLength_ =
false;
4075 changeVelocity_ =
false;
4076 changeExtraLength_ =
false;
4078 soundEffect_ = qMakePair(0, 0);
4079 lengthPercentage_ = 100;
4080 velocityType_ = Velocity_Offset;
4084 trillNoteLength_ = 60;
4085 trillRate_ = Note_Sixteen;
4086 accelerateType_ = Accelerate_None;
4087 auxiliaryFirst_ =
false;
4088 trillInterval_ = TrillInterval_Chromatic;
4091 void Articulation::setArtType(
int type) {
4092 type_ = (ArticulationType) type;
4095 ArticulationType Articulation::getArtType()
const {
4099 void Articulation::setPlacementAbove(
bool above) {
4103 bool Articulation::getPlacementAbove()
const {
4107 bool Articulation::getChangeSoundEffect()
const {
4108 return changeSoundEffect_;
4111 void Articulation::setSoundEffect(
int soundFrom,
int soundTo) {
4112 soundEffect_ = qMakePair(soundFrom, soundTo);
4113 changeSoundEffect_ =
true;
4116 QPair<int, int> Articulation::getSoundEffect()
const {
4117 return soundEffect_;
4120 bool Articulation::getChangeLength()
const {
4121 return changeLength_;
4124 void Articulation::setLengthPercentage(
int percentage) {
4125 lengthPercentage_ = percentage;
4126 changeLength_ =
true;
4129 int Articulation::getLengthPercentage()
const {
4130 return lengthPercentage_;
4133 bool Articulation::getChangeVelocity()
const {
4134 return changeVelocity_;
4137 void Articulation::setVelocityType(VelocityType type) {
4138 velocityType_ = type;
4139 changeVelocity_ =
true;
4142 Articulation::VelocityType Articulation::getVelocityType()
const {
4143 return velocityType_;
4146 void Articulation::setVelocityValue(
int value) {
4147 velocityValue_ = value;
4150 int Articulation::getVelocityValue()
const {
4151 return velocityValue_;
4154 bool Articulation::getChangeExtraLength()
const {
4155 return changeExtraLength_;
4158 void Articulation::setExtraLength(
int length) {
4159 extraLength_ = length;
4160 changeExtraLength_ =
true;
4163 int Articulation::getExtraLength()
const {
4164 return extraLength_;
4167 void Articulation::setTrillNoteLength(
int length) {
4168 trillNoteLength_ = length;
4171 int Articulation::getTrillNoteLength()
const {
4172 return trillNoteLength_;
4175 void Articulation::setTrillRate(NoteType rate) {
4179 NoteType Articulation::getTrillRate()
const {
4183 void Articulation::setAccelerateType(
int type) {
4184 accelerateType_ = (AccelerateType) type;
4187 Articulation::AccelerateType Articulation::getAccelerateType()
const {
4188 return accelerateType_;
4191 void Articulation::setAuxiliaryFirst(
bool first) {
4192 auxiliaryFirst_ = first;
4195 bool Articulation::getAuxiliaryFirst()
const {
4196 return auxiliaryFirst_;
4199 void Articulation::setTrillInterval(
int interval) {
4200 trillInterval_ = (TrillInterval) interval;
4203 Articulation::TrillInterval Articulation::getTrillInterval()
const {
4204 return trillInterval_;
4207 bool Articulation::willAffectNotes()
const {
4208 bool affect =
false;
4210 switch (getArtType()) {
4211 case Articulation_Major_Trill:
4212 case Articulation_Minor_Trill:
4213 case Articulation_Trill_Section:
4214 case Articulation_Inverted_Short_Mordent:
4215 case Articulation_Inverted_Long_Mordent:
4216 case Articulation_Short_Mordent:
4217 case Articulation_Turn:
4219 case Articulation_Arpeggio:
4220 case Articulation_Tremolo_Eighth:
4221 case Articulation_Tremolo_Sixteenth:
4222 case Articulation_Tremolo_Thirty_Second:
4223 case Articulation_Tremolo_Sixty_Fourth: {
4227 case Articulation_Finger_1:
4228 case Articulation_Finger_2:
4229 case Articulation_Finger_3:
4230 case Articulation_Finger_4:
4231 case Articulation_Finger_5:
4232 case Articulation_Flat_Accidental_For_Trill:
4233 case Articulation_Sharp_Accidental_For_Trill:
4234 case Articulation_Natural_Accidental_For_Trill:
4235 case Articulation_Marcato:
4236 case Articulation_Marcato_Dot:
4237 case Articulation_Heavy_Attack:
4238 case Articulation_SForzando:
4239 case Articulation_SForzando_Dot:
4240 case Articulation_Heavier_Attack:
4241 case Articulation_SForzando_Inverted:
4242 case Articulation_SForzando_Dot_Inverted:
4243 case Articulation_Staccatissimo:
4244 case Articulation_Staccato:
4245 case Articulation_Tenuto:
4246 case Articulation_Up_Bow:
4247 case Articulation_Down_Bow:
4248 case Articulation_Up_Bow_Inverted:
4249 case Articulation_Down_Bow_Inverted:
4250 case Articulation_Natural_Harmonic:
4251 case Articulation_Artificial_Harmonic:
4252 case Articulation_Plus_Sign:
4253 case Articulation_Fermata:
4254 case Articulation_Fermata_Inverted:
4255 case Articulation_Pedal_Down:
4256 case Articulation_Pedal_Up:
4257 case Articulation_Pause:
4258 case Articulation_Grand_Pause:
4259 case Articulation_Toe_Pedal:
4260 case Articulation_Heel_Pedal:
4261 case Articulation_Toe_To_Heel_Pedal:
4262 case Articulation_Heel_To_Toe_Pedal:
4263 case Articulation_Open_String:
4264 case Articulation_Guitar_Lift:
4265 case Articulation_Guitar_Slide_Up:
4266 case Articulation_Guitar_Rip:
4267 case Articulation_Guitar_Fall_Off:
4268 case Articulation_Guitar_Slide_Down:
4269 case Articulation_Guitar_Spill:
4270 case Articulation_Guitar_Flip:
4271 case Articulation_Guitar_Smear:
4272 case Articulation_Guitar_Bend:
4273 case Articulation_Guitar_Doit:
4274 case Articulation_Guitar_Plop:
4275 case Articulation_Guitar_Wow_Wow:
4276 case Articulation_Guitar_Thumb:
4277 case Articulation_Guitar_Index_Finger:
4278 case Articulation_Guitar_Middle_Finger:
4279 case Articulation_Guitar_Ring_Finger:
4280 case Articulation_Guitar_Pinky_Finger:
4281 case Articulation_Guitar_Tap:
4282 case Articulation_Guitar_Hammer:
4283 case Articulation_Guitar_Pluck: {
4293 bool Articulation::isTrill(ArticulationType type) {
4294 bool isTrill =
false;
4297 case Articulation_Major_Trill:
4298 case Articulation_Minor_Trill:
4299 case Articulation_Trill_Section: {
4310 Articulation::XmlType Articulation::getXmlType()
const {
4311 XmlType xmlType = Xml_Unknown;
4314 case Articulation_Major_Trill:
4315 case Articulation_Minor_Trill:
4316 case Articulation_Trill_Section:
4317 case Articulation_Inverted_Short_Mordent:
4318 case Articulation_Inverted_Long_Mordent:
4319 case Articulation_Short_Mordent:
4320 case Articulation_Turn:
4324 case Articulation_Tremolo_Eighth:
4325 case Articulation_Tremolo_Sixteenth:
4326 case Articulation_Tremolo_Thirty_Second:
4327 case Articulation_Tremolo_Sixty_Fourth: {
4328 xmlType = Xml_Ornament;
4331 case Articulation_Marcato:
4332 case Articulation_Marcato_Dot:
4333 case Articulation_Heavy_Attack:
4334 case Articulation_SForzando:
4335 case Articulation_SForzando_Inverted:
4336 case Articulation_SForzando_Dot:
4337 case Articulation_SForzando_Dot_Inverted:
4338 case Articulation_Heavier_Attack:
4339 case Articulation_Staccatissimo:
4340 case Articulation_Staccato:
4341 case Articulation_Tenuto:
4342 case Articulation_Pause:
4343 case Articulation_Grand_Pause: {
4344 xmlType = Xml_Articulation;
4347 case Articulation_Up_Bow:
4348 case Articulation_Down_Bow:
4349 case Articulation_Up_Bow_Inverted:
4350 case Articulation_Down_Bow_Inverted:
4351 case Articulation_Natural_Harmonic:
4352 case Articulation_Artificial_Harmonic:
4353 case Articulation_Finger_1:
4354 case Articulation_Finger_2:
4355 case Articulation_Finger_3:
4356 case Articulation_Finger_4:
4357 case Articulation_Finger_5:
4358 case Articulation_Plus_Sign: {
4359 xmlType = Xml_Technical;
4362 case Articulation_Arpeggio: {
4363 xmlType = Xml_Arpeggiate;
4366 case Articulation_Fermata:
4367 case Articulation_Fermata_Inverted: {
4368 xmlType = Xml_Fermata;
4371 case Articulation_Pedal_Down:
4372 case Articulation_Pedal_Up: {
4373 xmlType = Xml_Direction;
4389 NoteContainer::NoteContainer() {
4390 musicDataType_ = MusicData_Note_Container;
4396 noteType_ = Note_Quarter;
4398 graceNoteType_ = Note_Eight;
4408 NoteContainer::~NoteContainer(){
4409 for(
int i=0; i<notes_.size(); ++i){
4412 for(
int i=0; i<articulations_.size(); ++i){
4413 delete articulations_[i];
4416 articulations_.clear();
4419 void NoteContainer::setIsGrace(
bool grace) {
4423 bool NoteContainer::getIsGrace()
const {
4427 void NoteContainer::setIsCue(
bool cue) {
4431 bool NoteContainer::getIsCue()
const {
4435 void NoteContainer::setIsRest(
bool rest) {
4439 bool NoteContainer::getIsRest()
const {
4443 void NoteContainer::setIsRaw(
bool raw) {
4447 bool NoteContainer::getIsRaw()
const {
4451 void NoteContainer::setNoteType(NoteType type) {
4452 noteType_ = Note_Quarter;
4455 case Note_DoubleWhole:
4474 NoteType NoteContainer::getNoteType()
const {
4478 void NoteContainer::setDot(
int dot) {
4482 int NoteContainer::getDot()
const {
4486 void NoteContainer::setGraceNoteType(NoteType type) {
4487 graceNoteType_ = type;
4490 NoteType NoteContainer::getGraceNoteType()
const {
4491 return graceNoteType_;
4494 void NoteContainer::setInBeam(
bool in) {
4498 bool NoteContainer::getInBeam()
const {
4502 void NoteContainer::setStemUp(
bool up) {
4506 bool NoteContainer::getStemUp(
void)
const {
4510 void NoteContainer::setShowStem(
bool show) {
4514 bool NoteContainer::getShowStem()
const {
4518 void NoteContainer::setStemLength(
int line) {
4522 int NoteContainer::getStemLength()
const {
4526 void NoteContainer::setTuplet(
int tuplet) {
4530 int NoteContainer::getTuplet()
const {
4534 void NoteContainer::setSpace(
int space) {
4538 int NoteContainer::getSpace()
const {
4542 void NoteContainer::addNoteRest(Note* note) {
4543 notes_.push_back(note);
4546 QList<Note*> NoteContainer::getNotesRests()
const {
4550 void NoteContainer::addArticulation(Articulation* art) {
4551 articulations_.push_back(art);
4554 QList<Articulation*> NoteContainer::getArticulations()
const {
4555 return articulations_;
4558 void NoteContainer::setNoteShift(
int octave) {
4559 noteShift_ = octave;
4562 int NoteContainer::getNoteShift()
const {
4566 int NoteContainer::getOffsetStaff()
const {
4571 QList<OVE::Note*> notes = getNotesRests();
4572 for (
int i = 0; i < notes.size(); ++i) {
4573 OVE::Note* notePtr = notes[i];
4574 staffMove = notePtr->getOffsetStaff();
4580 int NoteContainer::getDuration()
const {
4581 int duration = (int) NoteDuration_4;
4583 switch (noteType_) {
4584 case Note_DoubleWhole: {
4585 duration = (int) NoteDuration_Double_Whole;
4589 duration = (int) NoteDuration_Whole;
4593 duration = (int) NoteDuration_2;
4596 case Note_Quarter: {
4597 duration = (int) NoteDuration_4;
4601 duration = (int) NoteDuration_8;
4604 case Note_Sixteen: {
4605 duration = (int) NoteDuration_16;
4609 duration = (int) NoteDuration_32;
4613 duration = (int) NoteDuration_64;
4617 duration = (int) NoteDuration_128;
4621 duration = (int) NoteDuration_256;
4628 int dotLength = duration;
4630 for (
int i = 0; i < dot_; ++i) {
4634 dotLength = duration - dotLength;
4636 duration += dotLength;
4643 musicDataType_ = MusicData_Beam;
4647 void Beam::setIsGrace(
bool grace) {
4651 bool Beam::getIsGrace()
const {
4655 void Beam::addLine(
const MeasurePos& startMp,
const MeasurePos& endMp) {
4656 lines_.push_back(qMakePair(startMp, endMp));
4659 const QList<QPair<MeasurePos, MeasurePos> > Beam::getLines()
const {
4665 musicDataType_ = MusicData_Tie;
4672 void Tie::setShowOnTop(
bool top) {
4676 bool Tie::getShowOnTop()
const {
4680 void Tie::setNote(
int note) {
4684 int Tie::getNote()
const {
4688 void Tie::setHeight(
int height) {
4692 int Tie::getHeight()
const {
4697 Glissando::Glissando() {
4698 musicDataType_ = MusicData_Glissando;
4705 void Glissando::setStraightWavy(
bool straight) {
4706 straight_ = straight;
4709 bool Glissando::getStraightWavy()
const {
4713 void Glissando::setText(
const QString& text) {
4717 QString Glissando::getText()
const {
4721 void Glissando::setLineThick(
int thick) {
4725 int Glissando::getLineThick()
const {
4730 Decorator::Decorator() :
4731 decoratorType_(Decorator_Articulation),
4732 artType_(Articulation_Marcato) {
4733 musicDataType_ = MusicData_Decorator;
4736 void Decorator::setDecoratorType(DecoratorType type) {
4737 decoratorType_ = type;
4740 Decorator::DecoratorType Decorator::getDecoratorType()
const {
4741 return decoratorType_;
4744 void Decorator::setArticulationType(ArticulationType type) {
4748 ArticulationType Decorator::getArticulationType()
const {
4753 MeasureRepeat::MeasureRepeat() {
4754 musicDataType_ = MusicData_Measure_Repeat;
4755 singleRepeat_ =
true;
4758 void MeasureRepeat::setSingleRepeat(
bool single) {
4759 singleRepeat_ = single;
4761 start()->setMeasure(0);
4762 start()->setOffset(0);
4763 stop()->setMeasure(single ? 1 : 2);
4764 stop()->setOffset(0);
4767 bool MeasureRepeat::getSingleRepeat()
const {
4768 return singleRepeat_;
4773 tuplet_(3), space_(2), height_(0), noteType_(Note_Quarter){
4774 musicDataType_ = MusicData_Tuplet;
4775 mark_ =
new OffsetElement();
4782 void Tuplet::setTuplet(
int tuplet) {
4786 int Tuplet::getTuplet()
const {
4790 void Tuplet::setSpace(
int space) {
4794 int Tuplet::getSpace()
const {
4798 OffsetElement* Tuplet::getMarkHandle()
const {
4802 void Tuplet::setHeight(
int height) {
4806 int Tuplet::getHeight()
const {
4810 void Tuplet::setNoteType(NoteType type) {
4814 NoteType Tuplet::getNoteType()
const {
4819 Harmony::Harmony() {
4820 musicDataType_ = MusicData_Harmony;
4822 harmonyType_ = Harmony_maj;
4825 bassOnBottom_ =
false;
4829 void Harmony::setHarmonyType(HarmonyType type) {
4830 harmonyType_ = type;
4833 HarmonyType Harmony::getHarmonyType()
const {
4834 return harmonyType_;
4837 void Harmony::setRoot(
int root) {
4841 int Harmony::getRoot()
const {
4845 void Harmony::setBass(
int bass) {
4849 int Harmony::getBass()
const {
4853 void Harmony::setBassOnBottom(
bool on) {
4857 bool Harmony::getBassOnBottom()
const {
4858 return bassOnBottom_;
4861 void Harmony::setAngle(
int angle) {
4865 int Harmony::getAngle()
const {
4871 musicDataType_ = MusicData_Clef;
4873 clefType_ = Clef_Treble;
4876 void Clef::setClefType(
int type) {
4877 clefType_ = (ClefType) type;
4880 ClefType Clef::getClefType()
const {
4886 musicDataType_ = MusicData_Lyric;
4892 void Lyric::setLyric(
const QString& lyricText) {
4896 QString Lyric::getLyric()
const {
4900 void Lyric::setVerse(
int verse) {
4904 int Lyric::getVerse()
const {
4910 musicDataType_ = MusicData_Slur;
4912 containerCount_ = 1;
4914 noteTimePercent_ = 100;
4916 handle_2_ =
new OffsetElement();
4917 handle_3_ =
new OffsetElement();
4925 void Slur::setContainerCount(
int count) {
4926 containerCount_ = count;
4929 int Slur::getContainerCount()
const {
4930 return containerCount_;
4933 void Slur::setShowOnTop(
bool top) {
4937 bool Slur::getShowOnTop()
const {
4941 OffsetElement* Slur::getHandle2()
const {
4945 OffsetElement* Slur::getHandle3()
const {
4949 void Slur::setNoteTimePercent(
int percent) {
4950 noteTimePercent_ = percent;
4953 int Slur::getNoteTimePercent()
const {
4954 return noteTimePercent_;
4958 Dynamics::Dynamics() {
4959 musicDataType_ = MusicData_Dynamics;
4961 dynamicsType_ = Dynamics_pppp;
4966 void Dynamics::setDynamicsType(
int type) {
4967 dynamicsType_ = (DynamicsType) type;
4970 DynamicsType Dynamics::getDynamicsType()
const {
4971 return dynamicsType_;
4974 void Dynamics::setIsPlayback(
bool play) {
4978 bool Dynamics::getIsPlayback()
const {
4982 void Dynamics::setVelocity(
int vel) {
4986 int Dynamics::getVelocity()
const {
4991 WedgeEndPoint::WedgeEndPoint() {
4992 musicDataType_ = MusicData_Wedge_EndPoint;
4994 wedgeType_ = Wedge_Cres;
4999 void WedgeEndPoint::setWedgeType(WedgeType type) {
5003 WedgeType WedgeEndPoint::getWedgeType()
const {
5007 void WedgeEndPoint::setHeight(
int height) {
5011 int WedgeEndPoint::getHeight()
const {
5015 void WedgeEndPoint::setWedgeStart(
bool wedgeStart) {
5016 wedgeStart_ = wedgeStart;
5019 bool WedgeEndPoint::getWedgeStart()
const {
5025 musicDataType_ = MusicData_Wedge;
5027 wedgeType_ = Wedge_Cres;
5031 void Wedge::setWedgeType(WedgeType type) {
5035 WedgeType Wedge::getWedgeType()
const {
5039 void Wedge::setHeight(
int height) {
5043 int Wedge::getHeight()
const {
5049 musicDataType_ = MusicData_Pedal;
5055 pedalHandle_ =
new OffsetElement();
5059 delete pedalHandle_;
5062 void Pedal::setHalf(
bool half) {
5066 bool Pedal::getHalf()
const {
5070 OffsetElement* Pedal::getPedalHandle()
const {
5071 return pedalHandle_;
5074 void Pedal::setIsPlayback(
bool playback) {
5075 playback_ = playback;
5078 bool Pedal::getIsPlayback()
const {
5082 void Pedal::setPlayOffset(
int offset) {
5083 playOffset_ = offset;
5086 int Pedal::getPlayOffset()
const {
5092 musicDataType_ = MusicData_KuoHao;
5094 kuohaoType_ = KuoHao_Parentheses;
5098 void KuoHao::setHeight(
int height) {
5102 int KuoHao::getHeight()
const {
5106 void KuoHao::setKuohaoType(
int type) {
5107 kuohaoType_ = (KuoHaoType) type;
5110 KuoHaoType KuoHao::getKuohaoType()
const {
5115 Expressions::Expressions() {
5116 musicDataType_ = MusicData_Expressions;
5121 void Expressions::setText(
const QString& str) {
5125 QString Expressions::getText()
const {
5130 HarpPedal::HarpPedal() :
5133 musicDataType_ = MusicData_Harp_Pedal;
5136 void HarpPedal::setShowType(
int type) {
5140 int HarpPedal::getShowType()
const {
5144 void HarpPedal::setShowCharFlag(
int flag) {
5145 showCharFlag_ = flag;
5148 int HarpPedal::getShowCharFlag()
const {
5149 return showCharFlag_;
5153 OctaveShift::OctaveShift() :
5154 octaveShiftType_(OctaveShift_8),
5155 octaveShiftPosition_(OctavePosition_Start),
5157 musicDataType_ = MusicData_OctaveShift;
5160 void OctaveShift::setOctaveShiftType(
int type) {
5161 octaveShiftType_ = (OctaveShiftType) type;
5164 OctaveShiftType OctaveShift::getOctaveShiftType()
const {
5165 return octaveShiftType_;
5168 int OctaveShift::getNoteShift()
const {
5171 switch (getOctaveShiftType()) {
5172 case OctaveShift_8: {
5176 case OctaveShift_Minus_8: {
5180 case OctaveShift_15: {
5184 case OctaveShift_Minus_15: {
5195 void OctaveShift::setEndTick(
int tick) {
5199 int OctaveShift::getEndTick()
const {
5204 OctaveShiftEndPoint::OctaveShiftEndPoint() {
5205 musicDataType_ = MusicData_OctaveShift_EndPoint;
5207 octaveShiftType_ = OctaveShift_8;
5208 octaveShiftPosition_ = OctavePosition_Start;
5212 void OctaveShiftEndPoint::setOctaveShiftType(
int type) {
5213 octaveShiftType_ = (OctaveShiftType) type;
5216 OctaveShiftType OctaveShiftEndPoint::getOctaveShiftType()
const {
5217 return octaveShiftType_;
5220 void OctaveShiftEndPoint::setOctaveShiftPosition(
int position) {
5221 octaveShiftPosition_ = (OctaveShiftPosition) position;
5224 OctaveShiftPosition OctaveShiftEndPoint::getOctaveShiftPosition()
const {
5225 return octaveShiftPosition_;
5228 void OctaveShiftEndPoint::setEndTick(
int tick) {
5232 int OctaveShiftEndPoint::getEndTick()
const {
5237 MultiMeasureRest::MultiMeasureRest() {
5238 musicDataType_ = MusicData_Multi_Measure_Rest;
5242 void MultiMeasureRest::setMeasureCount(
int count) {
5243 measureCount_ = count;
5246 int MultiMeasureRest::getMeasureCount()
const {
5247 return measureCount_;
5252 musicDataType_ = MusicData_Tempo;
5257 showParenthesis_ =
false;
5259 leftText_ = QString();
5260 rightText_ = QString();
5261 swingEighth_ =
false;
5265 void Tempo::setLeftNoteType(
int type) {
5266 leftNoteType_ = type;
5269 NoteType Tempo::getLeftNoteType()
const {
5270 return (NoteType) leftNoteType_;
5273 void Tempo::setShowMark(
bool show) {
5277 bool Tempo::getShowMark()
const {
5281 void Tempo::setShowBeforeText(
bool show) {
5285 bool Tempo::getShowBeforeText()
const {
5289 void Tempo::setShowParenthesis(
bool show) {
5290 showParenthesis_ = show;
5293 bool Tempo::getShowParenthesis()
const {
5294 return showParenthesis_;
5297 void Tempo::setTypeTempo(
int tempo) {
5301 int Tempo::getTypeTempo()
const {
5305 int Tempo::getQuarterTempo()
const {
5306 double factor = pow(2.0, (
int) Note_Quarter - (
int) getLeftNoteType());
5307 int tempo = int((
double) getTypeTempo() * factor);
5312 void Tempo::setLeftText(
const QString& str) {
5316 QString Tempo::getLeftText()
const {
5320 void Tempo::setRightText(
const QString& str) {
5324 QString Tempo::getRightText()
const {
5328 void Tempo::setSwingEighth(
bool swing) {
5329 swingEighth_ = swing;
5332 bool Tempo::getSwingEighth()
const {
5333 return swingEighth_;
5336 void Tempo::setRightNoteType(
int type) {
5337 rightNoteType_ = type;
5340 int Tempo::getRightNoteType()
const {
5341 return rightNoteType_;
5346 musicDataType_ = MusicData_Text;
5348 textType_ = Text_Rehearsal;
5357 void Text::setTextType(TextType type) {
5361 Text::TextType Text::getTextType()
const {
5365 void Text::setHorizontalMargin(
int margin) {
5366 horiMargin_ = margin;
5369 int Text::getHorizontalMargin()
const {
5373 void Text::setVerticalMargin(
int margin) {
5374 vertMargin_ = margin;
5377 int Text::getVerticalMargin()
const {
5381 void Text::setLineThick(
int thick) {
5385 int Text::getLineThick()
const {
5389 void Text::setText(
const QString& text) {
5393 QString Text::getText()
const {
5397 void Text::setWidth(
int width) {
5401 int Text::getWidth()
const {
5405 void Text::setHeight(
int height) {
5409 int Text::getHeight()
const {
5414 TimeSignature::TimeSignature() {
5420 barLengthUnits_ = 0x400;
5421 replaceFont_ =
false;
5422 showBeatGroup_ =
false;
5424 groupNumerator1_ = 0;
5425 groupNumerator2_ = 0;
5426 groupNumerator3_ = 0;
5427 groupDenominator1_ = 4;
5428 groupDenominator2_ = 4;
5429 groupDenominator3_ = 4;
5440 void TimeSignature::setNumerator(
int numerator) {
5441 numerator_ = numerator;
5444 int TimeSignature::getNumerator()
const {
5448 void TimeSignature::setDenominator(
int denominator) {
5449 denominator_ = denominator;
5452 int TimeSignature::getDenominator()
const {
5453 return denominator_;
5456 void TimeSignature::setIsSymbol(
bool symbol) {
5460 bool TimeSignature::getIsSymbol()
const {
5461 if (numerator_ == 2 && denominator_ == 2) {
5468 void TimeSignature::setBeatLength(
int length) {
5469 beatLength_ = length;
5472 int TimeSignature::getBeatLength()
const {
5476 void TimeSignature::setBarLength(
int length) {
5477 barLength_ = length;
5480 int TimeSignature::getBarLength()
const {
5484 void TimeSignature::addBeat(
int startUnit,
int lengthUnit,
int startTick) {
5486 node.startUnit_ = startUnit;
5487 node.lengthUnit_ = lengthUnit;
5488 node.startTick_ = startTick;
5489 beats_.push_back(node);
5492 void TimeSignature::endAddBeat()
5495 barLengthUnits_ = 0;
5497 for (i = 0; i < beats_.size(); ++i) {
5498 barLengthUnits_ += beats_[i].lengthUnit_;
5502 int TimeSignature::getUnits()
const {
5503 return barLengthUnits_;
5506 void TimeSignature::setReplaceFont(
bool replace) {
5507 replaceFont_ = replace;
5510 bool TimeSignature::getReplaceFont()
const {
5511 return replaceFont_;
5514 void TimeSignature::setShowBeatGroup(
bool show) {
5515 showBeatGroup_ = show;
5518 bool TimeSignature::getShowBeatGroup()
const {
5519 return showBeatGroup_;
5522 void TimeSignature::setGroupNumerator1(
int numerator) {
5523 groupNumerator1_ = numerator;
5526 void TimeSignature::setGroupNumerator2(
int numerator) {
5527 groupNumerator2_ = numerator;
5530 void TimeSignature::setGroupNumerator3(
int numerator) {
5531 groupNumerator3_ = numerator;
5534 void TimeSignature::setGroupDenominator1(
int denominator) {
5535 groupDenominator1_ = denominator;
5538 void TimeSignature::setGroupDenominator2(
int denominator) {
5539 groupDenominator2_ = denominator;
5542 void TimeSignature::setGroupDenominator3(
int denominator) {
5543 groupDenominator3_ = denominator;
5546 void TimeSignature::setBeamGroup1(
int count) {
5547 beamGroup1_ = count;
5550 void TimeSignature::setBeamGroup2(
int count) {
5551 beamGroup2_ = count;
5554 void TimeSignature::setBeamGroup3(
int count) {
5555 beamGroup3_ = count;
5558 void TimeSignature::setBeamGroup4(
int count) {
5559 beamGroup4_ = count;
5562 void TimeSignature::set16thBeamCount(
int count) {
5563 beamCount16th_ = count;
5566 void TimeSignature::set32thBeamCount(
int count) {
5567 beamCount32th_ = count;
5578 void Key::setKey(
int key) {
5583 int Key::getKey()
const {
5587 bool Key::getSetKey()
const {
5591 void Key::setPreviousKey(
int key) {
5595 int Key::getPreviousKey()
const {
5596 return previousKey_;
5599 void Key::setSymbolCount(
int count) {
5600 symbolCount_ = count;
5603 int Key::getSymbolCount()
const {
5604 return symbolCount_;
5608 RepeatSymbol::RepeatSymbol() :
5609 text_(
"#1"), repeatType_(Repeat_Segno) {
5610 musicDataType_ = MusicData_Repeat;
5613 void RepeatSymbol::setText(
const QString& text) {
5617 QString RepeatSymbol::getText()
const {
5621 void RepeatSymbol::setRepeatType(
int repeatType) {
5622 repeatType_ = (RepeatType) repeatType;
5625 RepeatType RepeatSymbol::getRepeatType()
const {
5630 NumericEnding::NumericEnding() {
5631 musicDataType_ = MusicData_Numeric_Ending;
5635 numericHandle_ =
new OffsetElement();
5638 NumericEnding::~NumericEnding() {
5639 delete numericHandle_;
5642 OffsetElement* NumericEnding::getNumericHandle()
const {
5643 return numericHandle_;
5646 void NumericEnding::setHeight(
int height) {
5650 int NumericEnding::getHeight()
const {
5654 void NumericEnding::setText(
const QString& text) {
5658 QString NumericEnding::getText()
const {
5662 QList<int> NumericEnding::getNumbers()
const {
5664 QStringList strs = text_.split(
",", QString::SkipEmptyParts);
5667 for (i = 0; i < strs.size(); ++i) {
5669 int num = strs[i].toInt(&ok);
5670 endings.push_back(num);
5676 int NumericEnding::getJumpCount()
const {
5677 QList<int> numbers = getNumbers();
5680 for (
int i = 0; i < numbers.size(); ++i) {
5681 if ((
int)i + 1 != numbers[i]) {
5692 BarNumber::BarNumber() {
5694 showOnParagraphStart_ =
false;
5698 prefix_ = QString();
5701 void BarNumber::setIndex(
int index) {
5705 int BarNumber::getIndex()
const {
5709 void BarNumber::setShowOnParagraphStart(
bool show) {
5710 showOnParagraphStart_ = show;
5713 bool BarNumber::getShowOnParagraphStart()
const {
5714 return showOnParagraphStart_;
5717 void BarNumber::setAlign(
int align)
5722 int BarNumber::getAlign()
const {
5726 void BarNumber::setShowFlag(
int flag) {
5730 int BarNumber::getShowFlag()
const {
5734 void BarNumber::setShowEveryBarCount(
int count) {
5738 int BarNumber::getShowEveryBarCount()
const {
5742 void BarNumber::setPrefix(
const QString& str) {
5746 QString BarNumber::getPrefix()
const {
5751 MidiController::MidiController() {
5752 midiType_ = Midi_Controller;
5757 void MidiController::setController(
int number) {
5758 controller_ = number;
5761 int MidiController::getController()
const {
5765 void MidiController::setValue(
int value) {
5769 int MidiController::getValue()
const {
5774 MidiProgramChange::MidiProgramChange() {
5775 midiType_ = Midi_Program_Change;
5779 void MidiProgramChange::setPatch(
int patch) {
5783 int MidiProgramChange::getPatch()
const {
5788 MidiChannelPressure::MidiChannelPressure() :
5790 midiType_ = Midi_Channel_Pressure;
5793 void MidiChannelPressure::setPressure(
int pressure) {
5794 pressure_ = pressure;
5797 int MidiChannelPressure::getPressure()
const {
5802 MidiPitchWheel::MidiPitchWheel() {
5803 midiType_ = Midi_Pitch_Wheel;
5807 void MidiPitchWheel::setValue(
int value) {
5811 int MidiPitchWheel::getValue()
const {
5816 Measure::Measure(
int index) {
5817 barNumber_ =
new BarNumber();
5818 barNumber_->setIndex(index);
5819 time_ =
new TimeSignature();
5824 Measure::~Measure(){
5831 BarNumber* Measure::getBarNumber()
const {
5835 TimeSignature* Measure::getTime()
const {
5839 void Measure::setLeftBarline(
int barline) {
5840 leftBarline_ = (BarlineType) barline;
5843 BarlineType Measure::getLeftBarline()
const {
5844 return leftBarline_;
5847 void Measure::setRightBarline(
int barline) {
5848 rightBarline_ = (BarlineType) barline;
5851 BarlineType Measure::getRightBarline()
const {
5852 return rightBarline_;
5855 void Measure::setBackwardRepeatCount(
int repeatCount) {
5856 repeatCount_ = repeatCount;
5859 int Measure::getBackwardRepeatCount()
const {
5860 return repeatCount_;
5863 void Measure::setTypeTempo(
double tempo) {
5867 double Measure::getTypeTempo()
const {
5871 void Measure::setIsPickup(
bool pickup) {
5875 bool Measure::getIsPickup()
const {
5879 void Measure::setIsMultiMeasureRest(
bool rest) {
5880 multiMeasureRest_ = rest;
5883 bool Measure::getIsMultiMeasureRest()
const {
5884 return multiMeasureRest_;
5887 void Measure::setMultiMeasureRestCount(
int count) {
5888 multiMeasureRestCount_ = count;
5891 int Measure::getMultiMeasureRestCount()
const {
5892 return multiMeasureRestCount_;
5895 void Measure::clear() {
5896 leftBarline_ = Barline_Default;
5897 rightBarline_ = Barline_Default;
5902 multiMeasureRest_ =
false;
5903 multiMeasureRestCount_ = 0;
5907 MeasureData::MeasureData() {
5912 MeasureData::~MeasureData(){
5914 for(i=0; i<musicDatas_.size(); ++i){
5915 delete musicDatas_[i];
5917 musicDatas_.clear();
5920 noteContainers_.clear();
5923 for(i=0; i<crossMeasureElements_.size(); ++i){
5924 if(crossMeasureElements_[i].second){
5925 delete crossMeasureElements_[i].first;
5928 crossMeasureElements_.clear();
5930 for(i=0; i<midiDatas_.size(); ++i){
5931 delete midiDatas_[i];
5939 Key* MeasureData::getKey()
const {
5943 Clef* MeasureData::getClef()
const {
5947 void MeasureData::addNoteContainer(NoteContainer* ptr) {
5948 noteContainers_.push_back(ptr);
5951 QList<NoteContainer*> MeasureData::getNoteContainers()
const {
5952 return noteContainers_;
5955 void MeasureData::addMusicData(MusicData* ptr) {
5956 musicDatas_.push_back(ptr);
5959 QList<MusicData*> MeasureData::getMusicDatas(MusicDataType type) {
5961 QList<MusicData*> notations;
5963 for (i = 0; i < musicDatas_.size(); ++i) {
5964 if (type == MusicData_None || musicDatas_[i]->getMusicDataType() == type) {
5965 notations.push_back(musicDatas_[i]);
5972 void MeasureData::addCrossMeasureElement(MusicData* ptr,
bool start) {
5973 crossMeasureElements_.push_back(qMakePair(ptr, start));
5976 QList<MusicData*> MeasureData::getCrossMeasureElements(
5977 MusicDataType type, PairType pairType)
5980 QList<MusicData*> pairs;
5982 for (i = 0; i < crossMeasureElements_.size(); ++i) {
5983 if ((type == MusicData_None || crossMeasureElements_[i].first->getMusicDataType() == type)
5984 && (pairType == PairType_All || ((crossMeasureElements_[i].second && pairType == PairType_Start)
5985 || (!crossMeasureElements_[i].second && pairType == PairType_Stop)))) {
5986 pairs.push_back(crossMeasureElements_[i].first);
5993 void MeasureData::addMidiData(MidiData* ptr) {
5994 midiDatas_.push_back(ptr);
5997 QList<MidiData*> MeasureData::getMidiDatas(MidiType type) {
5999 QList<MidiData*> datas;
6001 for (i = 0; i < midiDatas_.size(); ++i) {
6002 if (type == Midi_None || midiDatas_[i]->getMidiType() == type) {
6003 datas.push_back(midiDatas_[i]);
6012 StreamHandle::StreamHandle() :
6013 size_(0), curPos_(0), point_(NULL) {
6016 StreamHandle::StreamHandle(
unsigned char* p,
int size) :
6017 size_(size), curPos_(0), point_(p) {
6020 StreamHandle::~StreamHandle() {
6024 bool StreamHandle::read(
char* buff,
int size) {
6025 if (point_ != NULL && curPos_ + size <= size_) {
6026 memcpy(buff, point_ + curPos_, size);
6035 bool StreamHandle::write(
char* ,
int ) {
6045 Block::Block(
unsigned int count) {
6049 void Block::resize(
unsigned int count) {
6053 void Block::doResize(
unsigned int count) {
6055 for(
unsigned int i=0; i<count; ++i) {
6056 data_.push_back(
'\0');
6061 const unsigned char* Block::data()
const {
6063 return &data_.front();
6066 unsigned char* Block::data() {
6067 return &data_.front();
6070 unsigned int Block::size()
const {
6071 return data_.size();
6074 bool Block::toBoolean()
const {
6075 if (data() == NULL) {
6079 return size() == 1 && data()[0] == 0x01;
6082 unsigned int Block::toUnsignedInt()
const {
6083 if (data() == NULL) {
6088 unsigned int num(0);
6090 for (i = 0; i <
sizeof(
unsigned int) && i < size(); ++i) {
6091 num = (num << 8) + *(data() + i);
6097 int Block::toInt()
const {
6098 if (data() == NULL) {
6105 for (i = 0; i <
sizeof(
unsigned int) && i < size(); ++i) {
6106 num = (num << 8) + (
int) *(data() + i);
6109 std::size_t minSize =
sizeof(
unsigned int);
6110 if (size() < minSize) {
6114 if ((*(data()) & 0x80) == 0x80) {
6115 int maxNum = int(pow(2.0, (
int) minSize * 8));
6123 QByteArray Block::toStrByteArray()
const {
6124 if (data() == NULL) {
6125 return QByteArray();
6128 QByteArray arr((
char*) data(), size());
6133 QByteArray Block::fixedSizeBufferToStrByteArray()
const {
6137 for (i = 0; i < size(); ++i) {
6138 if (*(data() + i) ==
'\0') {
6142 str += (char) *(data() + i);
6148 bool Block::operator ==(
const Block& block)
const {
6151 if (size() != block.size()) {
6155 for (i = 0; i < size() && i < block.size(); ++i) {
6156 if (*(data() + i) != *(block.data() + i)) {
6164 bool Block::operator !=(
const Block& block)
const {
6165 return !(*
this == block);
6169 FixedBlock::FixedBlock() :
6173 FixedBlock::FixedBlock(
unsigned int count) :
6177 void FixedBlock::resize(
unsigned int ) {
6182 SizeBlock::SizeBlock() :
6186 unsigned int SizeBlock::toSize()
const {
6188 unsigned int num(0);
6189 const unsigned int SIZE = 4;
6191 for (i = 0; i < SIZE; ++i) {
6192 num = (num << 8) + *(data() + i);
6204 NameBlock::NameBlock() :
6218 bool NameBlock::isEqual(
const QString& name)
const 6220 unsigned int i, nsize =
static_cast<unsigned>(name.size());
6222 if (nsize != size()) {
6226 for (i = 0; i < size() && nsize; ++i) {
6227 if (data()[i] != name[i]) {
6236 CountBlock::CountBlock() :
6252 unsigned short CountBlock::toCount()
const {
6254 unsigned short num = 0;
6256 for (i = 0; i < size() && i <
sizeof(
unsigned short); ++i) {
6257 num = (num << 8) + *(data() + i);
6264 const QString Chunk::TrackName =
"TRAK";
6265 const QString Chunk::PageName =
"PAGE";
6266 const QString Chunk::LineName =
"LINE";
6267 const QString Chunk::StaffName =
"STAF";
6268 const QString Chunk::MeasureName =
"MEAS";
6269 const QString Chunk::ConductName =
"COND";
6270 const QString Chunk::BdatName =
"BDAT";
6275 NameBlock Chunk::getName()
const {
6280 const unsigned int SizeChunk::version3TrackSize = 0x13a;
6282 SizeChunk::SizeChunk() :
6284 sizeBlock_ =
new SizeBlock();
6285 dataBlock_ =
new Block();
6288 SizeChunk::~SizeChunk() {
6293 SizeBlock* SizeChunk::getSizeBlock()
const {
6297 Block* SizeChunk::getDataBlock()
const {
6302 GroupChunk::GroupChunk() : Chunk() {
6303 childCount_ =
new CountBlock();
6306 GroupChunk::~GroupChunk() {
6310 CountBlock* GroupChunk::getCountBlock()
const {
6315 unsigned int getHighNibble(
unsigned int byte) {
6319 unsigned int getLowNibble(
unsigned int byte) {
6323 int oveKeyToKey(
int oveKey) {
6329 else if( oveKey > 7 ) {
6332 else if( oveKey <= 7 ) {
6333 key = oveKey * (-1);
6340 BasicParse::BasicParse(OveSong* ove) :
6341 ove_(ove), handle_(NULL), notify_(NULL) {
6344 BasicParse::BasicParse() :
6345 ove_(NULL), handle_(NULL), notify_(NULL) {
6348 BasicParse::~BasicParse() {
6354 void BasicParse::setNotify(IOveNotify* notify) {
6358 bool BasicParse::parse() {
6362 bool BasicParse::readBuffer(Block& placeHolder,
unsigned int size) {
6363 if (handle_ == NULL) {
6366 if (placeHolder.size() != size) {
6367 placeHolder.resize(size);
6371 return handle_->read((
char*) placeHolder.data(), placeHolder.size());
6377 bool BasicParse::jump(
int offset) {
6378 if (handle_ == NULL || offset < 0) {
6383 Block placeHolder(offset);
6384 return handle_->read((
char*) placeHolder.data(), placeHolder.size());
6390 void BasicParse::messageOut(
const QString& str) {
6391 if (notify_ != NULL) {
6392 notify_->loadInfo(str);
6397 OvscParse::OvscParse(OveSong* ove) :
6398 BasicParse(ove), chunk_(NULL) {
6401 OvscParse::~OvscParse() {
6405 void OvscParse::setOvsc(SizeChunk* chunk) {
6409 bool OvscParse::parse() {
6410 Block* dataBlock = chunk_->getDataBlock();
6411 unsigned int blockSize = chunk_->getSizeBlock()->toSize();
6412 StreamHandle handle(dataBlock->data(), blockSize);
6418 if (!readBuffer(placeHolder, 1)) {
return false; }
6419 bool version4 = placeHolder.toUnsignedInt() == 4;
6420 ove_->setIsVersion4(version4);
6422 QString str = QString(
"This file is created by Overture ") + (version4 ?
"4" :
"3");
6425 if( !jump(6) ) {
return false; }
6428 if (!readBuffer(placeHolder, 1)) {
return false; }
6429 ove_->setShowPageMargin(placeHolder.toBoolean());
6431 if( !jump(1) ) {
return false; }
6434 if (!readBuffer(placeHolder, 1)) {
return false; }
6435 ove_->setShowTransposeTrack(placeHolder.toBoolean());
6438 if (!readBuffer(placeHolder, 1)) {
return false; }
6439 ove_->setPlayRepeat(placeHolder.toBoolean());
6442 if (!readBuffer(placeHolder, 1)) {
return false; }
6443 OveSong::PlayStyle style = OveSong::Record;
6444 if(placeHolder.toUnsignedInt() == 1){
6445 style = OveSong::Swing;
6447 else if(placeHolder.toUnsignedInt() == 2){
6448 style = OveSong::Notation;
6450 ove_->setPlayStyle(style);
6453 if (!readBuffer(placeHolder, 1)) {
return false; }
6454 ove_->setShowLineBreak(placeHolder.toBoolean());
6457 if (!readBuffer(placeHolder, 1)) {
return false; }
6458 ove_->setShowRuler(placeHolder.toBoolean());
6461 if (!readBuffer(placeHolder, 1)) {
return false; }
6462 ove_->setShowColor(placeHolder.toBoolean());
6468 TrackParse::TrackParse(OveSong* ove)
6472 TrackParse::~TrackParse() {
6475 void TrackParse::setTrack(SizeChunk* chunk) {
6479 bool TrackParse::parse()
6481 Block* dataBlock = chunk_->getDataBlock();
6482 unsigned int blockSize = ove_->getIsVersion4() ? chunk_->getSizeBlock()->toSize() : SizeChunk::version3TrackSize;
6483 StreamHandle handle(dataBlock->data(), blockSize);
6488 Track* oveTrack =
new Track();
6489 ove_->addTrack(oveTrack);
6492 if( !readBuffer(placeHolder, 32) ) {
return false; }
6493 oveTrack->setName(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
6495 if( !readBuffer(placeHolder, 32) ) {
return false; }
6496 oveTrack->setBriefName(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
6498 if( !jump(8) ) {
return false; }
6499 if( !jump(1) ) {
return false; }
6502 if( !readBuffer(placeHolder, 1) ) {
return false; }
6503 unsigned int thisByte = placeHolder.toInt();
6504 oveTrack->setPatch(thisByte&0x7f);
6507 if( !readBuffer(placeHolder, 1) ) {
return false; }
6508 oveTrack->setShowName(placeHolder.toBoolean());
6511 if( !readBuffer(placeHolder, 1) ) {
return false; }
6512 oveTrack->setShowBriefName(placeHolder.toBoolean());
6514 if( !jump(1) ) {
return false; }
6517 if( !readBuffer(placeHolder, 1) ) {
return false; }
6518 oveTrack->setShowTranspose(placeHolder.toBoolean());
6520 if( !jump(1) ) {
return false; }
6523 if( !readBuffer(placeHolder, 1) ) {
return false; }
6524 oveTrack->setMute(placeHolder.toBoolean());
6527 if( !readBuffer(placeHolder, 1) ) {
return false; }
6528 oveTrack->setSolo(placeHolder.toBoolean());
6530 if( !jump(1) ) {
return false; }
6533 if( !readBuffer(placeHolder, 1) ) {
return false; }
6534 oveTrack->setShowKeyEachLine(placeHolder.toBoolean());
6537 if( !readBuffer(placeHolder, 1) ) {
return false; }
6538 oveTrack->setVoiceCount(placeHolder.toUnsignedInt());
6540 if( !jump(3) ) {
return false; }
6543 if( !readBuffer(placeHolder, 1) ) {
return false; }
6544 oveTrack->setTranspose(placeHolder.toInt());
6546 if( !jump(2) ) {
return false; }
6549 if( !readBuffer(placeHolder, 1) ) {
return false; }
6550 oveTrack->setStartClef(placeHolder.toUnsignedInt());
6553 if( !readBuffer(placeHolder, 1) ) {
return false; }
6554 oveTrack->setTransposeClef(placeHolder.toUnsignedInt());
6557 if( !readBuffer(placeHolder, 1) ) {
return false; }
6558 oveTrack->setStartKey(placeHolder.toUnsignedInt());
6561 if( !readBuffer(placeHolder, 1) ) {
return false; }
6562 oveTrack->setDisplayPercent(placeHolder.toUnsignedInt());
6565 if( !readBuffer(placeHolder, 1) ) {
return false; }
6566 oveTrack->setShowLegerLine(placeHolder.toBoolean());
6569 if( !readBuffer(placeHolder, 1) ) {
return false; }
6570 oveTrack->setShowClef(placeHolder.toBoolean());
6573 if( !readBuffer(placeHolder, 1) ) {
return false; }
6574 oveTrack->setShowTimeSignature(placeHolder.toBoolean());
6577 if( !readBuffer(placeHolder, 1) ) {
return false; }
6578 oveTrack->setShowKeySignature(placeHolder.toBoolean());
6581 if( !readBuffer(placeHolder, 1) ) {
return false; }
6582 oveTrack->setShowBarline(placeHolder.toBoolean());
6585 if( !readBuffer(placeHolder, 1) ) {
return false; }
6586 oveTrack->setFillWithRest(placeHolder.toBoolean());
6589 if( !readBuffer(placeHolder, 1) ) {
return false; }
6590 oveTrack->setFlatTail(placeHolder.toBoolean());
6593 if( !readBuffer(placeHolder, 1) ) {
return false; }
6594 oveTrack->setShowClefEachLine(placeHolder.toBoolean());
6596 if( !jump(12) ) {
return false; }
6600 QList<Voice*> voices;
6601 for( i=0; i<8; ++i ) {
6602 Voice* voicePtr =
new Voice();
6604 if( !jump(5) ) {
return false; }
6607 if( !readBuffer(placeHolder, 1) ) {
return false; }
6608 voicePtr->setChannel(placeHolder.toUnsignedInt());
6611 if( !readBuffer(placeHolder, 1) ) {
return false; }
6612 voicePtr->setVolume(placeHolder.toInt());
6615 if( !readBuffer(placeHolder, 1) ) {
return false; }
6616 voicePtr->setPitchShift(placeHolder.toInt());
6619 if( !readBuffer(placeHolder, 1) ) {
return false; }
6620 voicePtr->setPan(placeHolder.toInt());
6622 if( !jump(6) ) {
return false; }
6625 if( !readBuffer(placeHolder, 1) ) {
return false; }
6626 voicePtr->setPatch(placeHolder.toInt());
6628 voices.push_back(voicePtr);
6632 for( i=0; i<8; ++i ) {
6633 if( !readBuffer(placeHolder, 1) ) {
return false; }
6634 voices[i]->setStemType(placeHolder.toUnsignedInt());
6636 oveTrack->addVoice(voices[i]);
6640 QList<Track::DrumNode> nodes;
6641 for(i=0; i<16; ++i) {
6642 nodes.push_back(Track::DrumNode());
6646 for( i=0; i<16; ++i ) {
6647 if( !readBuffer(placeHolder, 1) ) {
return false; }
6648 nodes[i].line_ = placeHolder.toInt();
6652 for( i=0; i<16; ++i ) {
6653 if( !readBuffer(placeHolder, 1) ) {
return false; }
6654 nodes[i].headType_ = placeHolder.toUnsignedInt();
6658 for( i=0; i<16; ++i ) {
6659 if( !readBuffer(placeHolder, 1) ) {
return false; }
6660 nodes[i].pitch_ = placeHolder.toUnsignedInt();
6664 for( i=0; i<16; ++i ) {
6665 if( !readBuffer(placeHolder, 1) ) {
return false; }
6666 nodes[i].voice_ = placeHolder.toUnsignedInt();
6669 for( i=0; i<nodes.size(); ++i ) {
6670 oveTrack->addDrum(nodes[i]);
6685 GroupParse::GroupParse(OveSong* ove)
6689 GroupParse::~GroupParse(){
6690 sizeChunks_.clear();
6693 void GroupParse::addSizeChunk(SizeChunk* sizeChunk) {
6694 sizeChunks_.push_back(sizeChunk);
6697 bool GroupParse::parse() {
6702 PageGroupParse::PageGroupParse(OveSong* ove)
6706 PageGroupParse::~PageGroupParse(){
6707 pageChunks_.clear();
6710 void PageGroupParse::addPage(SizeChunk* chunk) {
6711 pageChunks_.push_back(chunk);
6714 bool PageGroupParse::parse()
6716 if( pageChunks_.empty() ) {
6721 for( i=0; i<pageChunks_.size(); ++i ) {
6722 Page* page =
new Page();
6723 ove_->addPage(page);
6725 if( !parsePage(pageChunks_[i], page) ) {
return false; }
6731 bool PageGroupParse::parsePage(SizeChunk* chunk, Page* page) {
6732 Block placeHolder(2);
6733 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
6738 if( !readBuffer(placeHolder, 2) ) {
return false; }
6739 page->setBeginLine(placeHolder.toUnsignedInt());
6742 if( !readBuffer(placeHolder, 2) ) {
return false; }
6743 page->setLineCount(placeHolder.toUnsignedInt());
6745 if( !jump(4) ) {
return false; }
6748 if( !readBuffer(placeHolder, 2) ) {
return false; }
6749 page->setStaffInterval(placeHolder.toUnsignedInt());
6752 if( !readBuffer(placeHolder, 2) ) {
return false; }
6753 page->setLineInterval(placeHolder.toUnsignedInt());
6756 if( !readBuffer(placeHolder, 2) ) {
return false; }
6757 page->setStaffInlineInterval(placeHolder.toUnsignedInt());
6760 if( !readBuffer(placeHolder, 2) ) {
return false; }
6761 page->setLineBarCount(placeHolder.toUnsignedInt());
6764 if( !readBuffer(placeHolder, 2) ) {
return false; }
6765 page->setPageLineCount(placeHolder.toUnsignedInt());
6768 if( !readBuffer(placeHolder, 4) ) {
return false; }
6769 page->setLeftMargin(placeHolder.toUnsignedInt());
6772 if( !readBuffer(placeHolder, 4) ) {
return false; }
6773 page->setTopMargin(placeHolder.toUnsignedInt());
6776 if( !readBuffer(placeHolder, 4) ) {
return false; }
6777 page->setRightMargin(placeHolder.toUnsignedInt());
6780 if( !readBuffer(placeHolder, 4) ) {
return false; }
6781 page->setBottomMargin(placeHolder.toUnsignedInt());
6784 if( !readBuffer(placeHolder, 4) ) {
return false; }
6785 page->setPageWidth(placeHolder.toUnsignedInt());
6788 if( !readBuffer(placeHolder, 4) ) {
return false; }
6789 page->setPageHeight(placeHolder.toUnsignedInt());
6797 StaffCountGetter::StaffCountGetter(OveSong* ove)
6801 unsigned int StaffCountGetter::getStaffCount(SizeChunk* chunk) {
6802 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
6807 if( !jump(6) ) {
return false; }
6810 if( !readBuffer(placeHolder, 2) ) {
return false; }
6811 return placeHolder.toUnsignedInt();
6815 LineGroupParse::LineGroupParse(OveSong* ove) :
6816 BasicParse(ove), chunk_(NULL) {
6819 LineGroupParse::~LineGroupParse(){
6821 lineChunks_.clear();
6822 staffChunks_.clear();
6825 void LineGroupParse::setLineGroup(GroupChunk* chunk) {
6829 void LineGroupParse::addLine(SizeChunk* chunk) {
6830 lineChunks_.push_back(chunk);
6833 void LineGroupParse::addStaff(SizeChunk* chunk) {
6834 staffChunks_.push_back(chunk);
6837 bool LineGroupParse::parse()
6839 if( lineChunks_.empty() || staffChunks_.size() % lineChunks_.size() != 0 ) {
return false; }
6843 unsigned int lineStaffCount = staffChunks_.size() / lineChunks_.size();
6845 for( i=0; i<lineChunks_.size(); ++i ) {
6846 Line* linePtr =
new Line();
6848 ove_->addLine(linePtr);
6850 if( !parseLine(lineChunks_[i], linePtr) ) {
return false; }
6852 for( j=lineStaffCount*i; j<lineStaffCount*(i+1); ++j ) {
6853 Staff* staffPtr =
new Staff();
6855 linePtr->addStaff(staffPtr);
6857 if( !parseStaff(staffChunks_[j], staffPtr) ) {
return false; }
6864 bool LineGroupParse::parseLine(SizeChunk* chunk, Line* line) {
6867 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
6871 if( !jump(2) ) {
return false; }
6874 if( !readBuffer(placeHolder, 2) ) {
return false; }
6875 line->setBeginBar(placeHolder.toUnsignedInt());
6878 if( !readBuffer(placeHolder, 2) ) {
return false; }
6879 line->setBarCount(placeHolder.toUnsignedInt());
6881 if( !jump(6) ) {
return false; }
6884 if( !readBuffer(placeHolder, 2) ) {
return false; }
6885 line->setYOffset(placeHolder.toInt());
6888 if( !readBuffer(placeHolder, 2) ) {
return false; }
6889 line->setLeftXOffset(placeHolder.toInt());
6892 if( !readBuffer(placeHolder, 2) ) {
return false; }
6893 line->setRightXOffset(placeHolder.toInt());
6895 if( !jump(4) ) {
return false; }
6902 bool LineGroupParse::parseStaff(SizeChunk* chunk, Staff* staff) {
6905 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
6909 if( !jump(7) ) {
return false; }
6912 if( !readBuffer(placeHolder, 1) ) {
return false; }
6913 staff->setClefType(placeHolder.toUnsignedInt());
6916 if( !readBuffer(placeHolder, 1) ) {
return false; }
6917 staff->setKeyType(oveKeyToKey(placeHolder.toUnsignedInt()));
6919 if( !jump(2) ) {
return false; }
6922 if( !readBuffer(placeHolder, 1) ) {
return false; }
6923 staff->setVisible(placeHolder.toBoolean());
6925 if( !jump(12) ) {
return false; }
6928 if( !readBuffer(placeHolder, 2) ) {
return false; }
6929 staff->setYOffset(placeHolder.toInt());
6931 int jumpAmount = ove_->getIsVersion4() ? 26 : 18;
6932 if( !jump(jumpAmount) ) {
return false; }
6935 if( !readBuffer(placeHolder, 1) ) {
return false; }
6936 GroupType groupType = Group_None;
6937 if(placeHolder.toUnsignedInt() == 1) {
6938 groupType = Group_Brace;
6939 }
else if(placeHolder.toUnsignedInt() == 2) {
6940 groupType = Group_Bracket;
6942 staff->setGroupType(groupType);
6945 if( !readBuffer(placeHolder, 1) ) {
return false; }
6946 staff->setGroupStaffCount(placeHolder.toUnsignedInt());
6954 BarsParse::BarsParse(OveSong* ove) :
6958 BarsParse::~BarsParse(){
6959 measureChunks_.clear();
6960 conductChunks_.clear();
6961 bdatChunks_.clear();
6964 void BarsParse::addMeasure(SizeChunk* chunk) {
6965 measureChunks_.push_back(chunk);
6968 void BarsParse::addConduct(SizeChunk* chunk) {
6969 conductChunks_.push_back(chunk);
6972 void BarsParse::addBdat(SizeChunk* chunk) {
6973 bdatChunks_.push_back(chunk);
6976 bool BarsParse::parse() {
6978 int trackMeasureCount = ove_->getTrackBarCount();
6979 int trackCount = ove_->getTrackCount();
6980 int measureDataCount = trackCount * measureChunks_.size();
6981 QList<Measure*> measures;
6982 QList<MeasureData*> measureDatas;
6984 if( measureChunks_.empty() ||
6985 measureChunks_.size() != conductChunks_.size() ||
6986 (int)bdatChunks_.size() != measureDataCount ) {
6991 for ( i=0; i<(int)measureChunks_.size(); ++i ) {
6992 Measure* measure =
new Measure(i);
6994 measures.push_back(measure);
6995 ove_->addMeasure(measure);
6998 for ( i=0; i<measureDataCount; ++i ) {
6999 MeasureData* oveMeasureData =
new MeasureData();
7001 measureDatas.push_back(oveMeasureData);
7002 ove_->addMeasureData(oveMeasureData);
7005 for( i=0; i<(int)measureChunks_.size(); ++i ) {
7006 Measure* measure = measures[i];
7009 if( !parseMeas(measure, measureChunks_[i]) ) {
7010 QString ss =
"failed in parse MEAS " + i;
7017 for( i=0; i<(int)conductChunks_.size(); ++i ) {
7019 if( !parseCond(measures[i], measureDatas[i], conductChunks_[i]) ) {
7020 QString ss =
"failed in parse COND " + i;
7027 for( i=0; i<(int)bdatChunks_.size(); ++i ) {
7028 int measId = i % trackMeasureCount;
7031 if( !parseBdat(measures[measId], measureDatas[i], bdatChunks_[i]) ) {
7032 QString ss =
"failed in parse BDAT " + i;
7038 if( notify_ != NULL ) {
7039 int measureID = i % trackMeasureCount;
7040 int trackID = i / trackMeasureCount;
7046 notify_->loadPosition(measureID, trackMeasureCount, trackID, trackCount);
7053 bool BarsParse::parseMeas(Measure* measure, SizeChunk* chunk) {
7056 StreamHandle measureHandle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
7058 handle_ = &measureHandle;
7060 if( !jump(2) ) {
return false; }
7063 if( !readBuffer(placeHolder, 1) ) {
return false; }
7064 measure->setIsMultiMeasureRest(placeHolder.toBoolean());
7067 if( !readBuffer(placeHolder, 1) ) {
return false; }
7068 measure->setIsPickup(placeHolder.toBoolean());
7070 if( !jump(4) ) {
return false; }
7073 if( !readBuffer(placeHolder, 1) ) {
return false; }
7074 measure->setLeftBarline(placeHolder.toUnsignedInt());
7077 if( !readBuffer(placeHolder, 1) ) {
return false; }
7078 measure->setRightBarline(placeHolder.toUnsignedInt());
7081 if( !readBuffer(placeHolder, 2) ) {
return false; }
7082 double tempo = ((double)placeHolder.toUnsignedInt());
7083 if( ove_->getIsVersion4() ) {
7086 measure->setTypeTempo(tempo);
7089 if( !readBuffer(placeHolder, 2) ) {
return false; }
7090 measure->setLength(placeHolder.toUnsignedInt());
7092 if( !jump(6) ) {
return false; }
7095 if( !parseOffsetElement(measure->getBarNumber()) ) {
return false; }
7097 if( !jump(2) ) {
return false; }
7100 if( !readBuffer(placeHolder, 2) ) {
return false; }
7101 measure->setMultiMeasureRestCount(placeHolder.toUnsignedInt());
7108 bool BarsParse::parseCond(Measure* measure, MeasureData* measureData, SizeChunk* chunk) {
7111 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
7116 if( !readBuffer(placeHolder, 2) ) {
return false; }
7117 unsigned int cnt = placeHolder.toUnsignedInt();
7119 if( !parseTimeSignature(measure, 36) ) {
return false; }
7121 for(
unsigned int i=0; i<cnt; ++i ) {
7122 if( !readBuffer(placeHolder, 2) ) {
return false; }
7123 unsigned int twoByte = placeHolder.toUnsignedInt();
7124 unsigned int oldBlockSize = twoByte - 11;
7125 unsigned int newBlockSize = twoByte - 7;
7128 if( !readBuffer(placeHolder, 1) ) {
return false; }
7129 unsigned int thisByte = placeHolder.toUnsignedInt();
7132 if( !getCondElementType(thisByte, type) ) {
return false; }
7135 case Cond_Bar_Number: {
7136 if (!parseBarNumber(measure, twoByte - 1)) {
7142 if (!parseRepeatSymbol(measureData, oldBlockSize)) {
7147 case Cond_Numeric_Ending: {
7148 if (!parseNumericEndings(measureData, oldBlockSize)) {
7153 case Cond_Decorator: {
7154 if (!parseDecorators(measureData, newBlockSize)) {
7160 if (!parseTempo(measureData, newBlockSize)) {
7166 if (!parseText(measureData, newBlockSize)) {
7171 case Cond_Expression: {
7172 if (!parseExpressions(measureData, newBlockSize)) {
7177 case Cond_Time_Parameters: {
7178 if (!parseTimeSignatureParameters(measure, newBlockSize)) {
7183 case Cond_Barline_Parameters: {
7184 if (!parseBarlineParameters(measure, newBlockSize)) {
7190 if (!jump(newBlockSize)) {
7203 bool BarsParse::parseTimeSignature(Measure* measure,
int ) {
7206 TimeSignature* timeSignature = measure->getTime();
7209 if( !readBuffer(placeHolder, 1) ) {
return false; }
7210 timeSignature->setNumerator(placeHolder.toUnsignedInt());
7213 if( !readBuffer(placeHolder, 1) ) {
return false; }
7214 timeSignature->setDenominator(placeHolder.toUnsignedInt());
7216 if( !jump(2) ) {
return false; }
7219 if( !readBuffer(placeHolder, 2) ) {
return false; }
7220 timeSignature->setBeatLength(placeHolder.toUnsignedInt());
7223 if( !readBuffer(placeHolder, 2) ) {
return false; }
7224 timeSignature->setBarLength(placeHolder.toUnsignedInt());
7226 if( !jump(4) ) {
return false; }
7229 if( !readBuffer(placeHolder, 1) ) {
return false; }
7230 timeSignature->setIsSymbol(placeHolder.toBoolean());
7232 if( !jump(1) ) {
return false; }
7235 if( !readBuffer(placeHolder, 1) ) {
return false; }
7236 timeSignature->setReplaceFont(placeHolder.toBoolean());
7239 if( !readBuffer(placeHolder, 1) ) {
return false; }
7240 timeSignature->setColor(placeHolder.toUnsignedInt());
7243 if( !readBuffer(placeHolder, 1) ) {
return false; }
7244 timeSignature->setShow(placeHolder.toBoolean());
7247 if( !readBuffer(placeHolder, 1) ) {
return false; }
7248 timeSignature->setShowBeatGroup(placeHolder.toBoolean());
7250 if( !jump(6) ) {
return false; }
7253 if( !readBuffer(placeHolder, 1) ) {
return false; }
7254 timeSignature->setGroupNumerator1(placeHolder.toUnsignedInt());
7255 if( !readBuffer(placeHolder, 1) ) {
return false; }
7256 timeSignature->setGroupNumerator2(placeHolder.toUnsignedInt());
7257 if( !readBuffer(placeHolder, 1) ) {
return false; }
7258 timeSignature->setGroupNumerator3(placeHolder.toUnsignedInt());
7261 if( !readBuffer(placeHolder, 1) ) {
return false; }
7262 timeSignature->setGroupDenominator1(placeHolder.toUnsignedInt());
7263 if( !readBuffer(placeHolder, 1) ) {
return false; }
7264 timeSignature->setGroupDenominator2(placeHolder.toUnsignedInt());
7265 if( !readBuffer(placeHolder, 1) ) {
return false; }
7266 timeSignature->setGroupDenominator3(placeHolder.toUnsignedInt());
7269 if( !readBuffer(placeHolder, 1) ) {
return false; }
7270 timeSignature->setBeamGroup1(placeHolder.toUnsignedInt());
7271 if( !readBuffer(placeHolder, 1) ) {
return false; }
7272 timeSignature->setBeamGroup2(placeHolder.toUnsignedInt());
7273 if( !readBuffer(placeHolder, 1) ) {
return false; }
7274 timeSignature->setBeamGroup3(placeHolder.toUnsignedInt());
7275 if( !readBuffer(placeHolder, 1) ) {
return false; }
7276 timeSignature->setBeamGroup4(placeHolder.toUnsignedInt());
7279 if( !readBuffer(placeHolder, 1) ) {
return false; }
7280 timeSignature->set16thBeamCount(placeHolder.toUnsignedInt());
7283 if( !readBuffer(placeHolder, 1) ) {
return false; }
7284 timeSignature->set32thBeamCount(placeHolder.toUnsignedInt());
7289 bool BarsParse::parseTimeSignatureParameters(Measure* measure,
int length) {
7291 TimeSignature* ts = measure->getTime();
7293 int cursor = ove_->getIsVersion4() ? 10 : 8;
7294 if( !jump(cursor) ) {
return false; }
7297 if( !readBuffer(placeHolder, 1) ) {
return false; }
7298 unsigned int numerator = placeHolder.toUnsignedInt();
7300 cursor = ove_->getIsVersion4() ? 11 : 9;
7301 if( ( length - cursor ) % 8 != 0 || (length - cursor) / 8 != (
int)numerator ) {
7305 for(
unsigned int i =0; i<numerator; ++i ) {
7307 if( !readBuffer(placeHolder, 2) ) {
return false; }
7308 int beatStart = placeHolder.toUnsignedInt();
7311 if( !readBuffer(placeHolder, 2) ) {
return false; }
7312 int beatLength = placeHolder.toUnsignedInt();
7314 if( !jump(2) ) {
return false; }
7317 if( !readBuffer(placeHolder, 2) ) {
return false; }
7318 int beatStartTick = placeHolder.toUnsignedInt();
7320 ts->addBeat(beatStart, beatLength, beatStartTick);
7328 bool BarsParse::parseBarlineParameters(Measure* measure,
int ) {
7331 int cursor = ove_->getIsVersion4() ? 12 : 10;
7332 if( !jump(cursor) ) {
return false; }
7335 if( !readBuffer(placeHolder, 1) ) {
return false; }
7336 int repeatCount = placeHolder.toUnsignedInt();
7338 measure->setBackwardRepeatCount(repeatCount);
7340 if( !jump(6) ) {
return false; }
7345 bool BarsParse::parseNumericEndings(MeasureData* measureData,
int ) {
7348 NumericEnding* numeric =
new NumericEnding();
7349 measureData->addCrossMeasureElement(numeric,
true);
7351 if( !jump(3) ) {
return false; }
7354 if( !parseCommonBlock(numeric) ) {
return false; }
7356 if( !jump(6) ) {
return false; }
7359 if( !readBuffer(placeHolder, 2) ) {
return false; }
7361 int offsetMeasure = placeHolder.toUnsignedInt();
7362 numeric->stop()->setMeasure(offsetMeasure);
7364 if( !jump(2) ) {
return false; }
7367 if( !readBuffer(placeHolder, 2) ) {
return false; }
7368 numeric->getLeftShoulder()->setXOffset(placeHolder.toInt());
7371 if( !readBuffer(placeHolder, 2) ) {
return false; }
7372 numeric->setHeight(placeHolder.toUnsignedInt());
7375 if( !readBuffer(placeHolder, 2) ) {
return false; }
7376 numeric->getRightShoulder()->setXOffset(placeHolder.toInt());
7378 if( !jump(2) ) {
return false; }
7381 if( !readBuffer(placeHolder, 2) ) {
return false; }
7382 numeric->getLeftShoulder()->setYOffset(placeHolder.toInt());
7383 numeric->getRightShoulder()->setYOffset(placeHolder.toInt());
7386 if( !readBuffer(placeHolder, 2) ) {
return false; }
7387 numeric->getNumericHandle()->setXOffset(placeHolder.toInt());
7388 if( !readBuffer(placeHolder, 2) ) {
return false; }
7389 numeric->getNumericHandle()->setYOffset(placeHolder.toInt());
7391 if( !jump(6) ) {
return false; }
7394 if( !readBuffer(placeHolder, 1) ) {
return false; }
7395 unsigned int size = placeHolder.toUnsignedInt();
7398 if( !readBuffer(placeHolder, size) ) {
return false; }
7399 numeric->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7402 if( size % 2 == 0 ) {
7403 if( !jump(1) ) {
return false; }
7409 bool BarsParse::parseTempo(MeasureData* measureData,
int ) {
7411 unsigned int thisByte;
7413 Tempo* tempo =
new Tempo();
7414 measureData->addMusicData(tempo);
7416 if( !jump(3) ) {
return false; }
7419 if( !parseCommonBlock(tempo) ) {
return false; }
7421 if( !readBuffer(placeHolder, 1) ) {
return false; }
7422 thisByte = placeHolder.toUnsignedInt();
7425 tempo->setShowMark( (getHighNibble(thisByte) & 0x4) == 0x4 );
7427 tempo->setShowBeforeText( (getHighNibble(thisByte) & 0x8 ) == 0x8 ) ;
7429 tempo->setShowParenthesis( (getHighNibble(thisByte) & 0x1 ) == 0x1 );
7431 tempo->setLeftNoteType( getLowNibble(thisByte) );
7433 if( !jump(1) ) {
return false; }
7435 if( ove_->getIsVersion4() ) {
7436 if( !jump(2) ) {
return false; }
7439 if( !readBuffer(placeHolder, 2) ) {
return false; }
7440 tempo->setTypeTempo(placeHolder.toUnsignedInt()/100);
7443 if( !readBuffer(placeHolder, 2) ) {
return false; }
7444 tempo->setTypeTempo(placeHolder.toUnsignedInt());
7446 if( !jump(2) ) {
return false; }
7450 if( !parseOffsetElement(tempo) ) {
return false; }
7452 if( !jump(16) ) {
return false; }
7455 if( !readBuffer(placeHolder, 31) ) {
return false; }
7456 tempo->setLeftText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7458 if( !readBuffer(placeHolder, 1) ) {
return false; }
7459 thisByte = placeHolder.toUnsignedInt();
7462 tempo->setSwingEighth(getHighNibble(thisByte)!=8);
7465 tempo->setRightNoteType(getLowNibble(thisByte));
7468 if( ove_->getIsVersion4() ) {
7469 if( !readBuffer(placeHolder, 31) ) {
return false; }
7470 tempo->setRightText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7472 if( !jump(1) ) {
return false; }
7478 bool BarsParse::parseBarNumber(Measure* measure,
int ) {
7481 BarNumber* barNumber = measure->getBarNumber();
7483 if( !jump(2) ) {
return false; }
7486 if( !readBuffer(placeHolder, 1) ) {
return false; }
7487 barNumber->setShowOnParagraphStart(getLowNibble(placeHolder.toUnsignedInt())==8);
7489 unsigned int blankSize = ove_->getIsVersion4() ? 9 : 7;
7490 if( !jump(blankSize) ) {
return false; }
7493 if( !readBuffer(placeHolder, 1) ) {
return false; }
7494 barNumber->setAlign(placeHolder.toUnsignedInt());
7496 if( !jump(4) ) {
return false; }
7499 if( !readBuffer(placeHolder, 1) ) {
return false; }
7500 barNumber->setShowFlag(placeHolder.toUnsignedInt());
7502 if( !jump(10) ) {
return false; }
7505 if( !readBuffer(placeHolder, 1) ) {
return false; }
7506 barNumber->setShowEveryBarCount(placeHolder.toUnsignedInt());
7509 if( !readBuffer(placeHolder, 2) ) {
return false; }
7510 barNumber->setPrefix(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7512 if( !jump(18) ) {
return false; }
7517 bool BarsParse::parseText(MeasureData* measureData,
int length) {
7520 Text* text =
new Text();
7521 measureData->addMusicData(text);
7523 if( !jump(3) ) {
return false; }
7526 if( !parseCommonBlock(text) ) {
return false; }
7529 if( !readBuffer(placeHolder, 1) ) {
return false; }
7530 unsigned int thisByte = placeHolder.toUnsignedInt();
7531 bool includeLineBreak = ( (getHighNibble(thisByte)&0x2) != 0x2 );
7532 unsigned int id = getLowNibble(thisByte);
7533 Text::TextType textType = Text::Text_Rehearsal;
7536 textType = Text::Text_MeasureText;
7537 }
else if (
id == 1) {
7538 textType = Text::Text_SystemText;
7541 textType = Text::Text_Rehearsal;
7544 text->setTextType(textType);
7546 if( !jump(1) ) {
return false; }
7549 if( !readBuffer(placeHolder, 4) ) {
return false; }
7550 text->setXOffset(placeHolder.toInt());
7553 if( !readBuffer(placeHolder, 4) ) {
return false; }
7554 text->setYOffset(placeHolder.toInt());
7557 if( !readBuffer(placeHolder, 4) ) {
return false; }
7558 text->setWidth(placeHolder.toUnsignedInt());
7561 if( !readBuffer(placeHolder, 4) ) {
return false; }
7562 text->setHeight(placeHolder.toUnsignedInt());
7564 if( !jump(7) ) {
return false; }
7567 if( !readBuffer(placeHolder, 1) ) {
return false; }
7568 text->setHorizontalMargin(placeHolder.toUnsignedInt());
7570 if( !jump(1) ) {
return false; }
7573 if( !readBuffer(placeHolder, 1) ) {
return false; }
7574 text->setVerticalMargin(placeHolder.toUnsignedInt());
7576 if( !jump(1) ) {
return false; }
7579 if( !readBuffer(placeHolder, 1) ) {
return false; }
7580 text->setLineThick(placeHolder.toUnsignedInt());
7582 if( !jump(2) ) {
return false; }
7585 if( !readBuffer(placeHolder, 2) ) {
return false; }
7586 unsigned int size = placeHolder.toUnsignedInt();
7589 if( !readBuffer(placeHolder, size) ) {
return false; }
7590 text->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7592 if( !includeLineBreak ) {
7593 if( !jump(6) ) {
return false; }
7595 unsigned int cursor = ove_->getIsVersion4() ? 43 : 41;
7599 for(
unsigned int i=0; i<2; ++i ) {
7600 if( (
int)cursor < length ) {
7602 if( !readBuffer(placeHolder, 2) ) {
return false; }
7603 unsigned int lineCount = placeHolder.toUnsignedInt();
7605 if( i==0 &&
int(cursor + 2 + 8*lineCount) > length ) {
7609 if( i==1 &&
int(cursor + 2 + 8*lineCount) != length ) {
7613 if( !jump(8*lineCount) ) {
return false; }
7615 cursor += 2 + 8*lineCount;
7623 bool BarsParse::parseRepeatSymbol(MeasureData* measureData,
int ) {
7626 RepeatSymbol* repeat =
new RepeatSymbol();
7627 measureData->addMusicData(repeat);
7629 if( !jump(3) ) {
return false; }
7632 if( !parseCommonBlock(repeat) ) {
return false; }
7635 if( !readBuffer(placeHolder, 1) ) {
return false; }
7636 repeat->setRepeatType(placeHolder.toUnsignedInt());
7638 if( !jump(13) ) {
return false; }
7641 if( !parseOffsetElement(repeat) ) {
return false; }
7643 if( !jump(15) ) {
return false; }
7646 if( !readBuffer(placeHolder, 2) ) {
return false; }
7647 unsigned int size = placeHolder.toUnsignedInt();
7650 if( !readBuffer(placeHolder, size) ) {
return false; }
7651 repeat->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7654 if( size % 2 == 0 ) {
7655 if( !jump(1) ) {
return false; }
7661 bool BarsParse::parseBdat(Measure* , MeasureData* measureData, SizeChunk* chunk) {
7663 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
7668 if( !readBuffer(placeHolder, 2) ) {
return false; }
7669 unsigned int cnt = placeHolder.toUnsignedInt();
7671 for(
unsigned int i=0; i<cnt; ++i ) {
7673 if( !readBuffer(placeHolder, 2) ) {
return false; }
7674 unsigned int count = placeHolder.toUnsignedInt() - 7;
7677 if( !readBuffer(placeHolder, 1) ) {
return false; }
7678 unsigned int thisByte = placeHolder.toUnsignedInt();
7681 if( !getBdatElementType(thisByte, type) ) {
return false; }
7684 case Bdat_Raw_Note :
7687 if( !parseNoteRest(measureData, count, type) ) {
return false; }
7691 if( !parseBeam(measureData, count) ) {
return false; }
7694 case Bdat_Harmony : {
7695 if( !parseHarmony(measureData, count) ) {
return false; }
7699 if( !parseClef(measureData, count) ) {
return false; }
7702 case Bdat_Dynamics : {
7703 if( !parseDynamics(measureData, count) ) {
return false; }
7707 if( !parseWedge(measureData, count) ) {
return false; }
7710 case Bdat_Glissando : {
7711 if( !parseGlissando(measureData, count) ) {
return false; }
7714 case Bdat_Decorator : {
7715 if( !parseDecorators(measureData, count) ) {
return false; }
7719 if( !parseKey(measureData, count) ) {
return false; }
7723 if( !parseLyric(measureData, count) ) {
return false; }
7726 case Bdat_Octave_Shift: {
7727 if( !parseOctaveShift(measureData, count) ) {
return false; }
7731 if( !parseSlur(measureData, count) ) {
return false; }
7735 if( !parseText(measureData, count) ) {
return false; }
7739 if( !parseTie(measureData, count) ) {
return false; }
7742 case Bdat_Tuplet : {
7743 if( !parseTuplet(measureData, count) ) {
return false; }
7746 case Bdat_Guitar_Bend :
7747 case Bdat_Guitar_Barre : {
7748 if( !parseSizeBlock(count) ) {
return false; }
7752 if( !parsePedal(measureData, count) ) {
return false; }
7756 if( !parseKuohao(measureData, count) ) {
return false; }
7759 case Bdat_Expressions: {
7760 if( !parseExpressions(measureData, count) ) {
return false; }
7763 case Bdat_Harp_Pedal: {
7764 if( !parseHarpPedal(measureData, count) ) {
return false; }
7767 case Bdat_Multi_Measure_Rest: {
7768 if( !parseMultiMeasureRest(measureData, count) ) {
return false; }
7771 case Bdat_Harmony_GuitarFrame: {
7772 if( !parseHarmonyGuitarFrame(measureData, count) ) {
return false; }
7775 case Bdat_Graphics_40:
7776 case Bdat_Graphics_RoundRect:
7777 case Bdat_Graphics_Rect:
7778 case Bdat_Graphics_Round:
7779 case Bdat_Graphics_Line:
7780 case Bdat_Graphics_Curve:
7781 case Bdat_Graphics_WedgeSymbol: {
7782 if( !parseSizeBlock(count) ) {
return false; }
7785 case Bdat_Midi_Controller : {
7786 if( !parseMidiController(measureData, count) ) {
return false; }
7789 case Bdat_Midi_Program_Change : {
7790 if( !parseMidiProgramChange(measureData, count) ) {
return false; }
7793 case Bdat_Midi_Channel_Pressure : {
7794 if( !parseMidiChannelPressure(measureData, count) ) {
return false; }
7797 case Bdat_Midi_Pitch_Wheel : {
7798 if( !parseMidiPitchWheel(measureData, count) ) {
return false; }
7802 if( !jump(count) ) {
return false; }
7815 int getInt(
int byte,
int bits) {
7819 int factor = int(pow(2.0, bits-1));
7820 num = (byte % (factor*2));
7822 if ( (byte & factor) == factor ) {
7830 bool BarsParse::parseNoteRest(MeasureData* measureData,
int length, BdatType type) {
7831 NoteContainer* container =
new NoteContainer();
7833 unsigned int thisByte;
7835 measureData->addNoteContainer(container);
7836 measureData->addMusicData(container);
7839 container->setIsRest(type==Bdat_Rest);
7840 container->setIsRaw(type==Bdat_Raw_Note);
7842 if( !readBuffer(placeHolder, 2) ) {
return false; }
7843 thisByte = placeHolder.toUnsignedInt();
7844 container->setIsGrace( thisByte == 0x3C00 );
7845 container->setIsCue( thisByte == 0x4B40 || thisByte == 0x3240 );
7848 if( !readBuffer(placeHolder, 1) ) {
return false; }
7849 thisByte = placeHolder.toUnsignedInt();
7850 container->setShow(getLowNibble(thisByte)!=0x8);
7853 container->setVoice(getLowNibble(thisByte)&0x7);
7856 if( !parseCommonBlock(container) ) {
return false; }
7859 if( !readBuffer(placeHolder, 1) ) {
return false; }
7860 container->setTuplet(placeHolder.toUnsignedInt());
7863 if( !readBuffer(placeHolder, 1) ) {
return false; }
7864 container->setSpace(placeHolder.toUnsignedInt());
7867 if( !readBuffer(placeHolder, 1) ) {
return false; }
7868 thisByte = placeHolder.toUnsignedInt();
7869 bool inBeam = ( getHighNibble(thisByte) & 0x1 ) == 0x1;
7870 container->setInBeam(inBeam);
7873 container->setGraceNoteType((NoteType)getHighNibble(thisByte));
7876 container->setDot(getLowNibble(thisByte)&0x03);
7879 if( !readBuffer(placeHolder, 1) ) {
return false; }
7880 thisByte = placeHolder.toUnsignedInt();
7881 container->setNoteType((NoteType)getLowNibble(thisByte));
7885 if( type == Bdat_Rest ) {
7886 Note* restPtr =
new Note();
7887 container->addNoteRest(restPtr);
7888 restPtr->setIsRest(
true);
7891 if( !readBuffer(placeHolder, 1) ) {
return false; }
7892 restPtr->setLine(placeHolder.toInt());
7894 if( !jump(1) ) {
return false; }
7896 cursor = ove_->getIsVersion4() ? 16 : 14;
7900 if( !readBuffer(placeHolder, 1) ) {
return false; }
7901 thisByte = placeHolder.toUnsignedInt();
7902 container->setStemUp((getHighNibble(thisByte)&0x8)==0x8);
7905 int stemOffset = thisByte%0x80;
7906 container->setStemLength(getInt(stemOffset, 7)+7);
7909 if( !readBuffer(placeHolder, 1) ) {
return false; }
7910 bool hideStem = getHighNibble(thisByte)==0x4;
7911 container->setShowStem(!hideStem);
7913 if( !jump(1) ) {
return false; }
7916 if( !readBuffer(placeHolder, 1) ) {
return false; }
7917 unsigned int noteCount = placeHolder.toUnsignedInt();
7921 for( i=0; i<noteCount; ++i ) {
7922 Note* notePtr =
new Note();
7923 notePtr->setIsRest(
false);
7925 container->addNoteRest(notePtr);
7928 if( !readBuffer(placeHolder, 1) ) {
return false; }
7929 thisByte = placeHolder.toUnsignedInt();
7930 notePtr->setShow((thisByte&0x80) != 0x80);
7933 notePtr->setHeadType(thisByte&0x7f);
7936 if( !readBuffer(placeHolder, 1) ) {
return false; }
7937 thisByte = placeHolder.toUnsignedInt();
7938 notePtr->setTiePos(getHighNibble(thisByte));
7941 if( !readBuffer(placeHolder, 1) ) {
return false; }
7942 thisByte = getLowNibble(placeHolder.toUnsignedInt());
7943 int offsetStaff = 0;
7944 if( thisByte == 1 ) { offsetStaff = 1; }
7945 if( thisByte == 7 ) { offsetStaff = -1; }
7946 notePtr->setOffsetStaff(offsetStaff);
7949 if( !readBuffer(placeHolder, 1) ) {
return false; }
7950 thisByte = placeHolder.toUnsignedInt();
7951 notePtr->setAccidental(getLowNibble(thisByte));
7953 bool notShow = ( getHighNibble(thisByte) == 0 ) || ( getHighNibble(thisByte) == 4 );
7954 notePtr->setShowAccidental(!notShow);
7956 if( !jump(1) ) {
return false; }
7959 if( !readBuffer(placeHolder, 1) ) {
return false; }
7960 notePtr->setLine(placeHolder.toInt());
7962 if( !jump(1) ) {
return false; }
7965 if( !readBuffer(placeHolder, 1) ) {
return false; }
7966 unsigned int note = placeHolder.toUnsignedInt();
7967 notePtr->setNote(note);
7970 if( !readBuffer(placeHolder, 1) ) {
return false; }
7971 unsigned int onVelocity = placeHolder.toUnsignedInt();
7972 notePtr->setOnVelocity(onVelocity);
7975 if( !readBuffer(placeHolder, 1) ) {
return false; }
7976 unsigned int offVelocity = placeHolder.toUnsignedInt();
7977 notePtr->setOffVelocity(offVelocity);
7979 if( !jump(2) ) {
return false; }
7982 if( !readBuffer(placeHolder, 2) ) {
return false; }
7983 container->setLength(placeHolder.toUnsignedInt());
7986 if( !readBuffer(placeHolder, 2) ) {
return false; }
7987 notePtr->setOffsetTick(placeHolder.toInt());
7990 cursor = ove_->getIsVersion4() ? 18 : 16;
7991 cursor += noteCount * 16;
7995 while ( cursor < length + 1 ) {
7996 Articulation* art =
new Articulation();
7997 container->addArticulation(art);
8000 if( !readBuffer(placeHolder, 2) ) {
return false; }
8001 int blockSize = placeHolder.toUnsignedInt();
8004 if( !readBuffer(placeHolder, 1) ) {
return false; }
8005 art->setArtType(placeHolder.toUnsignedInt());
8008 if( !readBuffer(placeHolder, 1) ) {
return false; }
8009 art->setPlacementAbove(placeHolder.toUnsignedInt()!=0x00);
8012 if( !parseOffsetElement(art) ) {
return false; }
8014 if( !ove_->getIsVersion4() ) {
8015 if( blockSize - 8 > 0 ) {
8016 if( !jump(blockSize-8) ) {
return false; }
8020 if( !readBuffer(placeHolder, 1) ) {
return false; }
8021 thisByte = placeHolder.toUnsignedInt();
8022 const bool changeSoundEffect = ( ( thisByte & 0x1 ) == 0x1 );
8023 const bool changeLength = ( ( thisByte & 0x2 ) == 0x2 );
8024 const bool changeVelocity = ( ( thisByte & 0x4 ) == 0x4 );
8027 if( !jump(8) ) {
return false; }
8030 if( !readBuffer(placeHolder, 1) ) {
return false; }
8031 thisByte = placeHolder.toUnsignedInt();
8032 if( changeVelocity ) {
8033 art->setVelocityType((Articulation::VelocityType)thisByte);
8036 if( !jump(14) ) {
return false; }
8039 if( !readBuffer(placeHolder, 2) ) {
return false; }
8040 int from = placeHolder.toInt();
8041 if( !readBuffer(placeHolder, 2) ) {
return false; }
8042 int to = placeHolder.toInt();
8043 if( changeSoundEffect ) {
8044 art->setSoundEffect(from, to);
8047 if( !jump(1) ) {
return false; }
8050 if( !readBuffer(placeHolder, 1) ) {
return false; }
8051 if( changeLength ) {
8052 art->setLengthPercentage(placeHolder.toUnsignedInt());
8056 if( !readBuffer(placeHolder, 2) ) {
return false; }
8057 if( changeVelocity ) {
8058 art->setVelocityValue(placeHolder.toInt());
8061 if( Articulation::isTrill(art->getArtType()) ) {
8062 if( !jump(8) ) {
return false; }
8065 if( !readBuffer(placeHolder, 1) ) {
return false; }
8066 art->setTrillNoteLength(placeHolder.toUnsignedInt());
8069 if( !readBuffer(placeHolder, 1) ) {
return false; }
8070 thisByte = placeHolder.toUnsignedInt();
8071 NoteType trillNoteType = Note_Sixteen;
8072 switch ( getHighNibble(thisByte) ) {
8074 trillNoteType = Note_None;
8077 trillNoteType = Note_Sixteen;
8080 trillNoteType = Note_32;
8083 trillNoteType = Note_64;
8086 trillNoteType = Note_128;
8091 art->setTrillRate(trillNoteType);
8094 art->setAccelerateType(thisByte&0xf);
8096 if( !jump(1) ) {
return false; }
8099 if( !readBuffer(placeHolder, 1) ) {
return false; }
8100 art->setAuxiliaryFirst(placeHolder.toBoolean());
8102 if( !jump(1) ) {
return false; }
8105 if( !readBuffer(placeHolder, 1) ) {
return false; }
8106 art->setTrillInterval(placeHolder.toUnsignedInt());
8108 if( blockSize > 40 ) {
8109 if( !jump( blockSize - 40 ) ) {
return false; }
8114 cursor += blockSize;
8120 int tupletToSpace(
int tuplet) {
8123 while( a*2 < tuplet ) {
8130 bool BarsParse::parseBeam(MeasureData* measureData,
int length)
8135 Beam* beam =
new Beam();
8136 measureData->addCrossMeasureElement(beam,
true);
8139 bool createTuplet =
false;
8141 Tuplet* tuplet =
new Tuplet();
8144 if( !readBuffer(placeHolder, 1) ) {
return false; }
8145 beam->setIsGrace(placeHolder.toBoolean());
8147 if( !jump(1) ) {
return false; }
8150 if( !readBuffer(placeHolder, 1) ) {
return false; }
8151 beam->setVoice(getLowNibble(placeHolder.toUnsignedInt())&0x7);
8154 if( !parseCommonBlock(beam) ) {
return false; }
8156 if( !jump(2) ) {
return false; }
8159 if( !readBuffer(placeHolder, 1) ) {
return false; }
8160 int beamCount = placeHolder.toUnsignedInt();
8162 if( !jump(1) ) {
return false; }
8165 if( !readBuffer(placeHolder, 1) ) {
return false; }
8166 beam->getLeftLine()->setLine(placeHolder.toInt());
8169 if( !readBuffer(placeHolder, 1) ) {
return false; }
8170 beam->getRightLine()->setLine(placeHolder.toInt());
8172 if( ove_->getIsVersion4() ) {
8173 if( !jump(8) ) {
return false; }
8176 int currentCursor = ove_->getIsVersion4() ? 23 : 13;
8177 int count = (length - currentCursor)/16;
8179 if( count != beamCount ) {
return false; }
8181 for( i=0; i<count; ++i ) {
8182 if( !jump(1) ) {
return false; }
8185 if( !readBuffer(placeHolder, 1) ) {
return false; }
8186 int tupletCount = placeHolder.toUnsignedInt();
8187 if( tupletCount > 0 ) {
8188 createTuplet =
true;
8189 tuplet->setTuplet(tupletCount);
8190 tuplet->setSpace(tupletToSpace(tupletCount));
8198 if( !readBuffer(placeHolder, 1) ) {
return false; }
8199 startMp.setMeasure(placeHolder.toUnsignedInt());
8200 if( !readBuffer(placeHolder, 1) ) {
return false; }
8201 stopMp.setMeasure(placeHolder.toUnsignedInt());
8203 if( !readBuffer(placeHolder, 2) ) {
return false; }
8204 startMp.setOffset(placeHolder.toInt());
8205 if( !readBuffer(placeHolder, 2) ) {
return false; }
8206 stopMp.setOffset(placeHolder.toInt());
8208 beam->addLine(startMp, stopMp);
8210 if( stopMp.getOffset() > maxEndUnit ) {
8211 maxEndUnit = stopMp.getOffset();
8215 if( !jump(4) ) {
return false; }
8218 if( !readBuffer(placeHolder, 2) ) {
return false; }
8219 beam->getLeftShoulder()->setYOffset(placeHolder.toInt());
8222 if( !readBuffer(placeHolder, 2) ) {
return false; }
8223 beam->getRightShoulder()->setYOffset(placeHolder.toInt());
8225 if( !jump(8) ) {
return false; }
8229 const QList<QPair<MeasurePos, MeasurePos> > lines = beam->getLines();
8230 MeasurePos offsetMp;
8232 for( i=0; i<lines.size(); ++i ) {
8233 if( lines[i].second > offsetMp ) {
8234 offsetMp = lines[i].second;
8238 beam->stop()->setMeasure(offsetMp.getMeasure());
8239 beam->stop()->setOffset(offsetMp.getOffset());
8242 if( createTuplet ) {
8243 tuplet->copyCommonBlock(*beam);
8244 tuplet->getLeftLine()->setLine(beam->getLeftLine()->getLine());
8245 tuplet->getRightLine()->setLine(beam->getRightLine()->getLine());
8246 tuplet->stop()->setMeasure(beam->stop()->getMeasure());
8247 tuplet->stop()->setOffset(maxEndUnit);
8249 measureData->addCrossMeasureElement(tuplet,
true);
8257 bool BarsParse::parseTie(MeasureData* measureData,
int ) {
8260 Tie* tie =
new Tie();
8261 measureData->addCrossMeasureElement(tie,
true);
8263 if( !jump(3) ) {
return false; }
8266 if( !parseCommonBlock(tie) ) {
return false; }
8268 if( !jump(1) ) {
return false; }
8271 if( !readBuffer(placeHolder, 1) ) {
return false; }
8272 tie->setNote(placeHolder.toUnsignedInt());
8275 if( !parsePairLinesBlock(tie) ) {
return false; }
8278 if( !parseOffsetCommonBlock(tie) ) {
return false; }
8281 if( !parseOffsetElement(tie->getLeftShoulder()) ) {
return false; }
8284 if( !parseOffsetElement(tie->getRightShoulder()) ) {
return false; }
8287 if( !readBuffer(placeHolder, 2) ) {
return false; }
8288 tie->setHeight(placeHolder.toUnsignedInt());
8293 bool BarsParse::parseTuplet(MeasureData* measureData,
int ) {
8296 Tuplet* tuplet =
new Tuplet();
8297 measureData->addCrossMeasureElement(tuplet,
true);
8299 if( !jump(3) ) {
return false; }
8302 if( !parseCommonBlock(tuplet) ) {
return false; }
8304 if( !jump(2) ) {
return false; }
8307 if( !parsePairLinesBlock(tuplet) ) {
return false; }
8310 if( !parseOffsetCommonBlock(tuplet) ) {
return false; }
8313 if( !parseOffsetElement(tuplet->getLeftShoulder()) ) {
return false; }
8316 if( !parseOffsetElement(tuplet->getRightShoulder()) ) {
return false; }
8318 if( !jump(2) ) {
return false; }
8321 if( !readBuffer(placeHolder, 2) ) {
return false; }
8322 tuplet->setHeight(placeHolder.toUnsignedInt());
8325 if( !readBuffer(placeHolder, 1) ) {
return false; }
8326 tuplet->setTuplet(placeHolder.toUnsignedInt());
8329 if( !readBuffer(placeHolder, 1) ) {
return false; }
8330 tuplet->setSpace(placeHolder.toUnsignedInt());
8333 if( !parseOffsetElement(tuplet->getMarkHandle()) ) {
return false; }
8338 HarmonyType binaryToHarmonyType(
int bin) {
8339 HarmonyType type = Harmony_maj;
8340 if( bin == 0x0091 ) {
8342 }
else if( bin == 0x0089 ) {
8344 }
else if( bin == 0x0489 ) {
8345 type = Harmony_min7;
8346 }
else if( bin == 0x0491 ) {
8348 }
else if( bin == 0x0495 ) {
8350 }
else if( bin == 0x0449 ) {
8351 type = Harmony_min7b5;
8352 }
else if( bin == 0x04A1 ) {
8353 type = Harmony_7sus4;
8354 }
else if( bin == 0x00A1 ) {
8355 type = Harmony_sus4;
8356 }
else if( bin == 0x0049 ) {
8358 }
else if( bin == 0x0249 ) {
8359 type = Harmony_dim7;
8360 }
else if( bin == 0x0111 ) {
8362 }
else if( bin == 0x0511 ) {
8363 type = Harmony_aug7;
8364 }
else if( bin == 0x044D ) {
8365 type = Harmony_min9_b5;
8366 }
else if( bin == 0x0499 ) {
8368 }
else if( bin == 0x0615 ) {
8370 }
else if( bin == 0x0289 ) {
8371 type = Harmony_min6;
8372 }
else if( bin == 0x0291 ) {
8374 }
else if( bin == 0x0295 ) {
8376 }
else if( bin == 0x0095 ) {
8378 }
else if( bin == 0x008D ) {
8379 type = Harmony_maj7;
8380 }
else if( bin == 0x0891 ) {
8381 type = Harmony_maj7;
8382 }
else if( bin == 0x0881 ) {
8383 type = Harmony_maj7_s5;
8384 }
else if( bin == 0x0911 ) {
8385 type = Harmony_maj7_s5;
8386 }
else if( bin == 0x0991 ) {
8387 type = Harmony_maj7_s11;
8388 }
else if( bin == 0x0851 ) {
8389 type = Harmony_maj7_s11;
8390 }
else if( bin == 0x08D1 ) {
8391 type = Harmony_maj9;
8392 }
else if( bin == 0x0895 ) {
8393 type = Harmony_maj9_s5;
8394 }
else if( bin == 0x0995 ) {
8395 type = Harmony_maj13_s11;
8396 }
else if( bin == 0x0855 ) {
8397 type = Harmony_maj9_s11;
8398 }
else if( bin == 0x08D5 ) {
8399 type = Harmony_maj13;
8400 }
else if( bin == 0x0A95 ) {
8401 type = Harmony_maj13_s11;
8402 }
else if( bin == 0x0A55 ) {
8403 type = Harmony_maj13;
8404 }
else if( bin == 0x0A85 ) {
8405 type = Harmony_maj9_s5;
8406 }
else if( bin == 0x0B45 ) {
8408 }
else if( bin == 0x0493 ) {
8410 }
else if( bin == 0x0451 ) {
8412 }
else if( bin == 0x0455 ) {
8414 }
else if( bin == 0x0519 ) {
8416 }
else if( bin == 0x0513 ) {
8417 type = Harmony_aug7;
8418 }
else if( bin == 0x0515 ) {
8419 type = Harmony_sus4;
8420 }
else if( bin == 0x04A5 ) {
8421 type = Harmony_13b9;
8422 }
else if( bin == 0x0613 ) {
8423 type = Harmony_13b9;
8424 }
else if( bin == 0x0611 ) {
8426 }
else if( bin == 0x0653 ) {
8428 }
else if( bin == 0x0889 ) {
8429 type = Harmony_min9;
8430 }
else if( bin == 0x088D ) {
8431 type = Harmony_min11;
8432 }
else if( bin == 0x04AD ) {
8433 type = Harmony_9s11;
8434 }
else if( bin == 0x04D5 ) {
8435 type = Harmony_7sus4;
8436 }
else if( bin == 0x0421 ) {
8437 type = Harmony_min11;
8438 }
else if( bin == 0x04A9 ) {
8439 type = Harmony_min9;
8440 }
else if( bin == 0x048D ) {
8441 type = Harmony_7b5b9;
8442 }
else if( bin == 0x0453 ) {
8444 }
else if( bin == 0x0011 ) {
8445 type = Harmony_maj7;
8446 }
else if( bin == 0x0081 ) {
8448 }
else if( bin == 0x0481 ) {
8450 }
else if( bin == 0x0411 ) {
8452 }
else if( bin == 0x0291 ) {
8453 type = Harmony_sus4;
8454 }
else if( bin == 0x00A5 ) {
8455 type = Harmony_13s9;
8456 }
else if( bin == 0x0659 ) {
8457 type = Harmony_sus4;
8458 }
else if( bin == 0x0021 ) {
8459 type = Harmony_7b5b9;
8460 }
else if( bin == 0x045B ) {
8461 type = Harmony_13b5;
8462 }
else if( bin == 0x065B ) {
8463 type = Harmony_13b9;
8464 }
else if( bin == 0x061B ) {
8465 type = Harmony_7b9s9;
8466 }
else if( bin == 0x04B5 ) {
8473 bool BarsParse::parseHarmony(MeasureData* measureData,
int ) {
8476 Harmony* harmony =
new Harmony();
8477 measureData->addMusicData(harmony);
8479 if( !jump(3) ) {
return false; }
8482 if( !parseCommonBlock(harmony) ) {
return false; }
8485 if( !readBuffer(placeHolder, 1) ) {
return false; }
8486 harmony->setBassOnBottom((getHighNibble(placeHolder.toUnsignedInt())==0x4));
8488 if( !jump(1) ) {
return false; }
8491 if( !readBuffer(placeHolder, 2) ) {
return false; }
8492 harmony->setYOffset(placeHolder.toInt());
8495 if( !readBuffer(placeHolder, 2) ) {
return false; }
8496 harmony->setHarmonyType(binaryToHarmonyType(placeHolder.toUnsignedInt()));
8499 if( !readBuffer(placeHolder, 1) ) {
return false; }
8500 harmony->setRoot(placeHolder.toInt());
8503 if( !readBuffer(placeHolder, 1) ) {
return false; }
8504 harmony->setBass(placeHolder.toInt());
8507 if( !readBuffer(placeHolder, 2) ) {
return false; }
8508 harmony->setAngle(placeHolder.toInt());
8510 if( ove_->getIsVersion4() ) {
8512 if( !readBuffer(placeHolder, 2) ) {
return false; }
8513 harmony->setLength(placeHolder.toUnsignedInt());
8515 if( !jump(4) ) {
return false; }
8521 bool BarsParse::parseClef(MeasureData* measureData,
int ) {
8524 Clef* clef =
new Clef();
8525 measureData->addMusicData(clef);
8527 if( !jump(3) ) {
return false; }
8530 if( !parseCommonBlock(clef) ) {
return false; }
8533 if( !readBuffer(placeHolder, 1) ) {
return false; }
8534 clef->setClefType(placeHolder.toUnsignedInt());
8537 if( !readBuffer(placeHolder, 1) ) {
return false; }
8538 clef->setLine(placeHolder.toInt());
8540 if( !jump(2) ) {
return false; }
8545 bool BarsParse::parseLyric(MeasureData* measureData,
int length) {
8548 Lyric*
lyric =
new Lyric();
8549 measureData->addMusicData(lyric);
8551 if( !jump(3) ) {
return false; }
8554 if( !parseCommonBlock(lyric) ) {
return false; }
8556 if( !jump(2) ) {
return false; }
8559 if( !parseOffsetElement(lyric) ) {
return false; }
8561 if( !jump(7) ) {
return false; }
8564 if( !readBuffer(placeHolder, 1) ) {
return false; }
8565 lyric->setVerse(placeHolder.toUnsignedInt());
8567 if( ove_->getIsVersion4() ) {
8568 if( !jump(6) ) {
return false; }
8572 if( !readBuffer(placeHolder, length-29) ) {
return false; }
8573 lyric->setLyric(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
8580 bool BarsParse::parseSlur(MeasureData* measureData,
int ) {
8583 Slur* slur =
new Slur();
8584 measureData->addCrossMeasureElement(slur,
true);
8586 if( !jump(2) ) {
return false; }
8589 if( !readBuffer(placeHolder, 1) ) {
return false; }
8590 slur->setVoice(getLowNibble(placeHolder.toUnsignedInt())&0x7);
8593 if( !parseCommonBlock(slur) ) {
return false; }
8596 if( !readBuffer(placeHolder, 1) ) {
return false; }
8597 slur->setShowOnTop(getHighNibble(placeHolder.toUnsignedInt())==0x8);
8599 if( !jump(1) ) {
return false; }
8602 if( !parsePairLinesBlock(slur) ) {
return false; }
8605 if( !parseOffsetCommonBlock(slur) ) {
return false; }
8608 if( !parseOffsetElement(slur->getLeftShoulder()) ) {
return false; }
8611 if( !parseOffsetElement(slur->getRightShoulder()) ) {
return false; }
8614 if( !parseOffsetElement(slur->getHandle2()) ) {
return false; }
8617 if( !parseOffsetElement(slur->getHandle3()) ) {
return false; }
8619 if( ove_->getIsVersion4() ) {
8620 if( !jump(3) ) {
return false; }
8623 if( !readBuffer(placeHolder, 1) ) {
return false; }
8624 slur->setNoteTimePercent(placeHolder.toUnsignedInt());
8626 if( !jump(36) ) {
return false; }
8632 bool BarsParse::parseGlissando(MeasureData* measureData,
int ) {
8635 Glissando* glissando =
new Glissando();
8636 measureData->addCrossMeasureElement(glissando,
true);
8638 if( !jump(3) ) {
return false; }
8641 if( !parseCommonBlock(glissando) ) {
return false; }
8644 if( !readBuffer(placeHolder, 1) ) {
return false; }
8645 unsigned int thisByte = placeHolder.toUnsignedInt();
8646 glissando->setStraightWavy(getHighNibble(thisByte)==4);
8648 if( !jump(1) ) {
return false; }
8651 if( !parsePairLinesBlock(glissando) ) {
return false; }
8654 if( !parseOffsetCommonBlock(glissando) ) {
return false; }
8657 if( !parseOffsetElement(glissando->getLeftShoulder()) ) {
return false; }
8660 if( !parseOffsetElement(glissando->getRightShoulder()) ) {
return false; }
8662 if( ove_->getIsVersion4() ) {
8663 if( !jump(1) ) {
return false; }
8666 if( !readBuffer(placeHolder, 1) ) {
return false; }
8667 glissando->setLineThick(placeHolder.toUnsignedInt());
8669 if( !jump(12) ) {
return false; }
8672 if( !readBuffer(placeHolder, 32) ) {
return false; }
8673 glissando->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
8675 if( !jump(6) ) {
return false; }
8681 bool getDecoratorType(
8682 unsigned int thisByte,
8683 bool& measureRepeat,
8684 Decorator::DecoratorType& decoratorType,
8686 ArticulationType& artType) {
8687 measureRepeat =
false;
8688 decoratorType = Decorator::Decorator_Articulation;
8689 singleRepeat =
true;
8690 artType = Articulation_None;
8694 decoratorType = Decorator::Decorator_Dotted_Barline;
8698 artType = Articulation_Open_String;
8702 artType = Articulation_Finger_1;
8706 artType = Articulation_Finger_2;
8710 artType = Articulation_Finger_3;
8714 artType = Articulation_Finger_4;
8718 artType = Articulation_Finger_5;
8722 artType = Articulation_Flat_Accidental_For_Trill;
8726 artType = Articulation_Sharp_Accidental_For_Trill;
8730 artType = Articulation_Natural_Accidental_For_Trill;
8734 measureRepeat =
true;
8735 singleRepeat =
true;
8739 measureRepeat =
true;
8740 singleRepeat =
false;
8744 artType = Articulation_Minor_Trill;
8748 artType = Articulation_Major_Trill;
8752 artType = Articulation_Trill_Section;
8756 artType = Articulation_Turn;
8760 artType = Articulation_Tremolo_Eighth;
8764 artType = Articulation_Tremolo_Sixteenth;
8768 artType = Articulation_Tremolo_Thirty_Second;
8772 artType = Articulation_Tremolo_Sixty_Fourth;
8776 artType = Articulation_Fermata;
8780 artType = Articulation_Fermata_Inverted;
8784 artType = Articulation_Pause;
8788 artType = Articulation_Grand_Pause;
8792 artType = Articulation_Marcato;
8796 artType = Articulation_Marcato_Dot;
8800 artType = Articulation_SForzando;
8804 artType = Articulation_SForzando_Dot;
8808 artType = Articulation_SForzando_Inverted;
8812 artType = Articulation_SForzando_Dot_Inverted;
8816 artType = Articulation_Staccatissimo;
8820 artType = Articulation_Staccato;
8824 artType = Articulation_Tenuto;
8828 artType = Articulation_Natural_Harmonic;
8832 artType = Articulation_Artificial_Harmonic;
8836 artType = Articulation_Plus_Sign;
8840 artType = Articulation_Up_Bow;
8844 artType = Articulation_Down_Bow;
8848 artType = Articulation_Up_Bow_Inverted;
8852 artType = Articulation_Down_Bow_Inverted;
8856 artType = Articulation_Pedal_Down;
8860 artType = Articulation_Pedal_Up;
8864 artType = Articulation_Heavy_Attack;
8868 artType = Articulation_Heavier_Attack;
8879 bool BarsParse::parseDecorators(MeasureData* measureData,
int length) {
8881 MusicData* musicData =
new MusicData();
8883 if( !jump(3) ) {
return false; }
8886 if( !parseCommonBlock(musicData) ) {
return false; }
8888 if( !jump(2) ) {
return false; }
8891 if( !readBuffer(placeHolder, 2) ) {
return false; }
8892 musicData->setYOffset(placeHolder.toInt());
8894 if( !jump(2) ) {
return false; }
8897 if( !readBuffer(placeHolder, 1) ) {
return false; }
8898 unsigned int thisByte = placeHolder.toUnsignedInt();
8900 Decorator::DecoratorType decoratorType;
8901 bool isMeasureRepeat;
8902 bool isSingleRepeat =
true;
8903 ArticulationType artType = Articulation_None;
8905 getDecoratorType(thisByte, isMeasureRepeat, decoratorType, isSingleRepeat, artType);
8907 if( isMeasureRepeat ) {
8908 MeasureRepeat* measureRepeat =
new MeasureRepeat();
8909 measureData->addCrossMeasureElement(measureRepeat,
true);
8911 measureRepeat->copyCommonBlock(*musicData);
8912 measureRepeat->setYOffset(musicData->getYOffset());
8914 measureRepeat->setSingleRepeat(isSingleRepeat);
8916 Decorator* decorator =
new Decorator();
8917 measureData->addMusicData(decorator);
8919 decorator->copyCommonBlock(*musicData);
8920 decorator->setYOffset(musicData->getYOffset());
8922 decorator->setDecoratorType(decoratorType);
8923 decorator->setArticulationType(artType);
8926 int cursor = ove_->getIsVersion4() ? 16 : 14;
8927 if( !jump(length-cursor) ) {
return false; }
8932 bool BarsParse::parseWedge(MeasureData* measureData,
int length) {
8934 Wedge* wedge =
new Wedge();
8936 if( !jump(3) ) {
return false; }
8939 if( !parseCommonBlock(wedge) ) {
return false; }
8942 if( !readBuffer(placeHolder, 1) ) {
return false; }
8943 WedgeType wedgeType = Wedge_Cres_Line;
8944 bool wedgeOrExpression =
true;
8945 unsigned int highHalfByte = getHighNibble(placeHolder.toUnsignedInt());
8946 unsigned int lowHalfByte = getLowNibble(placeHolder.toUnsignedInt());
8948 switch (highHalfByte) {
8950 wedgeType = Wedge_Cres_Line;
8951 wedgeOrExpression =
true;
8955 wedgeType = Wedge_Decresc_Line;
8956 wedgeOrExpression =
true;
8960 wedgeType = Wedge_Decresc;
8961 wedgeOrExpression =
false;
8965 wedgeType = Wedge_Cres;
8966 wedgeOrExpression =
false;
8974 if( (lowHalfByte & 0x8) == 0x8 ) {
8975 wedgeType = Wedge_Double_Line;
8976 wedgeOrExpression =
true;
8979 if( !jump(1) ) {
return false; }
8982 if( !readBuffer(placeHolder, 2) ) {
return false; }
8983 wedge->setYOffset(placeHolder.toInt());
8986 if( wedgeOrExpression ) {
8987 measureData->addCrossMeasureElement(wedge,
true);
8988 wedge->setWedgeType(wedgeType);
8990 if( !jump(2) ) {
return false; }
8993 if( !readBuffer(placeHolder, 2) ) {
return false; }
8994 wedge->setHeight(placeHolder.toUnsignedInt());
8997 if( !parseOffsetCommonBlock(wedge) ) {
return false; }
8999 int cursor = ove_->getIsVersion4() ? 21 : 19;
9000 if( !jump(length-cursor) ) {
return false; }
9004 Expressions* express =
new Expressions();
9005 measureData->addMusicData(express);
9007 express->copyCommonBlock(*wedge);
9008 express->setYOffset(wedge->getYOffset());
9010 if( !jump(4) ) {
return false; }
9013 if( !parseOffsetCommonBlock(express) ) {
return false; }
9015 if( ove_->getIsVersion4() ) {
9016 if( !jump(18) ) {
return false; }
9020 if( !readBuffer(placeHolder, length-39) ) {
return false; }
9021 express->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
9024 QString str = wedgeType==Wedge_Cres ?
"cresc" :
"decresc";
9025 express->setText(str);
9027 if( !jump(8) ) {
return false; }
9034 bool BarsParse::parseDynamics(MeasureData* measureData,
int ) {
9037 Dynamics* dynamics =
new Dynamics();
9038 measureData->addMusicData(dynamics);
9040 if( !jump(1) ) {
return false; }
9043 if( !readBuffer(placeHolder, 1) ) {
return false; }
9044 dynamics->setIsPlayback(getHighNibble(placeHolder.toUnsignedInt())!=0x4);
9046 if( !jump(1) ) {
return false; }
9049 if( !parseCommonBlock(dynamics) ) {
return false; }
9052 if( !readBuffer(placeHolder, 2) ) {
return false; }
9053 dynamics->setYOffset(placeHolder.toInt());
9056 if( !readBuffer(placeHolder, 1) ) {
return false; }
9057 dynamics->setDynamicsType(getLowNibble(placeHolder.toUnsignedInt()));
9060 if( !readBuffer(placeHolder, 1) ) {
return false; }
9061 dynamics->setVelocity(placeHolder.toUnsignedInt());
9063 int cursor = ove_->getIsVersion4() ? 4 : 2;
9065 if( !jump(cursor) ) {
return false; }
9070 bool BarsParse::parseKey(MeasureData* measureData,
int ) {
9072 Key* key = measureData->getKey();
9073 int cursor = ove_->getIsVersion4() ? 9 : 7;
9075 if( !jump(cursor) ) {
return false; }
9078 if( !readBuffer(placeHolder, 1) ) {
return false; }
9079 key->setKey(oveKeyToKey(placeHolder.toUnsignedInt()));
9082 if( !readBuffer(placeHolder, 1) ) {
return false; }
9083 key->setPreviousKey(oveKeyToKey(placeHolder.toUnsignedInt()));
9085 if( !jump(3) ) {
return false; }
9088 if( !readBuffer(placeHolder, 1) ) {
return false; }
9089 key->setSymbolCount(placeHolder.toUnsignedInt());
9091 if( !jump(4) ) {
return false; }
9096 bool BarsParse::parsePedal(MeasureData* measureData,
int length) {
9099 Pedal* pedal =
new Pedal();
9101 measureData->addCrossMeasureElement(pedal,
true);
9103 if( !jump(1) ) {
return false; }
9106 if( !readBuffer(placeHolder, 1) ) {
return false; }
9107 pedal->setIsPlayback(getHighNibble(placeHolder.toUnsignedInt())!=4);
9109 if( !jump(1) ) {
return false; }
9112 if( !parseCommonBlock(pedal) ) {
return false; }
9114 if( !jump(2) ) {
return false; }
9117 if( !parsePairLinesBlock(pedal) ) {
return false; }
9120 if( !parseOffsetCommonBlock(pedal) ) {
return false; }
9123 if( !parseOffsetElement(pedal->getLeftShoulder()) ) {
return false; }
9126 if( !parseOffsetElement(pedal->getRightShoulder()) ) {
return false; }
9128 int cursor = ove_->getIsVersion4() ? 0x45 : 0x23;
9129 int blankCount = ove_->getIsVersion4() ? 42 : 10;
9131 pedal->setHalf( length > cursor );
9133 if( !jump(blankCount) ) {
return false; }
9135 if( length > cursor ) {
9136 if( !jump(2) ) {
return false; }
9139 if( !readBuffer(placeHolder, 2) ) {
return false; }
9140 pedal->getPedalHandle()->setXOffset(placeHolder.toInt());
9142 if( !jump(6) ) {
return false; }
9148 bool BarsParse::parseKuohao(MeasureData* measureData,
int ) {
9151 KuoHao* kuoHao =
new KuoHao();
9152 measureData->addMusicData(kuoHao);
9154 if( !jump(3) ) {
return false; }
9157 if( !parseCommonBlock(kuoHao) ) {
return false; }
9159 if( !jump(2) ) {
return false; }
9162 if( !parsePairLinesBlock(kuoHao) ) {
return false; }
9164 if( !jump(4) ) {
return false; }
9167 if( !parseOffsetElement(kuoHao->getLeftShoulder()) ) {
return false; }
9170 if( !parseOffsetElement(kuoHao->getRightShoulder()) ) {
return false; }
9173 if( !readBuffer(placeHolder, 1) ) {
return false; }
9174 kuoHao->setKuohaoType(placeHolder.toUnsignedInt());
9177 if( !readBuffer(placeHolder, 1) ) {
return false; }
9178 kuoHao->setHeight(placeHolder.toUnsignedInt());
9180 int jumpAmount = ove_->getIsVersion4() ? 40 : 8;
9181 if( !jump(jumpAmount) ) {
return false; }
9186 bool BarsParse::parseExpressions(MeasureData* measureData,
int length) {
9189 Expressions* expressions =
new Expressions();
9190 measureData->addMusicData(expressions);
9192 if( !jump(3) ) {
return false; }
9195 if( !parseCommonBlock(expressions) ) {
return false; }
9197 if( !jump(2) ) {
return false; }
9200 if( !readBuffer(placeHolder, 2) ) {
return false; }
9201 expressions->setYOffset(placeHolder.toInt());
9204 if( !readBuffer(placeHolder, 2) ) {
return false; }
9207 if( !jump(10) ) {
return false; }
9210 if( !readBuffer(placeHolder, 2) ) {
return false; }
9214 if( !readBuffer(placeHolder, 2) ) {
return false; }
9217 if( !jump(6) ) {
return false; }
9220 int cursor = ove_->getIsVersion4() ? 35 : 33;
9221 if( length > cursor ) {
9222 if( !readBuffer(placeHolder, length-cursor) ) {
return false; }
9223 expressions->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
9229 bool BarsParse::parseHarpPedal(MeasureData* measureData,
int ) {
9232 HarpPedal* harpPedal =
new HarpPedal();
9233 measureData->addMusicData(harpPedal);
9235 if( !jump(3) ) {
return false; }
9238 if( !parseCommonBlock(harpPedal) ) {
return false; }
9240 if( !jump(2) ) {
return false; }
9243 if( !readBuffer(placeHolder, 2) ) {
return false; }
9244 harpPedal->setYOffset(placeHolder.toInt());
9247 if( !readBuffer(placeHolder, 1) ) {
return false; }
9248 harpPedal->setShowType(placeHolder.toUnsignedInt());
9251 if( !readBuffer(placeHolder, 1) ) {
return false; }
9252 harpPedal->setShowCharFlag(placeHolder.toUnsignedInt());
9254 if( !jump(8) ) {
return false; }
9259 bool BarsParse::parseMultiMeasureRest(MeasureData* measureData,
int ) {
9260 Block placeHolder(2);
9261 MultiMeasureRest* measureRest =
new MultiMeasureRest();
9262 measureData->addMusicData(measureRest);
9264 if( !jump(3) ) {
return false; }
9267 if( !parseCommonBlock(measureRest) ) {
return false; }
9269 if( !jump(6) ) {
return false; }
9274 bool BarsParse::parseHarmonyGuitarFrame(MeasureData* measureData,
int length) {
9277 Harmony* harmony =
new Harmony();
9278 measureData->addMusicData(harmony);
9280 if( !jump(3) ) {
return false; }
9283 if( !parseCommonBlock(harmony) ) {
return false; }
9286 if( !readBuffer(placeHolder, 1) ) {
return false; }
9287 harmony->setRoot(placeHolder.toUnsignedInt());
9290 if( !readBuffer(placeHolder, 1) ) {
return false; }
9291 harmony->setHarmonyType((HarmonyType)placeHolder.toUnsignedInt());
9294 if( !readBuffer(placeHolder, 1) ) {
return false; }
9295 harmony->setBass(placeHolder.toUnsignedInt());
9297 int jumpAmount = ove_->getIsVersion4() ? length - 12 : length - 10;
9298 if( !jump(jumpAmount) ) {
return false; }
9303 void extractOctave(
unsigned int Bits, OctaveShiftType& octaveShiftType, QList<OctaveShiftPosition>& positions) {
9304 octaveShiftType = OctaveShift_8;
9309 octaveShiftType = OctaveShift_8;
9310 positions.push_back(OctavePosition_Continue);
9314 octaveShiftType = OctaveShift_Minus_8;
9315 positions.push_back(OctavePosition_Continue);
9319 octaveShiftType = OctaveShift_15;
9320 positions.push_back(OctavePosition_Continue);
9324 octaveShiftType = OctaveShift_Minus_15;
9325 positions.push_back(OctavePosition_Continue);
9329 octaveShiftType = OctaveShift_8;
9330 positions.push_back(OctavePosition_Stop);
9334 octaveShiftType = OctaveShift_Minus_8;
9335 positions.push_back(OctavePosition_Stop);
9339 octaveShiftType = OctaveShift_15;
9340 positions.push_back(OctavePosition_Stop);
9344 octaveShiftType = OctaveShift_Minus_15;
9345 positions.push_back(OctavePosition_Stop);
9349 octaveShiftType = OctaveShift_8;
9350 positions.push_back(OctavePosition_Start);
9354 octaveShiftType = OctaveShift_Minus_8;
9355 positions.push_back(OctavePosition_Start);
9359 octaveShiftType = OctaveShift_15;
9360 positions.push_back(OctavePosition_Start);
9364 octaveShiftType = OctaveShift_Minus_15;
9365 positions.push_back(OctavePosition_Start);
9370 octaveShiftType = OctaveShift_8;
9371 positions.push_back(OctavePosition_Start);
9372 positions.push_back(OctavePosition_Stop);
9376 octaveShiftType = OctaveShift_Minus_8;
9377 positions.push_back(OctavePosition_Start);
9378 positions.push_back(OctavePosition_Stop);
9382 octaveShiftType = OctaveShift_15;
9383 positions.push_back(OctavePosition_Start);
9384 positions.push_back(OctavePosition_Stop);
9388 octaveShiftType = OctaveShift_Minus_15;
9389 positions.push_back(OctavePosition_Start);
9390 positions.push_back(OctavePosition_Stop);
9398 bool BarsParse::parseOctaveShift(MeasureData* measureData,
int )
9402 OctaveShift* octave =
new OctaveShift();
9403 measureData->addCrossMeasureElement(octave,
true);
9405 if( !jump(3) ) {
return false; }
9408 if( !parseCommonBlock(octave) ) {
return false; }
9411 if( !readBuffer(placeHolder, 1) ) {
return false; }
9412 unsigned int type = getLowNibble(placeHolder.toUnsignedInt());
9413 OctaveShiftType octaveShiftType = OctaveShift_8;
9414 QList<OctaveShiftPosition> positions;
9415 extractOctave(type, octaveShiftType, positions);
9417 octave->setOctaveShiftType(octaveShiftType);
9419 if( !jump(1) ) {
return false; }
9422 if( !readBuffer(placeHolder, 2) ) {
return false; }
9423 octave->setYOffset(placeHolder.toInt());
9425 if( !jump(4) ) {
return false; }
9428 if( !readBuffer(placeHolder, 2) ) {
return false; }
9429 octave->setLength(placeHolder.toUnsignedInt());
9432 if( !readBuffer(placeHolder, 2) ) {
return false; }
9433 octave->setEndTick(placeHolder.toUnsignedInt());
9436 for (
int i=0; i<positions.size(); ++i) {
9437 OctaveShiftPosition position = positions[i];
9438 OctaveShiftEndPoint* octavePoint =
new OctaveShiftEndPoint();
9439 measureData->addMusicData(octavePoint);
9441 octavePoint->copyCommonBlock(*octave);
9442 octavePoint->setOctaveShiftType(octaveShiftType);
9443 octavePoint->setOctaveShiftPosition(position);
9444 octavePoint->setEndTick(octave->getEndTick());
9447 if( i==0 && position == OctavePosition_Stop ) {
9448 octavePoint->start()->setOffset(octave->start()->getOffset()+octave->getLength());
9453 octavePoint->start()->setOffset(octave->start()->getOffset()+octave->getLength());
9454 octavePoint->setTick(octave->getEndTick());
9461 bool BarsParse::parseMidiController(MeasureData* measureData,
int ) {
9463 MidiController* controller =
new MidiController();
9464 measureData->addMidiData(controller);
9466 parseMidiCommon(controller);
9469 if( !readBuffer(placeHolder, 1) ) {
return false; }
9470 controller->setValue(placeHolder.toUnsignedInt());
9473 if( !readBuffer(placeHolder, 1) ) {
return false; }
9474 controller->setController(placeHolder.toUnsignedInt());
9476 if( ove_->getIsVersion4() ) {
9477 if( !jump(2) ) {
return false; }
9483 bool BarsParse::parseMidiProgramChange(MeasureData* measureData,
int ) {
9485 MidiProgramChange* program =
new MidiProgramChange();
9486 measureData->addMidiData(program);
9488 parseMidiCommon(program);
9490 if( !jump(1) ) {
return false; }
9493 if( !readBuffer(placeHolder, 1) ) {
return false; }
9494 program->setPatch(placeHolder.toUnsignedInt());
9496 if( ove_->getIsVersion4() ) {
9497 if( !jump(2) ) {
return false; }
9503 bool BarsParse::parseMidiChannelPressure(MeasureData* measureData,
int ) {
9505 MidiChannelPressure* pressure =
new MidiChannelPressure();
9506 measureData->addMidiData(pressure);
9508 parseMidiCommon(pressure);
9510 if( !jump(1) ) {
return false; }
9513 if( !readBuffer(placeHolder, 1) ) {
return false; }
9514 pressure->setPressure(placeHolder.toUnsignedInt());
9516 if( ove_->getIsVersion4() )
9518 if( !jump(2) ) {
return false; }
9524 bool BarsParse::parseMidiPitchWheel(MeasureData* measureData,
int ) {
9526 MidiPitchWheel* wheel =
new MidiPitchWheel();
9527 measureData->addMidiData(wheel);
9529 parseMidiCommon(wheel);
9532 if( !readBuffer(placeHolder, 2) ) {
return false; }
9533 int value = placeHolder.toUnsignedInt();
9534 wheel->setValue(value);
9536 if( ove_->getIsVersion4() ) {
9537 if( !jump(2) ) {
return false; }
9543 bool BarsParse::parseSizeBlock(
int length) {
9544 if( !jump(length) ) {
return false; }
9549 bool BarsParse::parseMidiCommon(MidiData* ptr) {
9552 if( !jump(3) ) {
return false; }
9555 if( !readBuffer(placeHolder, 2) ) {
return false; }
9556 ptr->setTick(placeHolder.toUnsignedInt());
9561 bool BarsParse::parseCommonBlock(MusicData* ptr) {
9565 if( !readBuffer(placeHolder, 2) ) {
return false; }
9566 ptr->setTick(placeHolder.toInt());
9569 if( !readBuffer(placeHolder, 2) ) {
return false; }
9570 ptr->start()->setOffset(placeHolder.toInt());
9572 if( ove_->getIsVersion4() ) {
9574 if( !readBuffer(placeHolder, 1) ) {
return false; }
9575 ptr->setColor(placeHolder.toUnsignedInt());
9577 if( !jump(1) ) {
return false; }
9583 bool BarsParse::parseOffsetCommonBlock(MusicData* ptr) {
9587 if( !readBuffer(placeHolder, 2) ) {
return false; }
9588 ptr->stop()->setMeasure(placeHolder.toUnsignedInt());
9591 if( !readBuffer(placeHolder, 2) ) {
return false; }
9592 ptr->stop()->setOffset(placeHolder.toInt());
9597 bool BarsParse::parsePairLinesBlock(PairEnds* ptr) {
9601 if( !readBuffer(placeHolder, 2) ) {
return false; }
9602 ptr->getLeftLine()->setLine(placeHolder.toInt());
9605 if( !readBuffer(placeHolder, 2) ) {
return false; }
9606 ptr->getRightLine()->setLine(placeHolder.toInt());
9611 bool BarsParse::parseOffsetElement(OffsetElement* ptr) {
9615 if( !readBuffer(placeHolder, 2) ) {
return false; }
9616 ptr->setXOffset(placeHolder.toInt());
9619 if( !readBuffer(placeHolder, 2) ) {
return false; }
9620 ptr->setYOffset(placeHolder.toInt());
9625 bool BarsParse::getCondElementType(
unsigned int byteData, CondType& type) {
9626 if( byteData == 0x09 ) {
9627 type = Cond_Time_Parameters;
9628 }
else if (byteData == 0x0A) {
9629 type = Cond_Bar_Number;
9630 }
else if (byteData == 0x16) {
9631 type = Cond_Decorator;
9632 }
else if (byteData == 0x1C) {
9634 }
else if (byteData == 0x1D) {
9636 }
else if (byteData == 0x25) {
9637 type = Cond_Expression;
9638 }
else if (byteData == 0x30) {
9639 type = Cond_Barline_Parameters;
9640 }
else if (byteData == 0x31) {
9642 }
else if (byteData == 0x32) {
9643 type = Cond_Numeric_Ending;
9651 bool BarsParse::getBdatElementType(
unsigned int byteData, BdatType& type) {
9652 if (byteData == 0x70) {
9653 type = Bdat_Raw_Note;
9654 }
else if (byteData == 0x80) {
9656 }
else if (byteData == 0x90) {
9658 }
else if (byteData == 0x10) {
9660 }
else if (byteData == 0x11) {
9661 type = Bdat_Harmony;
9662 }
else if (byteData == 0x12) {
9664 }
else if (byteData == 0x13) {
9666 }
else if (byteData == 0x14) {
9667 type = Bdat_Dynamics;
9668 }
else if (byteData == 0x15) {
9669 type = Bdat_Glissando;
9670 }
else if (byteData == 0x16) {
9671 type = Bdat_Decorator;
9672 }
else if (byteData == 0x17) {
9674 }
else if (byteData == 0x18) {
9676 }
else if (byteData == 0x19) {
9677 type = Bdat_Octave_Shift;
9678 }
else if (byteData == 0x1B) {
9680 }
else if (byteData == 0x1D) {
9682 }
else if (byteData == 0x1E) {
9684 }
else if (byteData == 0x1F) {
9686 }
else if (byteData == 0x21) {
9687 type = Bdat_Guitar_Bend;
9688 }
else if (byteData == 0x22) {
9689 type = Bdat_Guitar_Barre;
9690 }
else if (byteData == 0x23) {
9692 }
else if (byteData == 0x24) {
9694 }
else if (byteData == 0x25) {
9695 type = Bdat_Expressions;
9696 }
else if (byteData == 0x26) {
9697 type = Bdat_Harp_Pedal;
9698 }
else if (byteData == 0x27) {
9699 type = Bdat_Multi_Measure_Rest;
9700 }
else if (byteData == 0x28) {
9701 type = Bdat_Harmony_GuitarFrame;
9702 }
else if (byteData == 0x40) {
9703 type = Bdat_Graphics_40;
9704 }
else if (byteData == 0x41) {
9705 type = Bdat_Graphics_RoundRect;
9706 }
else if (byteData == 0x42) {
9707 type = Bdat_Graphics_Rect;
9708 }
else if (byteData == 0x43) {
9709 type = Bdat_Graphics_Round;
9710 }
else if (byteData == 0x44) {
9711 type = Bdat_Graphics_Line;
9712 }
else if (byteData == 0x45) {
9713 type = Bdat_Graphics_Curve;
9714 }
else if (byteData == 0x46) {
9715 type = Bdat_Graphics_WedgeSymbol;
9716 }
else if (byteData == 0xAB) {
9717 type = Bdat_Midi_Controller;
9718 }
else if (byteData == 0xAC) {
9719 type = Bdat_Midi_Program_Change;
9720 }
else if (byteData == 0xAD) {
9721 type = Bdat_Midi_Channel_Pressure;
9722 }
else if (byteData == 0xAE) {
9723 type = Bdat_Midi_Pitch_Wheel;
9724 }
else if (byteData == 0xFF) {
9725 type = Bdat_Bar_End;
9734 LyricChunkParse::LyricChunkParse(OveSong* ove) :
9738 void LyricChunkParse::setLyricChunk(SizeChunk* chunk) {
9743 bool LyricChunkParse::parse() {
9745 Block* dataBlock = chunk_->getDataBlock();
9746 unsigned int blockSize = chunk_->getSizeBlock()->toSize();
9747 StreamHandle handle(dataBlock->data(), blockSize);
9752 if( !jump(4) ) {
return false; }
9755 if( !readBuffer(placeHolder, 2) ) {
return false; }
9756 unsigned int count = placeHolder.toUnsignedInt();
9758 for( i=0; i<count; ++i ) {
9761 if( !readBuffer(placeHolder, 2) ) {
return false; }
9765 if( !jump(2) ) {
return false; }
9768 if( !readBuffer(placeHolder, 1) ) {
return false; }
9769 info.voice_ = placeHolder.toUnsignedInt();
9772 if( !readBuffer(placeHolder, 1) ) {
return false; }
9773 info.verse_ = placeHolder.toUnsignedInt();
9776 if( !readBuffer(placeHolder, 1) ) {
return false; }
9777 info.track_ = placeHolder.toUnsignedInt();
9779 if( !jump(1) ) {
return false; }
9782 if( !readBuffer(placeHolder, 2) ) {
return false; }
9783 info.measure_ = placeHolder.toUnsignedInt();
9786 if( !readBuffer(placeHolder, 2) ) {
return false; }
9787 info.wordCount_ = placeHolder.toUnsignedInt();
9790 if( !readBuffer(placeHolder, 2) ) {
return false; }
9791 info.lyricSize_ = placeHolder.toUnsignedInt();
9793 if( !jump(6) ) {
return false; }
9796 if( !readBuffer(placeHolder, 32) ) {
return false; }
9797 info.name_ = ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray());
9799 if( info.lyricSize_ > 0 ) {
9801 if( info.lyricSize_ > 0 ) {
9802 if( !readBuffer(placeHolder, info.lyricSize_) ) {
return false; }
9803 info.lyric_ = ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray());
9806 if( !jump(4) ) {
return false; }
9809 if( !readBuffer(placeHolder, 2) ) {
return false; }
9810 info.font_ = placeHolder.toUnsignedInt();
9812 if( !jump(1) ) {
return false; }
9815 if( !readBuffer(placeHolder, 1) ) {
return false; }
9816 info.fontSize_ = placeHolder.toUnsignedInt();
9819 if( !readBuffer(placeHolder, 1) ) {
return false; }
9820 info.fontStyle_ = placeHolder.toUnsignedInt();
9822 if( !jump(1) ) {
return false; }
9824 for(
int j=0; j<info.wordCount_; ++j ) {
9825 if( !jump(8) ) {
return false; }
9829 processLyricInfo(info);
9835 bool isSpace(
char c) {
9836 return c ==
' ' || c ==
'\n';
9839 void LyricChunkParse::processLyricInfo(
const LyricInfo& info)
9845 int measureId = info.measure_-1;
9846 bool changeMeasure =
true;
9847 MeasureData* measureData = 0;
9848 int trackMeasureCount = ove_->getTrackBarCount();
9849 QStringList words = info.lyric_.split(
" ", QString::SkipEmptyParts);
9851 while ( index < words.size() && measureId+1 < trackMeasureCount ) {
9852 if( changeMeasure ) {
9854 measureData = ove_->getMeasureData(info.track_, measureId);
9855 changeMeasure =
false;
9858 if( measureData == 0 ) {
return; }
9859 QList<NoteContainer*> containers = measureData->getNoteContainers();
9860 QList<MusicData*> lyrics = measureData->getMusicDatas(MusicData_Lyric);
9862 for( i=0; i<containers.size() && index<words.size(); ++i ) {
9863 if( containers[i]->getIsRest() ) {
9867 for( j=0; j<lyrics.size(); ++j ) {
9868 Lyric* lyric =
static_cast<Lyric*
>(lyrics[j]);
9870 if( containers[i]->
start()->getOffset() == lyric->start()->getOffset() &&
9871 (int)containers[i]->getVoice() == info.voice_ &&
9872 lyric->getVerse() == info.verse_ ) {
9873 if(index<words.size()) {
9874 QString l = words[index].trimmed();
9877 lyric->setVoice(info.voice_);
9886 changeMeasure =
true;
9891 TitleChunkParse::TitleChunkParse(OveSong* ove) :
9893 titleType_ = 0x00000001;
9894 annotateType_ = 0x00010000;
9895 writerType_ = 0x00020002;
9896 copyrightType_ = 0x00030001;
9897 headerType_ = 0x00040000;
9898 footerType_ = 0x00050002;
9901 void TitleChunkParse::setTitleChunk(SizeChunk* chunk) {
9905 bool TitleChunkParse::parse() {
9906 Block* dataBlock = chunk_->getDataBlock();
9907 unsigned int blockSize = chunk_->getSizeBlock()->toSize();
9908 StreamHandle handle(dataBlock->data(), blockSize);
9910 unsigned int titleType;
9914 if( !readBuffer(typeBlock, 4) ) {
return false; }
9916 titleType = typeBlock.toUnsignedInt();
9918 if( titleType == titleType_ || titleType == annotateType_ || titleType == writerType_ || titleType == copyrightType_ ) {
9921 if( !readBuffer(offsetBlock, 4) ) {
return false; }
9923 const unsigned int itemCount = 4;
9926 for( i=0; i<itemCount; ++i ) {
9929 if( !jump(6) ) {
return false; }
9933 if( !readBuffer(countBlock, 2) ) {
return false; }
9934 unsigned int titleSize = countBlock.toUnsignedInt();
9937 if( !readBuffer(dataBlock, titleSize) ) {
return false; }
9939 QByteArray array((
char*)dataBlock.data(), dataBlock.size());
9940 addToOve(ove_->getCodecString(array), titleType);
9946 if( titleType == headerType_ || titleType == footerType_ ) {
9947 if( !jump(10) ) {
return false; }
9950 if( !readBuffer(countBlock, 2) ) {
return false; }
9951 unsigned int titleSize = countBlock.toUnsignedInt();
9954 if( !readBuffer(dataBlock, titleSize) ) {
return false; }
9956 QByteArray array((
char*)dataBlock.data(), dataBlock.size());
9957 addToOve(ove_->getCodecString(array), titleType);
9960 if( !jump(6) ) {
return false; }
9968 void TitleChunkParse::addToOve(
const QString& str,
unsigned int titleType) {
9969 if( str.isEmpty() ) {
return; }
9971 if (titleType == titleType_) {
9972 ove_->addTitle(str);
9975 if (titleType == annotateType_) {
9976 ove_->addAnnotate(str);
9979 if (titleType == writerType_) {
9980 ove_->addWriter(str);
9983 if (titleType == copyrightType_) {
9984 ove_->addCopyright(str);
9987 if (titleType == headerType_) {
9988 ove_->addHeader(str);
9991 if (titleType == footerType_) {
9992 ove_->addFooter(str);
9997 OveOrganizer::OveOrganizer(OveSong* ove) {
10001 void OveOrganizer::organize() {
10007 organizeAttributes();
10008 organizeMeasures();
10011 void OveOrganizer::organizeAttributes() {
10017 if(ove_->getLineCount() > 0) {
10018 Line* line = ove_->getLine(0);
10019 int partBarCount = ove_->getPartBarCount();
10023 for(i=0; i<line->getStaffCount(); ++i) {
10024 QPair<int, int> partStaff = ove_->trackToPartStaff(i);
10025 Staff* staff = line->getStaff(i);
10026 lastKey = staff->getKeyType();
10028 for(j=0; j<partBarCount; ++j) {
10029 MeasureData* measureData = ove_->getMeasureData(partStaff.first, partStaff.second, j);
10031 if(measureData != 0) {
10032 Key* key = measureData->getKey();
10035 key->setKey(lastKey);
10036 key->setPreviousKey(lastKey);
10039 if( !key->getSetKey() ) {
10040 key->setKey(lastKey);
10041 key->setPreviousKey(lastKey);
10044 if( key->getKey() != lastKey ) {
10045 lastKey = key->getKey();
10055 if( ove_->getLineCount() > 0 ) {
10056 Line* line = ove_->getLine(0);
10057 int partBarCount = ove_->getPartBarCount();
10058 ClefType lastClefType = Clef_Treble;
10061 for( i=0; i<line->getStaffCount(); ++i ) {
10062 QPair<int, int> partStaff = ove_->trackToPartStaff(i);
10063 Staff* staff = line->getStaff(i);
10064 lastClefType = staff->getClefType();
10066 for( j=0; j<partBarCount; ++j ) {
10067 MeasureData* measureData = ove_->getMeasureData(partStaff.first, partStaff.second, j);
10069 if(measureData != 0) {
10070 Clef* clefPtr = measureData->getClef();
10071 clefPtr->setClefType((
int)lastClefType);
10073 const QList<MusicData*>& clefs = measureData->getMusicDatas(MusicData_Clef);
10075 for( k=0; k<clefs.size(); ++k ) {
10076 Clef* clef =
static_cast<Clef*
>(clefs[k]);
10077 lastClefType = clef->getClefType();
10086 Staff* getStaff(OveSong* ove,
int track) {
10087 if (ove->getLineCount() > 0) {
10088 Line* line = ove->getLine(0);
10089 if(line != 0 && line->getStaffCount() > 0) {
10090 Staff* staff = line->getStaff(track);
10098 void OveOrganizer::organizeTracks() {
10101 QList<Track*> tracks = ove_->getTracks();
10102 QList<bool> comboStaveStarts;
10104 for( i=0; i<tracks.size(); ++i ) {
10105 comboStaveStarts.push_back(
false);
10108 for( i=0; i<tracks.size(); ++i ) {
10109 Staff* staff = getStaff(ove_, i);
10111 if(staff->getGroupType() == Group_Brace && staff->getGroupStaffCount() == 1 ) {
10112 comboStaveStarts[i] =
true;
10125 QList<int> partStaffCounts;
10127 while( trackId < (
int)tracks.size() ) {
10128 int partTrackCount = 1;
10130 if( comboStaveStarts[trackId] ) {
10131 partTrackCount = 2;
10134 partStaffCounts.push_back(partTrackCount);
10135 trackId += partTrackCount;
10138 ove_->setPartStaffCounts(partStaffCounts);
10141 void OveOrganizer::organizeMeasures() {
10142 int trackBarCount = ove_->getTrackBarCount();
10144 for(
int i=0; i<ove_->getPartCount(); ++i ) {
10145 int partStaffCount = ove_->getStaffCount(i);
10147 for(
int j=0; j<partStaffCount; ++j ) {
10148 for(
int k=0; k<trackBarCount; ++k ) {
10149 Measure* measure = ove_->getMeasure(k);
10150 MeasureData* measureData = ove_->getMeasureData(i, j, k);
10152 organizeMeasure(i, j, measure, measureData);
10158 void OveOrganizer::organizeMeasure(
int part,
int track, Measure* measure, MeasureData* measureData) {
10160 organizeContainers(part, track, measure, measureData);
10163 organizeMusicDatas(part, track, measure, measureData);
10166 organizeCrossMeasureElements(part, track, measure, measureData);
10169 void addToList(QList<int>& list,
int number) {
10170 for(
int i=0; i<list.size(); ++i){
10171 if(list[i] == number){
10176 list.push_back(number);
10179 void OveOrganizer::organizeContainers(
int ,
int ,
10180 Measure* measure, MeasureData* measureData)
10183 QList<NoteContainer*> containers = measureData->getNoteContainers();
10184 int barUnits = measure->getTime()->getUnits();
10187 for(i=0; i<containers.size(); ++i){
10188 int endUnit = barUnits;
10189 if( i < containers.size() - 1 ) {
10190 endUnit = containers[i+1]->start()->getOffset();
10193 containers[i]->stop()->setOffset(endUnit);
10194 addToList(voices, containers[i]->getVoice());
10198 qSort(voices.begin(), voices.end());
10200 for (i = 0; i < voices.size(); ++i) {
10201 int voice = voices[i];
10203 for(
int j=0; j<(int)containers.size(); ++j) {
10204 int avoice = containers[j]->getVoice();
10205 if ( avoice == voice && avoice != i ) {
10206 containers[j]->setVoice(i);
10212 void OveOrganizer::organizeMusicDatas(
int ,
int , Measure* measure, MeasureData* measureData) {
10214 int barIndex = measure->getBarNumber()->getIndex();
10215 QList<MusicData*> datas = measureData->getMusicDatas(MusicData_None);
10217 for(i=0; i<datas.size(); ++i) {
10218 datas[i]->start()->setMeasure(barIndex);
10222 void OveOrganizer::organizeCrossMeasureElements(
int part,
int track, Measure* measure, MeasureData* measureData)
10225 QList<MusicData*> pairs = measureData->getCrossMeasureElements(MusicData_None, MeasureData::PairType_Start);
10227 for(i=0; i<pairs.size(); ++i) {
10228 MusicData* pair = pairs[i];
10230 switch ( pair->getMusicDataType() ) {
10231 case MusicData_Beam :
10232 case MusicData_Glissando :
10233 case MusicData_Slur :
10234 case MusicData_Tie :
10235 case MusicData_Tuplet :
10236 case MusicData_Pedal :
10237 case MusicData_Numeric_Ending :
10239 case MusicData_Measure_Repeat : {
10240 organizePairElement(pair, part, track, measure, measureData);
10243 case MusicData_OctaveShift : {
10244 OctaveShift* octave =
static_cast<OctaveShift*
>(pair);
10245 organizeOctaveShift(octave, measure, measureData);
10248 case MusicData_Wedge : {
10249 Wedge* wedge =
static_cast<Wedge*
>(pair);
10250 organizeWedge(wedge, part, track, measure, measureData);
10259 void OveOrganizer::organizePairElement(
10264 MeasureData* measureData) {
10265 int bar1Index = measure->getBarNumber()->getIndex();
10266 int bar2Index = bar1Index + data->stop()->getMeasure();
10267 MeasureData* measureData2 = ove_->getMeasureData(part, track, bar2Index);
10269 data->start()->setMeasure(bar1Index);
10271 if(measureData2 != 0 && measureData != measureData2) {
10272 measureData2->addCrossMeasureElement(data,
false);
10275 if( data->getMusicDataType() == MusicData_Tuplet ){
10276 Tuplet* tuplet =
static_cast<Tuplet*
>(data);
10277 const QList<NoteContainer*> containers = measureData->getNoteContainers();
10279 for(
int i=0; i<containers.size(); ++i){
10280 if(containers[i]->getTick() > tuplet->getTick()){
10284 if(containers[i]->getTick() == tuplet->getTick()){
10285 tuplet->setNoteType(containers[i]->getNoteType());
10289 int tupletTick = NoteTypeToTick(tuplet->getNoteType(), ove_->getQuarter())*tuplet->getSpace();
10290 if( tuplet->getTick() % tupletTick != 0 ) {
10291 int newStartTick = (tuplet->getTick() / tupletTick) * tupletTick;
10293 for(
int i=0; i<containers.size(); ++i){
10294 if( containers[i]->getTick() == newStartTick &&
10295 containers[i]->getTuplet() == tuplet->getTuplet()) {
10296 tuplet->setTick(containers[i]->getTick());
10297 tuplet->start()->setOffset(containers[i]->
start()->getOffset());
10304 void OveOrganizer::organizeOctaveShift(
10305 OctaveShift* octave,
10307 MeasureData* measureData)
10311 const QList<NoteContainer*> containers = measureData->getNoteContainers();
10312 int barIndex = measure->getBarNumber()->getIndex();
10314 octave->start()->setMeasure(barIndex);
10316 for(i=0; i<containers.size(); ++i) {
10317 int noteShift = octave->getNoteShift();
10318 int containerTick = containers[i]->getTick();
10320 if( octave->getTick() <= containerTick && octave->getEndTick() > containerTick ) {
10321 containers[i]->setNoteShift(noteShift);
10326 bool getMiddleUnit(
10327 OveSong* ove,
int ,
int ,
10328 Measure* measure1, Measure* measure2,
int unit1,
int ,
10329 Measure* middleMeasure,
int& middleUnit) {
10330 QList<int> barUnits;
10332 int bar1Index = measure1->getBarNumber()->getIndex();
10333 int bar2Index = measure2->getBarNumber()->getIndex();
10336 for(
int j=bar1Index; j<=bar2Index; ++j ) {
10337 Measure* measure = ove->getMeasure(j);
10338 barUnits.push_back(measure->getTime()->getUnits());
10339 sumUnit += measure->getTime()->getUnits();
10342 int currentSumUnit = 0;
10343 for( i=0; i<barUnits.size(); ++i ) {
10344 int barUnit = barUnits[i];
10347 barUnit = barUnits[i] - unit1;
10350 if( currentSumUnit + barUnit < sumUnit/2 ) {
10351 currentSumUnit += barUnit;
10358 if( i < barUnits.size() ) {
10359 int barMiddleIndex = bar1Index + i;
10360 middleMeasure = ove->getMeasure(barMiddleIndex);
10361 middleUnit = sumUnit/2 - currentSumUnit;
10369 void OveOrganizer::organizeWedge(Wedge* wedge,
int part,
int track, Measure* measure, MeasureData* measureData) {
10370 int bar1Index = measure->getBarNumber()->getIndex();
10371 int bar2Index = bar1Index + wedge->stop()->getMeasure();
10372 MeasureData* measureData2 = ove_->getMeasureData(part, track, bar2Index);
10373 WedgeType wedgeType = wedge->getWedgeType();
10375 if( wedge->getWedgeType() == Wedge_Double_Line ) {
10376 wedgeType = Wedge_Cres_Line;
10379 wedge->start()->setMeasure(bar1Index);
10381 WedgeEndPoint* startPoint =
new WedgeEndPoint();
10382 measureData->addMusicData(startPoint);
10384 startPoint->setTick(wedge->getTick());
10385 startPoint->start()->setOffset(wedge->start()->getOffset());
10386 startPoint->setWedgeStart(
true);
10387 startPoint->setWedgeType(wedgeType);
10388 startPoint->setHeight(wedge->getHeight());
10390 WedgeEndPoint* stopPoint =
new WedgeEndPoint();
10392 stopPoint->setTick(wedge->getTick());
10393 stopPoint->start()->setOffset(wedge->stop()->getOffset());
10394 stopPoint->setWedgeStart(
false);
10395 stopPoint->setWedgeType(wedgeType);
10396 stopPoint->setHeight(wedge->getHeight());
10398 if(measureData2 != 0) {
10399 measureData2->addMusicData(stopPoint);
10402 if( wedge->getWedgeType() == Wedge_Double_Line ) {
10403 Measure* middleMeasure = NULL;
10404 int middleUnit = 0;
10408 measure, ove_->getMeasure(bar2Index),
10409 wedge->start()->getOffset(), wedge->stop()->getOffset(),
10410 middleMeasure, middleUnit);
10412 if( middleMeasure != 0 ) {
10413 WedgeEndPoint* midStopPoint =
new WedgeEndPoint();
10414 measureData->addMusicData(midStopPoint);
10416 midStopPoint->setTick(wedge->getTick());
10417 midStopPoint->start()->setOffset(middleUnit);
10418 midStopPoint->setWedgeStart(
false);
10419 midStopPoint->setWedgeType(Wedge_Cres_Line);
10420 midStopPoint->setHeight(wedge->getHeight());
10422 WedgeEndPoint* midStartPoint =
new WedgeEndPoint();
10423 measureData->addMusicData(midStartPoint);
10425 midStartPoint->setTick(wedge->getTick());
10426 midStartPoint->start()->setOffset(middleUnit);
10427 midStartPoint->setWedgeStart(
true);
10428 midStartPoint->setWedgeType(Wedge_Decresc_Line);
10429 midStartPoint->setHeight(wedge->getHeight());
10464 ChunkType nameToChunkType(
const NameBlock& name) {
10465 ChunkType type = Chunk_NONE;
10467 if (name.isEqual(
"OVSC")) {
10469 }
else if (name.isEqual(
"TRKL")) {
10471 }
else if (name.isEqual(
"TRAK")) {
10473 }
else if (name.isEqual(
"PAGL")) {
10475 }
else if (name.isEqual(
"PAGE")) {
10477 }
else if (name.isEqual(
"LINL")) {
10479 }
else if (name.isEqual(
"LINE")) {
10481 }
else if (name.isEqual(
"STAF")) {
10483 }
else if (name.isEqual(
"BARL")) {
10485 }
else if (name.isEqual(
"MEAS")) {
10487 }
else if (name.isEqual(
"COND")) {
10489 }
else if (name.isEqual(
"BDAT")) {
10491 }
else if (name.isEqual(
"PACH")) {
10493 }
else if (name.isEqual(
"FNTS")) {
10495 }
else if (name.isEqual(
"ODEV")) {
10497 }
else if (name.isEqual(
"TITL")) {
10499 }
else if (name.isEqual(
"ALOT")) {
10501 }
else if (name.isEqual(
"ENGR")) {
10503 }
else if (name.isEqual(
"FMAP")) {
10505 }
else if (name.isEqual(
"PCPR")) {
10507 }
else if (name.isEqual(
"LYRC")) {
10514 int chunkTypeToMaxTimes(ChunkType type) {
10571 OveSerialize::OveSerialize() :
10577 OveSerialize::~OveSerialize() {
10578 if(streamHandle_ != 0) {
10579 delete streamHandle_;
10584 void OveSerialize::setOve(OveSong* ove) {
10588 void OveSerialize::setFileStream(
unsigned char* buffer,
unsigned int size) {
10589 streamHandle_ =
new StreamHandle(buffer, size);
10592 void OveSerialize::setNotify(IOveNotify* notify) {
10596 void OveSerialize::messageOutError() {
10597 if (notify_ != NULL) {
10598 notify_->loadError();
10602 void OveSerialize::messageOut(
const QString& str) {
10603 if (notify_ != NULL) {
10604 notify_->loadInfo(str);
10608 bool OveSerialize::load(
void) {
10609 if(streamHandle_ == 0)
10612 if( !readHeader() ) {
10618 QMap<ChunkType, int> chunkTimes;
10621 for( i=(
int)Chunk_OVSC; i<(int)Chunk_NONE; ++i ) {
10622 chunkTimes[(ChunkType)i] = 0;
10625 ChunkType chunkType = Chunk_NONE;
10628 NameBlock nameBlock;
10629 SizeChunk sizeChunk;
10631 if( !readNameBlock(nameBlock) ) {
return false; }
10633 chunkType = nameToChunkType(nameBlock);
10634 ++chunkTimes[chunkType];
10635 int maxTime = chunkTypeToMaxTimes(chunkType);
10637 if( maxTime > 0 && chunkTimes[chunkType] > maxTime ) {
10638 messageOut(
"format not support, chunk appear more than accept.");
10642 switch (chunkType) {
10654 if (!readTracksData()) {
10662 if (!readPagesData()) {
10670 if (!readLinesData()) {
10678 if (!readBarsData()) {
10696 SizeChunk lyricChunk;
10697 if (!readSizeChunk(&lyricChunk)) {
10702 LyricChunkParse parse(ove_);
10704 parse.setLyricChunk(&lyricChunk);
10710 SizeChunk titleChunk;
10711 if (!readSizeChunk(&titleChunk)) {
10716 TitleChunkParse titleChunkParse(ove_);
10718 titleChunkParse.setTitleChunk(&titleChunk);
10719 titleChunkParse.parse();
10730 if (!readSizeChunk(&sizeChunk)) {
10752 while ( chunkType != Chunk_NONE );
10757 OVE::OveOrganizer organizer(ove_);
10758 organizer.organize();
10763 void OveSerialize::release() {
10767 bool OveSerialize::readHeader() {
10768 ChunkType chunkType = Chunk_NONE;
10769 NameBlock nameBlock;
10770 SizeChunk sizeChunk;
10772 if (!readNameBlock(nameBlock)) {
10776 chunkType = nameToChunkType(nameBlock);
10779 if (chunkType == Chunk_OVSC) {
10780 if (readHeadData(&sizeChunk)) {
10785 QString info =
"Not compatible file, try to load and save with newer version, Overture 4 is recommended.";
10791 bool OveSerialize::readHeadData(SizeChunk* ovscChunk) {
10792 if (!readSizeChunk(ovscChunk))
10795 OvscParse ovscParse(ove_);
10797 ovscParse.setNotify(notify_);
10798 ovscParse.setOvsc(ovscChunk);
10800 return ovscParse.parse();
10803 bool OveSerialize::readTracksData() {
10804 GroupChunk trackGroupChunk;
10806 if (!readGroupChunk(&trackGroupChunk))
10810 unsigned short trackCount = trackGroupChunk.getCountBlock()->toCount();
10812 for (i = 0; i < trackCount; ++i) {
10813 SizeChunk* trackChunk =
new SizeChunk();
10815 if (ove_->getIsVersion4()) {
10816 if (!readChunkName(trackChunk, Chunk::TrackName)) {
10819 if (!readSizeChunk(trackChunk)) {
10823 if (!readDataChunk(trackChunk->getDataBlock(),
10824 SizeChunk::version3TrackSize)) {
10829 TrackParse trackParse(ove_);
10831 trackParse.setTrack(trackChunk);
10832 trackParse.parse();
10838 bool OveSerialize::readPagesData() {
10839 GroupChunk pageGroupChunk;
10841 if (!readGroupChunk(&pageGroupChunk))
10844 unsigned short pageCount = pageGroupChunk.getCountBlock()->toCount();
10846 PageGroupParse parse(ove_);
10848 for (i = 0; i < pageCount; ++i) {
10849 SizeChunk* pageChunk =
new SizeChunk();
10851 if (!readChunkName(pageChunk, Chunk::PageName)) {
10854 if (!readSizeChunk(pageChunk)) {
10858 parse.addPage(pageChunk);
10861 if (!parse.parse()) {
10868 bool OveSerialize::readLinesData() {
10869 GroupChunk lineGroupChunk;
10870 if (!readGroupChunk(&lineGroupChunk))
10873 unsigned short lineCount = lineGroupChunk.getCountBlock()->toCount();
10876 QList<SizeChunk*> lineChunks;
10877 QList<SizeChunk*> staffChunks;
10879 for (i = 0; i < lineCount; ++i) {
10880 SizeChunk* lineChunk =
new SizeChunk();
10882 if (!readChunkName(lineChunk, Chunk::LineName)) {
10885 if (!readSizeChunk(lineChunk)) {
10889 lineChunks.push_back(lineChunk);
10891 StaffCountGetter getter(ove_);
10892 unsigned int staffCount = getter.getStaffCount(lineChunk);
10894 for (j = 0; j < staffCount; ++j) {
10895 SizeChunk* staffChunk =
new SizeChunk();
10897 if (!readChunkName(staffChunk, Chunk::StaffName)) {
10900 if (!readSizeChunk(staffChunk)) {
10904 staffChunks.push_back(staffChunk);
10908 LineGroupParse parse(ove_);
10910 parse.setLineGroup(&lineGroupChunk);
10912 for (i = 0; i < lineChunks.size(); ++i) {
10913 parse.addLine(lineChunks[i]);
10916 for (i = 0; i < staffChunks.size(); ++i) {
10917 parse.addStaff(staffChunks[i]);
10920 if (!parse.parse()) {
10927 bool OveSerialize::readBarsData() {
10928 GroupChunk barGroupChunk;
10929 if (!readGroupChunk(&barGroupChunk))
10932 unsigned short measCount = barGroupChunk.getCountBlock()->toCount();
10935 QList<SizeChunk*> measureChunks;
10936 QList<SizeChunk*> conductChunks;
10937 QList<SizeChunk*> bdatChunks;
10939 ove_->setTrackBarCount(measCount);
10942 for (i = 0; i < measCount; ++i) {
10943 SizeChunk* measureChunkPtr =
new SizeChunk();
10945 if (!readChunkName(measureChunkPtr, Chunk::MeasureName)) {
10948 if (!readSizeChunk(measureChunkPtr)) {
10952 measureChunks.push_back(measureChunkPtr);
10955 for (i = 0; i < measCount; ++i) {
10956 SizeChunk* conductChunkPtr =
new SizeChunk();
10958 if (!readChunkName(conductChunkPtr, Chunk::ConductName))
10961 if (!readSizeChunk(conductChunkPtr))
10964 conductChunks.push_back(conductChunkPtr);
10967 int bdatCount = ove_->getTrackCount() * measCount;
10968 for (i = 0; i < bdatCount; ++i) {
10969 SizeChunk* batChunkPtr =
new SizeChunk();
10971 if (!readChunkName(batChunkPtr, Chunk::BdatName)) {
10974 if (!readSizeChunk(batChunkPtr)) {
10978 bdatChunks.push_back(batChunkPtr);
10982 BarsParse barsParse(ove_);
10984 for (i = 0; i < (int) measureChunks.size(); ++i) {
10985 barsParse.addMeasure(measureChunks[i]);
10988 for (i = 0; i < (int) conductChunks.size(); ++i) {
10989 barsParse.addConduct(conductChunks[i]);
10992 for (i = 0; i < (int) bdatChunks.size(); ++i) {
10993 barsParse.addBdat(bdatChunks[i]);
10996 barsParse.setNotify(notify_);
10997 if (!barsParse.parse()) {
11004 bool OveSerialize::readOveEnd() {
11005 if (streamHandle_ == 0)
11008 const unsigned int END_OVE1 = 0xffffffff;
11009 const unsigned int END_OVE2 = 0x00000000;
11010 unsigned int buffer;
11012 if (!streamHandle_->read((
char*) &buffer,
sizeof(
unsigned int)))
11015 if (buffer != END_OVE1)
11018 if (!streamHandle_->read((
char*) &buffer,
sizeof(
unsigned int)))
11021 if (buffer != END_OVE2)
11028 bool OveSerialize::readNameBlock(NameBlock& nameBlock) {
11029 if (streamHandle_ == 0)
11032 if (!streamHandle_->read((
char*) nameBlock.data(), nameBlock.size()))
11038 bool OveSerialize::readChunkName(Chunk* ,
const QString& name) {
11039 if (streamHandle_ == 0)
11042 NameBlock nameBlock;
11044 if (!streamHandle_->read((
char*) nameBlock.data(), nameBlock.size()))
11047 if (!(nameBlock.toStrByteArray() == name))
11053 bool OveSerialize::readSizeChunk(SizeChunk* sizeChunk) {
11054 if (streamHandle_ == 0)
11057 SizeBlock* sizeBlock = sizeChunk->getSizeBlock();
11059 if (!streamHandle_->read((
char*) sizeBlock->data(), sizeBlock->size()))
11062 unsigned int blockSize = sizeBlock->toSize();
11064 sizeChunk->getDataBlock()->resize(blockSize);
11066 Block* dataBlock = sizeChunk->getDataBlock();
11068 if (!streamHandle_->read((
char*) dataBlock->data(), blockSize))
11074 bool OveSerialize::readDataChunk(Block* block,
unsigned int size) {
11075 if (streamHandle_ == 0)
11078 block->resize(size);
11080 if (!streamHandle_->read((
char*) block->data(), size))
11086 bool OveSerialize::readGroupChunk(GroupChunk* groupChunk) {
11087 if (streamHandle_ == 0)
11090 CountBlock* countBlock = groupChunk->getCountBlock();
11092 if (!streamHandle_->read((
char*) countBlock->data(), countBlock->size()))
11098 IOVEStreamLoader* createOveStreamLoader() {
11099 return new OveSerialize;
11121 class MeasureToTick {
11124 virtual ~MeasureToTick() {
11128 void build(OVE::OveSong* ove,
int quarter);
11137 numerator_(4), denominator_(4), measure_(0), tick_(0) {
11140 int getTick(
int measure,
int tickOffset);
11141 QList<TimeTick> getTimeTicks()
const;
11145 OVE::OveSong* ove_;
11147 QList<TimeTick> tts_;
11150 int getMeasureTick(
int quarter,
int num,
int den) {
11151 return quarter * 4 * num / den;
11154 MeasureToTick::MeasureToTick() {
11159 void MeasureToTick::build(OVE::OveSong* ove,
int quarter) {
11161 int currentTick = 0;
11162 unsigned int measureCount = ove->getMeasureCount();
11164 quarter_ = quarter;
11168 for (i = 0; i < measureCount; ++i) {
11169 OVE::Measure* measure = ove_->getMeasure(i);
11170 OVE::TimeSignature* time = measure->getTime();
11172 bool change =
false;
11174 tt.tick_ = currentTick;
11175 tt.numerator_ = time->getNumerator();
11176 tt.denominator_ = time->getDenominator();
11182 OVE::TimeSignature* previousTime = ove_->getMeasure(i - 1)->getTime();
11184 if (time->getNumerator() != previousTime->getNumerator()
11185 || time->getDenominator() != previousTime->getDenominator()) {
11191 tts_.push_back(tt);
11194 currentTick += getMeasureTick(quarter_, tt.numerator_, tt.denominator_);
11198 int MeasureToTick::getTick(
int measure,
int tickOffset) {
11202 for (i = 0; i < tts_.size(); ++i) {
11203 if (measure >= tts_[i].measure_ && (i == tts_.size() - 1 || measure < tts_[i + 1].measure_)) {
11204 int measuresTick = (measure - tts_[i].measure_) *
11205 getMeasureTick(quarter_, tts_[i].numerator_, tts_[i].denominator_);
11207 return tts_[i].tick_ + measuresTick + tickOffset;
11214 QList<MeasureToTick::TimeTick> MeasureToTick::getTimeTicks()
const {
11219 class QOve::QOvePrivate {
11251 d->ove.setTextCodecName(codec);
11260 QFile oveFile(fileName);
11261 bool success =
true;
11263 if (oveFile.open(QFile::ReadOnly)) {
11264 QByteArray buffer = oveFile.readAll();
11270 OVE::IOVEStreamLoader* oveLoader = OVE::createOveStreamLoader();
11272 oveLoader->setOve(&d->ove);
11273 oveLoader->setFileStream((
unsigned char*) buffer.data(), buffer.size());
11274 oveLoader->setNotify(0);
11275 bool result = oveLoader->load();
11276 oveLoader->release();
11288 "Cannot read this OVE file, " 11289 "probably because it has an incompatible format.\n" 11290 "Please, convert it using Overture 4 or a newer version.");
11294 void QOve::convertSong() {
11298 d->mtt.build(&d->ove, d->ove.getQuarter());
11302 convertSignatures();
11304 for (i = 0; i < (
unsigned int) d->ove.getPartCount(); ++i) {
11305 int partStaffCount = d->ove.getStaffCount(i);
11307 for (
int j = 0; j < partStaffCount; ++j) {
11308 OVE::Track* trackPtr = d->ove.getTrack(i, j);
11309 int transpose = trackPtr->getShowTranspose() ? trackPtr->getTranspose() : 0;
11311 convertTrackHeader(trackPtr, trackNo);
11314 int endMeasure = d->ove.getMeasureCount();
11315 int offsetTick = 0;
11317 for (
int l = 0; l < endMeasure; ++l) {
11318 OVE::Measure* measure = d->ove.getMeasure(l);
11319 OVE::MeasureData* measureData = d->ove.getMeasureData(i, j, l);
11325 convertMeasure(trackPtr, trackNo, trackPtr->getVoices(), measure, measureData, transpose, offsetTick);
11335 void QOve::convertSignatures() {
11337 int beginMeasure = 0;
11338 int endMeasure = d->ove.getMeasureCount();
11341 QMap<int, int> tempos;
11342 for (i = 0; i < d->ove.getPartCount(); ++i) {
11347 int partStaffCount = d->ove.getStaffCount(i);
11349 for (
int j = 0; j < partStaffCount; ++j) {
11354 for (
int k = beginMeasure; k < endMeasure; ++k) {
11355 OVE::Measure* measure = d->ove.getMeasure(k);
11356 OVE::MeasureData* measureData = d->ove.getMeasureData(i, j, k);
11357 QList<OVE::MusicData*> tempoPtrs = measureData->getMusicDatas(OVE::MusicData_Tempo);
11359 if (k == 0 || (k > 0 && std::abs(measure->getTypeTempo() - d->ove.getMeasure(k - 1)->getTypeTempo()) > 0.01)) {
11360 int tick = d->mtt.getTick(k, 0);
11361 int tempo = (int) measure->getTypeTempo();
11362 tempos[tick] = tempo;
11365 for (
int l = 0; l < tempoPtrs.size(); ++l) {
11366 OVE::Tempo* ptr =
static_cast<OVE::Tempo*
> (tempoPtrs[l]);
11367 int tick = d->mtt.getTick(measure->getBarNumber()->getIndex(), ptr->getTick());
11368 int tempo = ptr->getQuarterTempo() > 0 ? ptr->getQuarterTempo() : 1;
11370 tempos[tick] = tempo;
11376 QMap<int, int>::iterator it;
11378 for (it = tempos.begin(); it != tempos.end(); ++it) {
11379 if (it == tempos.begin() || it.value() != lastTempo) {
11383 lastTempo = it.value();
11387 const QList<MeasureToTick::TimeTick> tts = d->mtt.getTimeTicks();
11388 for (i = 0; i < (int) tts.size(); ++i) {
11389 if (beginMeasure <= tts[i].measure_ && endMeasure > tts[i].measure_) {
11390 Q_EMIT
signalOVETimeSig(tts[i].measure_, tts[i].tick_, tts[i].numerator_, tts[i].denominator_);
11395 bool createKey =
false;
11396 for (i = beginMeasure; i < endMeasure; ++i) {
11397 OVE::MeasureData* measureData = d->ove.getMeasureData(0, 0, i);
11399 if (measureData != NULL) {
11400 OVE::Key* keyPtr = measureData->getKey();
11402 if (i == 0 || keyPtr->getKey() != keyPtr->getPreviousKey()) {
11415 void QOve::convertTrackHeader(OVE::Track* track,
int trackNo) {
11417 const QList<OVE::Voice*> voices = track->getVoices();
11418 QMap<int, int> patches;
11419 QMap<int, int> pans;
11420 QMap<int, int> volumes;
11421 QMap<int, int>::iterator it;
11427 QString trackName = track->getName();
11430 for (i = 0; i < voices.size() && i < (
unsigned int)track->getVoiceCount(); ++i) {
11431 int patch = voices[i]->getPatch();
11432 int channel = voices[i]->getChannel();
11433 int volume = voices[i]->getVolume();
11435 if (patch != OVE::Voice::getDefaultPatch()) {
11436 patches[channel] = patch;
11439 pans[channel] = voices[i]->getPan();
11441 if (volume != OVE::Voice::getDefaultVolume()) {
11442 volumes[channel] = volume;
11450 for (it = patches.begin(); it != patches.end(); ++it) {
11451 patch = it.value();
11457 for (it = pans.begin(); it != pans.end(); ++it) {
11458 if (it.value() != 0 && it.value() != lastPan) {
11462 lastPan = it.value();
11466 for (it = volumes.begin(); it != volumes.end(); ++it) {
11467 int volume = it.value();
11468 if (volume != -1) {
11473 Q_EMIT
signalOVENewTrack(track->getName(), trackNo, ch, 0, vol, 0,
false,
false,
false);
11478 int getPitchShift(
const QList<OVE::Voice*>& voices,
int voice) {
11479 if (voice >= 0 && voice < (
int) voices.size())
11480 return voices[voice]->getPitchShift();
11484 int getChannel(
const QList<OVE::Voice*>& voices,
int voice) {
11485 if (voice >= 0 && voice < (
int) voices.size())
11486 return voices[voice]->getChannel();
11490 int getTick(
int tick) {
11496 void QOve::convertMeasure(
11497 OVE::Track* track,
int trackNo,
const QList<OVE::Voice*>& voices,
11498 OVE::Measure* measure, OVE::MeasureData* measureData,
int transpose,
int offsetTick)
11502 int measureId = measure->getBarNumber()->getIndex();
11503 QList<OVE::NoteContainer*> containers = measureData->getNoteContainers();
11506 for (i = 0; i < containers.size(); ++i) {
11507 OVE::NoteContainer* container = containers[i];
11508 int measureTick = d->mtt.getTick(measureId, 0);
11513 getChannel(voices, container->getVoice()),
11514 getPitchShift(voices, container->getVoice()) - transpose);
11518 QList<OVE::MidiData*> midiDatas = measureData->getMidiDatas(OVE::Midi_None);
11519 int channel = getChannel(voices, 0);
11521 for (i = 0; i < midiDatas.size(); ++i) {
11522 OVE::MidiType midiType = midiDatas[i]->getMidiType();
11523 int midiTick = getTick(d->mtt.getTick(measureId, midiDatas[i]->getTick()) + offsetTick);
11525 switch (midiType) {
11526 case OVE::Midi_Controller: {
11527 OVE::MidiController* controller =
static_cast<OVE::MidiController*
> (midiDatas[i]);
11529 Q_EMIT
signalOVECtlChange(trackNo, midiTick, channel, controller->getController(), controller->getValue());
11533 case OVE::Midi_Program_Change: {
11534 OVE::MidiProgramChange* program =
static_cast<OVE::MidiProgramChange*
> (midiDatas[i]);
11540 case OVE::Midi_Channel_Pressure: {
11541 OVE::MidiChannelPressure* pressure =
static_cast<OVE::MidiChannelPressure*
> (midiDatas[i]);
11547 case OVE::Midi_Pitch_Wheel: {
11548 OVE::MidiPitchWheel* pitchWheel =
static_cast<OVE::MidiPitchWheel*
> (midiDatas[i]);
11560 QList<OVE::MusicData*> musicDatas = measureData->getMusicDatas(OVE::MusicData_None);
11562 for (i = 0; i < musicDatas.size(); ++i) {
11563 OVE::MusicDataType type = musicDatas[i]->getMusicDataType();
11564 int musicDataTick = getTick(d->mtt.getTick(measureId, musicDatas[i]->getTick()) + offsetTick);
11567 case OVE::MusicData_Lyric: {
11568 OVE::Lyric* lyricPtr =
static_cast<OVE::Lyric*
> (musicDatas[i]);
11570 Q_EMIT
signalOVEText(trackNo, musicDataTick, lyricPtr->getLyric());
11574 case OVE::MusicData_Dynamics: {
11575 OVE::Dynamics* dynamicPtr =
static_cast<OVE::Dynamics*
> (musicDatas[i]);
11577 Q_EMIT
signalOVECtlChange(trackNo, musicDataTick, channel, 7, dynamicPtr->getVelocity());
11581 case OVE::MusicData_Decorator: {
11582 OVE::Decorator* decorator =
static_cast<OVE::Decorator*
> (musicDatas[i]);
11584 if (decorator->getDecoratorType() == OVE::Decorator::Decorator_Articulation) {
11585 OVE::ArticulationType artType = decorator->getArticulationType();
11588 case OVE::Articulation_Pedal_Down: {
11593 case OVE::Articulation_Pedal_Up: {
11611 bool hasNoteOn(
int pos) {
11612 return (pos & OVE::Tie_RightEnd) != OVE::Tie_RightEnd;
11615 bool hasNoteOff(
int pos) {
11616 return (pos & OVE::Tie_LeftEnd) != OVE::Tie_LeftEnd;
11619 int noteTypeToTick(OVE::NoteType type,
int quarter = 480) {
11620 int c = int(pow(2.0, (
int) type));
11621 return quarter * 4 * 2 / c;
11624 void QOve::convertNotes(
int trackNo,
int measureTick, OVE::NoteContainer* container,
int channel,
int pitchShift)
11626 if (container->getIsRest()) {
11633 QList<OVE::Note*> notes = container->getNotesRests();
11634 QList<OVE::Articulation*> articulations = container->getArticulations();
11635 bool changeNoteCount =
false;
11638 for (i = 0; i < articulations.size(); ++i) {
11639 OVE::Articulation* art = articulations[i];
11640 OVE::ArticulationType type = art->getArtType();
11642 for (j = 0; j < notes.size(); ++j) {
11643 OVE::Note* notePtr = notes[j];
11644 unsigned int velocityValue = notePtr->getOnVelocity();
11645 int noteValue = notePtr->getNote() + container->getNoteShift() + pitchShift;
11646 int startTick = measureTick + container->getTick() + notePtr->getOffsetTick();
11649 if (hasNoteOn(notePtr->getTiePos())) {
11652 case OVE::Articulation_Tremolo_Eighth:
11653 case OVE::Articulation_Tremolo_Sixteenth:
11654 case OVE::Articulation_Tremolo_Thirty_Second:
11655 case OVE::Articulation_Tremolo_Sixty_Fourth: {
11656 int noteCount = (int) pow(2.0, ((
int) type - (int) OVE::Articulation_Tremolo_Eighth) + 1);
11657 int noteTick = noteTypeToTick(container->getNoteType(), d->ove.getQuarter()) / noteCount;
11659 for (k = 0; k < noteCount; ++k) {
11661 int onTick = getTick(startTick + k * noteTick);
11663 Q_EMIT
signalOVENoteOn(trackNo, onTick, channel, noteValue, velocityValue);
11665 if (k < noteCount - 1 || hasNoteOff((
int) notePtr->getTiePos())) {
11667 int offTick = getTick(startTick + (k + 1) * noteTick);
11669 Q_EMIT signalOVENoteOff(trackNo, offTick, channel, noteValue, velocityValue);
11673 changeNoteCount =
true;
11684 if (changeNoteCount) {
11689 for (i = 0; i < notes.size(); ++i) {
11690 OVE::Note* notePtr = notes[i];
11691 unsigned int velocityValue = notePtr->getOnVelocity();
11692 int noteValue = notePtr->getNote() + container->getNoteShift() + pitchShift;
11694 int startTick = getTick(measureTick + container->getTick() + notePtr->getOffsetTick());
11695 int lengthTick = container->getLength();
11698 if (hasNoteOn((
int) notePtr->getTiePos())) {
11699 for (j = 0; j < articulations.size(); ++j) {
11700 OVE::Articulation* art = articulations[j];
11701 OVE::ArticulationType type = art->getArtType();
11703 if (art->getChangeLength()) {
11704 lengthTick = noteTypeToTick(container->getNoteType(), d->ove.getQuarter()) * art->getLengthPercentage() / 100;
11707 if (art->getChangeVelocity()) {
11708 switch (art->getVelocityType()) {
11709 case OVE::Articulation::Velocity_Offset: {
11710 velocityValue += art->getVelocityValue();
11713 case OVE::Articulation::Velocity_Percentage: {
11714 velocityValue *= (
unsigned int) ((
double) art->getVelocityValue() / (double) 100);
11717 case OVE::Articulation::Velocity_SetValue: {
11718 velocityValue = art->getVelocityValue();
11726 if (art->getChangeExtraLength()) {
11730 case OVE::Articulation_Pedal_Down: {
11735 case OVE::Articulation_Pedal_Up: {
11740 case OVE::Articulation_Arpeggio: {
11742 unsigned int soundEffect = std::abs(art->getSoundEffect().first) + std::abs(art->getSoundEffect().second);
11743 int tickAmount = (soundEffect / notes.size()) * ((notes.size() - i) - 1);
11744 startTick -= tickAmount;
11754 Q_EMIT
signalOVENoteOn(trackNo, getTick(startTick), channel, noteValue, velocityValue);
11758 if (hasNoteOff(notePtr->getTiePos())) {
11759 Q_EMIT signalOVENoteOff(trackNo, getTick(startTick + lengthTick), channel, noteValue, velocityValue);
void setTextCodecName(const QString &codec)
Sets the text codec for text meta-events.
void signalOVETimeSig(int bar, long tick, int num, int den)
Emitted after reading a Time signature.
void signalOVENewTrack(const QString &name, int track, int channel, int pitch, int velocity, int port, bool selected, bool muted, bool loop)
Emitted after reading a new track prefix.
void signalOVEKeySig(int bar, long tick, int alt)
Emitted after reading a Key Signature.
void signalOVENoteOn(int track, long tick, int channel, int pitch, int vol)
Emitted after reading a Note message.
void signalOVETrackPatch(int track, int channel, int patch)
Emitted after reading a track patch chunk.
void signalOVETempo(long tick, int tempo)
Emitted after reading a Tempo Change message.
virtual ~QOve()
Destructor.
The QObject class is the base class of all Qt objects.
void signalOVEText(int track, long tick, const QString &data)
Emitted after reading a text message.
void signalOVEChanPress(int track, long tick, int channel, int press)
Emitted after reading a Channel Aftertouch message.
QOve(QObject *parent=0)
Constructor.
void signalOVEHeader(int quarter, int trackCount)
Emitted after reading a WRK header.
void signalOVEProgram(int track, long tick, int channel, int patch)
Emitted after reading a Program change message.
void start(Priority priority=InheritPriority)
Starts the playback thread.
void signalOVETrackBank(int track, int channel, int bank)
Emitted after reading a track bank chunk.
Overture OVE Files Input.
void signalOVEPitchBend(int track, long tick, int channel, int value)
Emitted after reading a Bender message.
void signalOVEError(const QString &errorStr)
Emitted for a OVE file read error.
void readFromFile(const QString &fileName)
Reads an Overture file.
void signalOVECtlChange(int track, long tick, int channel, int ctl, int value)
Emitted after reading a Control Change message.
void signalOVEEnd()
Emitted after reading the last chunk of a OVE file.
virtual void stop()
Stops playing the current sequence.