25 #include <QStringList> 70 class MultiMeasureRest;
72 class OctaveShiftEndPoint;
82 class MidiProgramChange;
83 class MidiChannelPressure;
86 const int TWELVE_TONE = 12 ;
87 const int INVALID_NOTE = -1 ;
88 const int OCTAVE = 7 ;
91 Cond_Time_Parameters = 0x09,
92 Cond_Bar_Number = 0x0A,
93 Cond_Decorator = 0x16,
96 Cond_Expression = 0x25,
97 Cond_Barline_Parameters = 0x30,
99 Cond_Numeric_Ending = 0x32,
105 Bdat_Raw_Note = 0x70,
111 Bdat_Dynamics = 0x13,
113 Bdat_Glissando = 0x15,
114 Bdat_Decorator = 0x16,
117 Bdat_Octave_Shift = 0x19,
122 Bdat_Guitar_Bend = 0x21,
123 Bdat_Guitar_Barre = 0x22,
126 Bdat_Expressions = 0x25,
127 Bdat_Harp_Pedal = 0x26,
128 Bdat_Multi_Measure_Rest = 0x27,
129 Bdat_Harmony_GuitarFrame = 0x28,
130 Bdat_Graphics_40 = 0x40,
131 Bdat_Graphics_RoundRect = 0x41,
132 Bdat_Graphics_Rect = 0x42,
133 Bdat_Graphics_Round = 0x43,
134 Bdat_Graphics_Line = 0x44,
135 Bdat_Graphics_Curve = 0x45,
136 Bdat_Graphics_WedgeSymbol = 0x46,
137 Bdat_Midi_Controller = 0xAB,
138 Bdat_Midi_Program_Change = 0xAC,
139 Bdat_Midi_Channel_Pressure = 0xAD,
140 Bdat_Midi_Pitch_Wheel = 0xAE,
152 MusicData_Measure_Repeat,
160 MusicData_Wedge_EndPoint,
161 MusicData_OctaveShift,
162 MusicData_OctaveShift_EndPoint,
163 MusicData_Expressions,
166 MusicData_Harp_Pedal,
170 MusicData_Note_Container,
182 MusicData_Numeric_Ending,
187 MusicData_Multi_Measure_Rest,
195 Midi_Channel_Pressure,
224 enum AccidentalType {
225 Accidental_Normal = 0x0,
226 Accidental_Sharp = 0x1,
227 Accidental_Flat = 0x2,
228 Accidental_Natural = 0x3,
229 Accidental_DoubleSharp = 0x4,
230 Accidental_DoubleFlat = 0x5,
231 Accidental_Sharp_Caution = 0x9,
232 Accidental_Flat_Caution = 0xA,
233 Accidental_Natural_Caution = 0xB,
234 Accidental_DoubleSharp_Caution = 0xC,
235 Accidental_DoubleFlat_Caution = 0xD
239 NoteHead_Standard = 0x00,
241 NoteHead_Rhythmic_Slash,
243 NoteHead_Closed_Rhythm,
244 NoteHead_Open_Rhythm,
245 NoteHead_Closed_Slash,
269 enum ArticulationType {
270 Articulation_Major_Trill = 0x00,
271 Articulation_Minor_Trill = 0x01,
272 Articulation_Trill_Section = 0x02,
273 Articulation_Inverted_Short_Mordent = 0x03,
274 Articulation_Inverted_Long_Mordent = 0x04,
275 Articulation_Short_Mordent = 0x05,
276 Articulation_Turn = 0x06,
277 Articulation_Finger_1 = 0x07,
278 Articulation_Finger_2 = 0x08,
279 Articulation_Finger_3 = 0x09,
280 Articulation_Finger_4 = 0x0A,
281 Articulation_Finger_5 = 0x0B,
282 Articulation_Flat_Accidental_For_Trill = 0x0C,
283 Articulation_Sharp_Accidental_For_Trill = 0x0D,
284 Articulation_Natural_Accidental_For_Trill = 0x0E,
285 Articulation_Marcato = 0x0F,
286 Articulation_Marcato_Dot = 0x10,
287 Articulation_Heavy_Attack = 0x11,
288 Articulation_SForzando = 0x12,
289 Articulation_SForzando_Dot = 0x13,
290 Articulation_Heavier_Attack = 0x14,
291 Articulation_SForzando_Inverted = 0x15,
292 Articulation_SForzando_Dot_Inverted = 0x16,
293 Articulation_Staccatissimo = 0x17,
294 Articulation_Staccato = 0x18,
295 Articulation_Tenuto = 0x19,
296 Articulation_Up_Bow = 0x1A,
297 Articulation_Down_Bow = 0x1B,
298 Articulation_Up_Bow_Inverted = 0x1C,
299 Articulation_Down_Bow_Inverted = 0x1D,
300 Articulation_Arpeggio = 0x1E,
301 Articulation_Tremolo_Eighth = 0x1F,
302 Articulation_Tremolo_Sixteenth = 0x20,
303 Articulation_Tremolo_Thirty_Second = 0x21,
304 Articulation_Tremolo_Sixty_Fourth = 0x22,
305 Articulation_Natural_Harmonic = 0x23,
306 Articulation_Artificial_Harmonic = 0x24,
307 Articulation_Plus_Sign = 0x25,
308 Articulation_Fermata = 0x26,
309 Articulation_Fermata_Inverted = 0x27,
310 Articulation_Pedal_Down = 0x28,
311 Articulation_Pedal_Up = 0x29,
312 Articulation_Pause = 0x2A,
313 Articulation_Grand_Pause = 0x2B,
314 Articulation_Toe_Pedal = 0x2C,
315 Articulation_Heel_Pedal = 0x2D,
316 Articulation_Toe_To_Heel_Pedal = 0x2E,
317 Articulation_Heel_To_Toe_Pedal = 0x2F,
318 Articulation_Open_String = 0x30,
319 Articulation_Guitar_Lift = 0x46,
320 Articulation_Guitar_Slide_Up = 0x47,
321 Articulation_Guitar_Rip = 0x48,
322 Articulation_Guitar_Fall_Off = 0x49,
323 Articulation_Guitar_Slide_Down = 0x4A,
324 Articulation_Guitar_Spill = 0x4B,
325 Articulation_Guitar_Flip = 0x4C,
326 Articulation_Guitar_Smear = 0x4D,
327 Articulation_Guitar_Bend = 0x4E,
328 Articulation_Guitar_Doit = 0x4F,
329 Articulation_Guitar_Plop = 0x50,
330 Articulation_Guitar_Wow_Wow = 0x51,
331 Articulation_Guitar_Thumb = 0x64,
332 Articulation_Guitar_Index_Finger = 0x65,
333 Articulation_Guitar_Middle_Finger = 0x66,
334 Articulation_Guitar_Ring_Finger = 0x67,
335 Articulation_Guitar_Pinky_Finger = 0x68,
336 Articulation_Guitar_Tap = 0x69,
337 Articulation_Guitar_Hammer = 0x6A,
338 Articulation_Guitar_Pluck = 0x6B,
353 Note_DoubleWhole= 0x0,
367 inline int NoteTypeToTick(NoteType type,
int quarter) {
368 int c = int(pow(2.0, (
int)type)) ;
369 return quarter * 4 * 2 / c ;
475 KuoHao_Parentheses = 0,
480 enum OctaveShiftType {
487 enum OctaveShiftPosition {
488 OctavePosition_Start = 0 ,
489 OctavePosition_Continue,
517 NoteDuration_256 = 15,
518 NoteDuration_128 = NoteDuration_256 * 2,
519 NoteDuration_64 = NoteDuration_128 * 2,
520 NoteDuration_32 = NoteDuration_64 * 2,
521 NoteDuration_16 = NoteDuration_32 * 2,
522 NoteDuration_8 = NoteDuration_16 * 2,
523 NoteDuration_4 = NoteDuration_8 * 2,
524 NoteDuration_2 = NoteDuration_4 * 2,
525 NoteDuration_Whole = NoteDuration_2 * 2,
526 NoteDuration_Double_Whole = NoteDuration_Whole * 2
561 virtual ~IOveNotify() {}
564 virtual void loadInfo(
const QString& info) = 0;
565 virtual void loadError() = 0;
566 virtual void loadPosition(
int currentMeasure,
int totalMeasure,
int currentTrack,
int totalTrack) = 0;
569 class IOVEStreamLoader {
571 IOVEStreamLoader() {}
572 virtual ~IOVEStreamLoader() {}
575 virtual void setNotify(IOveNotify* notify) = 0;
576 virtual void setFileStream(
unsigned char* buffer,
unsigned int size) = 0;
577 virtual void setOve(OveSong* ove) = 0;
580 virtual bool load() = 0;
582 virtual void release() = 0;
585 IOVEStreamLoader* createOveStreamLoader();
592 virtual ~TickElement() {}
595 void setTick(
int tick);
596 int getTick(
void)
const;
605 virtual ~MeasurePos() {}
608 void setMeasure(
int measure);
609 int getMeasure()
const;
611 void setOffset(
int offset);
612 int getOffset()
const;
614 MeasurePos shiftMeasure(
int measure)
const;
615 MeasurePos shiftOffset(
int offset)
const;
617 bool operator ==(
const MeasurePos& mp)
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;
632 virtual ~PairElement();
635 MeasurePos* start()
const;
636 MeasurePos* stop()
const;
649 LineElement* getLeftLine()
const;
650 LineElement* getRightLine()
const;
652 OffsetElement* getLeftShoulder()
const;
653 OffsetElement* getRightShoulder()
const;
656 LineElement* leftLine_;
657 LineElement* rightLine_;
658 OffsetElement* leftShoulder_;
659 OffsetElement* rightShoulder_;
665 virtual ~LineElement() {}
668 virtual void setLine(
int line);
669 virtual int getLine(
void)
const;
675 class OffsetElement {
678 virtual ~OffsetElement() {}
681 virtual void setXOffset(
int offset);
682 virtual int getXOffset()
const;
684 virtual void setYOffset(
int offset);
685 virtual int getYOffset()
const;
692 class LengthElement {
695 virtual ~LengthElement() {}
698 void setLength(
int length);
699 int getLength()
const;
706 class MusicData:
public TickElement,
public PairElement,
public OffsetElement {
709 virtual ~MusicData() {}
712 MusicDataType getMusicDataType()
const;
715 Attributes = 0, NoteBeam, Notations, Direction, None
717 static XmlDataType getXmlDataType(MusicDataType type);
721 void setShow(
bool show);
722 bool getShow()
const;
725 void setColor(
unsigned int color);
726 unsigned int getColor()
const;
728 void setVoice(
unsigned int voice);
729 unsigned int getVoice()
const;
731 void copyCommonBlock(
const MusicData& source);
734 MusicDataType musicDataType_;
742 class MidiData:
public TickElement {
745 virtual ~MidiData() {}
748 MidiType getMidiType()
const;
762 void setIsVersion4(
bool version4 =
true);
763 bool getIsVersion4()
const;
765 void setQuarter(
int tick);
766 int getQuarter(
void)
const;
768 void setShowPageMargin(
bool show);
769 bool getShowPageMargin()
const;
771 void setShowTransposeTrack(
bool show);
772 bool getShowTransposeTrack()
const;
774 void setShowLineBreak(
bool show);
775 bool getShowLineBreak()
const;
777 void setShowRuler(
bool show);
778 bool getShowRuler()
const;
780 void setShowColor(
bool show);
781 bool getShowColor()
const;
783 void setPlayRepeat(
bool play);
784 bool getPlayRepeat()
const;
787 Record, Swing, Notation
789 void setPlayStyle(PlayStyle style);
790 PlayStyle getPlayStyle()
const;
792 void addTitle(
const QString& str);
793 QList<QString> getTitles(
void)
const;
795 void addAnnotate(
const QString& str);
796 QList<QString> getAnnotates(
void)
const;
798 void addWriter(
const QString& str);
799 QList<QString> getWriters(
void)
const;
801 void addCopyright(
const QString& str);
802 QList<QString> getCopyrights(
void)
const;
804 void addHeader(
const QString& str);
805 QList<QString> getHeaders(
void)
const;
807 void addFooter(
const QString& str);
808 QList<QString> getFooters(
void)
const;
810 void addTrack(Track* ptr);
811 int getTrackCount(
void)
const;
812 QList<Track*> getTracks()
const;
813 Track* getTrack(
int part,
int staff)
const;
815 void setTrackBarCount(
int count);
816 int getTrackBarCount()
const;
818 bool addPage(Page* page);
819 int getPageCount()
const;
820 Page* getPage(
int idx);
822 void addLine(Line* ptr);
823 int getLineCount()
const;
824 Line* getLine(
int idx)
const;
826 void addMeasure(Measure* ptr);
827 int getMeasureCount(
void)
const;
828 Measure* getMeasure(
int bar)
const;
830 void addMeasureData(MeasureData* ptr);
831 int getMeasureDataCount(
void)
const;
832 MeasureData* getMeasureData(
int part,
int staff,
int bar)
const;
833 MeasureData* getMeasureData(
int track,
int bar)
const;
836 void setPartStaffCounts(
const QList<int>& partStaffCounts);
837 int getPartCount()
const;
838 int getStaffCount(
int part)
const;
839 int getPartBarCount()
const;
843 QPair<int, int> trackToPartStaff(
int track)
const;
845 void setTextCodecName(
const QString& codecName);
846 QString getCodecString(
const QByteArray& text);
849 int partStaffToTrack(
int part,
int staff)
const;
855 bool showPageMargin_;
856 bool showTransposeTrack;
861 PlayStyle playStyle_;
863 QList<QString> titles_;
864 QList<QString> annotates_;
865 QList<QString> writers_;
866 QList<QString> copyrights_;
867 QList<QString> headers_;
868 QList<QString> footers_;
870 QList<Track*> tracks_;
873 QList<Measure*> measures_;
874 QList<MeasureData*> measureDatas_;
877 QList<int> partStaffCounts_;
887 void setChannel(
int channel);
888 int getChannel()
const;
890 void setVolume(
int volume);
891 int getVolume()
const;
893 void setPitchShift(
int pitchShift);
894 int getPitchShift()
const;
896 void setPan(
int pan);
899 void setPatch(
int patch);
900 int getPatch()
const;
902 void setStemType(
int stemType);
903 int getStemType()
const;
905 static int getDefaultPatch();
906 static int getDefaultVolume();
923 void setName(
const QString& str);
924 QString getName(
void)
const;
926 void setBriefName(
const QString& str);
927 QString getBriefName(
void)
const;
929 void setPatch(
unsigned int patch);
930 unsigned int getPatch()
const;
932 void setChannel(
int channel);
933 int getChannel()
const;
935 void setShowName(
bool show);
936 bool getShowName()
const;
938 void setShowBriefName(
bool show);
939 bool getShowBriefName()
const;
941 void setMute(
bool mute);
942 bool getMute()
const;
944 void setSolo(
bool solo);
945 bool getSolo()
const;
947 void setShowKeyEachLine(
bool show);
948 bool getShowKeyEachLine()
const;
950 void setVoiceCount(
int voices);
951 int getVoiceCount()
const;
953 void addVoice(Voice* voice);
954 QList<Voice*> getVoices()
const;
956 void setShowTranspose(
bool show);
957 bool getShowTranspose()
const;
959 void setTranspose(
int transpose);
960 int getTranspose()
const;
962 void setNoteShift(
int shift);
963 int getNoteShift()
const;
965 void setStartClef(
int clef);
966 ClefType getStartClef()
const;
968 void setTransposeClef(
int clef);
969 int getTansposeClef()
const;
971 void setStartKey(
int key);
972 int getStartKey()
const;
974 void setDisplayPercent(
unsigned int percent);
975 unsigned int getDisplayPercent()
const;
977 void setShowLegerLine(
bool show);
978 bool getShowLegerLine()
const;
980 void setShowClef(
bool show);
981 bool getShowClef()
const;
983 void setShowTimeSignature(
bool show);
984 bool getShowTimeSignature()
const;
986 void setShowKeySignature(
bool show);
987 bool getShowKeySignature()
const;
989 void setShowBarline(
bool show);
990 bool getShowBarline()
const;
992 void setFillWithRest(
bool fill);
993 bool getFillWithRest()
const;
995 void setFlatTail(
bool flat);
996 bool getFlatTail()
const;
998 void setShowClefEachLine(
bool show);
999 bool getShowClefEachLine()
const;
1008 DrumNode():line_(0), headType_(0), pitch_(0), voice_(0){}
1010 void addDrum(
const DrumNode& node);
1011 QList<DrumNode> getDrumKit()
const;
1016 void setPart(
int part);
1017 int getPart()
const;
1023 unsigned int patch_;
1026 bool showTranspose_;
1030 unsigned int displayPercent_;
1033 QList<Voice*> voices_;
1036 bool showBriefName_;
1037 bool showKeyEachLine_;
1038 bool showLegerLine_;
1040 bool showTimeSignature_;
1041 bool showKeySignature_;
1043 bool showClefEachLine_;
1051 QList<DrumNode> drumKit_;
1063 void setBeginLine(
int line);
1064 int getBeginLine()
const;
1066 void setLineCount(
int count);
1067 int getLineCount()
const;
1069 void setLineInterval(
int interval);
1070 int getLineInterval()
const;
1072 void setStaffInterval(
int interval);
1073 int getStaffInterval()
const;
1075 void setStaffInlineInterval(
int interval);
1076 int getStaffInlineInterval()
const;
1078 void setLineBarCount(
int count);
1079 int getLineBarCount()
const;
1081 void setPageLineCount(
int count);
1082 int getPageLineCount()
const;
1084 void setLeftMargin(
int margin);
1085 int getLeftMargin()
const;
1087 void setTopMargin(
int margin);
1088 int getTopMargin()
const;
1090 void setRightMargin(
int margin);
1091 int getRightMargin()
const;
1093 void setBottomMargin(
int margin);
1094 int getBottomMargin()
const;
1096 void setPageWidth(
int width);
1097 int getPageWidth()
const;
1099 void setPageHeight(
int height);
1100 int getPageHeight()
const;
1108 int staffInlineInterval_;
1128 void addStaff(Staff* staff);
1129 int getStaffCount()
const;
1130 Staff* getStaff(
int idx)
const;
1132 void setBeginBar(
unsigned int bar);
1133 unsigned int getBeginBar()
const;
1135 void setBarCount(
unsigned int count);
1136 unsigned int getBarCount()
const;
1138 void setYOffset(
int offset);
1139 int getYOffset()
const;
1141 void setLeftXOffset(
int offset);
1142 int getLeftXOffset()
const;
1144 void setRightXOffset(
int offset);
1145 int getRightXOffset()
const;
1148 QList<Staff*> staffs_;
1149 unsigned int beginBar_;
1150 unsigned int barCount_;
1156 class Staff :
public OffsetElement {
1162 void setClefType(
int clef);
1163 ClefType getClefType()
const;
1165 void setKeyType(
int key);
1166 int getKeyType()
const;
1168 void setVisible(
bool visible);
1169 bool setVisible()
const;
1171 void setGroupType(GroupType type);
1172 GroupType getGroupType()
const;
1174 void setGroupStaffCount(
int count);
1175 int getGroupStaffCount()
const;
1181 GroupType groupType_;
1182 int groupStaffCount_;
1187 class Note :
public LineElement {
1193 void setIsRest(
bool rest);
1194 bool getIsRest()
const;
1196 void setNote(
unsigned int note);
1197 unsigned int getNote()
const;
1199 void setAccidental(
int type);
1200 AccidentalType getAccidental()
const;
1202 void setShowAccidental(
bool show);
1203 bool getShowAccidental()
const;
1205 void setOnVelocity(
unsigned int velocity);
1206 unsigned int getOnVelocity()
const;
1208 void setOffVelocity(
unsigned int velocity);
1209 unsigned int getOffVelocity()
const;
1211 void setHeadType(
int type);
1212 NoteHeadType getHeadType()
const;
1214 void setTiePos(
int tiePos);
1215 TiePos getTiePos()
const;
1217 void setOffsetStaff(
int offset);
1218 int getOffsetStaff()
const;
1220 void setShow(
bool show);
1221 bool getShow()
const;
1223 void setOffsetTick(
int offset);
1224 int getOffsetTick()
const;
1229 AccidentalType accidental_;
1230 bool showAccidental_;
1231 unsigned int onVelocity_;
1232 unsigned int offVelocity_;
1233 NoteHeadType headType_;
1240 class Articulation :
public OffsetElement {
1243 virtual ~Articulation(){}
1246 void setArtType(
int type);
1247 ArticulationType getArtType()
const;
1249 void setPlacementAbove(
bool above);
1250 bool getPlacementAbove()
const;
1253 bool willAffectNotes()
const;
1255 static bool isTrill(ArticulationType type);
1268 XmlType getXmlType()
const;
1271 bool getChangeSoundEffect()
const;
1272 void setSoundEffect(
int soundFrom,
int soundTo);
1273 QPair<int, int> getSoundEffect()
const;
1275 bool getChangeLength()
const;
1276 void setLengthPercentage(
int percentage);
1277 int getLengthPercentage()
const;
1279 bool getChangeVelocity()
const;
1286 void setVelocityType(VelocityType type);
1287 VelocityType getVelocityType()
const;
1289 void setVelocityValue(
int value);
1290 int getVelocityValue()
const;
1292 bool getChangeExtraLength()
const;
1293 void setExtraLength(
int length);
1294 int getExtraLength()
const;
1297 enum TrillInterval {
1298 TrillInterval_Diatonic = 0,
1299 TrillInterval_Chromatic,
1302 void setTrillInterval(
int interval);
1303 TrillInterval getTrillInterval()
const;
1305 void setAuxiliaryFirst(
bool first);
1306 bool getAuxiliaryFirst()
const;
1308 void setTrillRate(NoteType rate);
1309 NoteType getTrillRate()
const;
1311 void setTrillNoteLength(
int length);
1312 int getTrillNoteLength()
const;
1314 enum AccelerateType {
1315 Accelerate_None = 0 ,
1320 void setAccelerateType(
int type);
1321 AccelerateType getAccelerateType()
const;
1324 ArticulationType type_;
1327 bool changeSoundEffect_;
1328 QPair<int, int> soundEffect_;
1330 int lengthPercentage_;
1331 bool changeVelocity_;
1332 VelocityType velocityType_;
1334 bool changeExtraLength_;
1338 TrillInterval trillInterval_;
1339 bool auxiliaryFirst_;
1340 NoteType trillRate_;
1341 int trillNoteLength_;
1342 AccelerateType accelerateType_;
1345 class NoteContainer :
public MusicData,
public LengthElement {
1348 virtual ~NoteContainer();
1351 void setIsGrace(
bool grace);
1352 bool getIsGrace()
const;
1354 void setIsCue(
bool cue);
1355 bool getIsCue()
const;
1357 void setIsRest(
bool rest);
1358 bool getIsRest()
const;
1360 void setIsRaw(
bool raw);
1361 bool getIsRaw()
const;
1363 void setNoteType(NoteType type);
1364 NoteType getNoteType()
const;
1366 void setDot(
int dot);
1369 void setGraceNoteType(NoteType type);
1370 NoteType getGraceNoteType()
const;
1372 void setInBeam(
bool in);
1373 bool getInBeam()
const;
1375 void setStemUp(
bool up);
1376 bool getStemUp(
void)
const;
1378 void setShowStem(
bool show);
1379 bool getShowStem()
const;
1381 void setStemLength(
int line);
1382 int getStemLength()
const;
1384 void setTuplet(
int tuplet);
1385 int getTuplet()
const;
1387 void setSpace(
int space);
1388 int getSpace()
const;
1390 void addNoteRest(Note* note);
1391 QList<Note*> getNotesRests()
const;
1393 void addArticulation(Articulation* art);
1394 QList<Articulation*> getArticulations()
const;
1396 void setNoteShift(
int octave);
1397 int getNoteShift()
const;
1399 int getOffsetStaff()
const;
1401 int getDuration()
const;
1410 NoteType graceNoteType_;
1419 QList<Note*> notes_;
1420 QList<Articulation*> articulations_;
1423 class Beam :
public MusicData,
public PairEnds {
1429 void setIsGrace(
bool grace);
1430 bool getIsGrace()
const;
1432 void addLine(
const MeasurePos& startMp,
const MeasurePos& endMp);
1433 const QList<QPair<MeasurePos, MeasurePos> > getLines()
const;
1437 QList<QPair<MeasurePos, MeasurePos> > lines_;
1440 class Tie :
public MusicData,
public PairEnds {
1446 void setShowOnTop(
bool top);
1447 bool getShowOnTop()
const;
1449 void setNote(
int note);
1450 int getNote()
const;
1452 void setHeight(
int height);
1453 int getHeight()
const;
1461 class Glissando :
public MusicData,
public PairEnds {
1464 virtual ~Glissando(){}
1467 void setStraightWavy(
bool straight);
1468 bool getStraightWavy()
const;
1470 void setText(
const QString& text);
1471 QString getText()
const;
1473 void setLineThick(
int thick);
1474 int getLineThick()
const;
1482 class Decorator :
public MusicData {
1485 virtual ~Decorator(){}
1488 enum DecoratorType {
1489 Decorator_Dotted_Barline = 0,
1490 Decorator_Articulation
1492 void setDecoratorType(DecoratorType type);
1493 DecoratorType getDecoratorType()
const;
1495 void setArticulationType(ArticulationType type);
1496 ArticulationType getArticulationType()
const;
1499 DecoratorType decoratorType_;
1500 ArticulationType artType_;
1503 class MeasureRepeat :
public MusicData {
1506 virtual ~MeasureRepeat(){}
1509 void setSingleRepeat(
bool single);
1510 bool getSingleRepeat()
const;
1516 class Tuplet :
public MusicData,
public PairEnds {
1522 void setTuplet(
int tuplet=3);
1523 int getTuplet()
const;
1525 void setSpace(
int space=2);
1526 int getSpace()
const;
1528 void setHeight(
int height);
1529 int getHeight()
const;
1531 void setNoteType(NoteType type);
1532 NoteType getNoteType()
const;
1534 OffsetElement* getMarkHandle()
const;
1541 OffsetElement* mark_;
1544 class Harmony :
public MusicData,
public LengthElement {
1547 virtual ~Harmony(){}
1550 void setHarmonyType(HarmonyType type);
1551 HarmonyType getHarmonyType()
const;
1553 void setRoot(
int root=0);
1554 int getRoot()
const;
1556 void setBass(
int bass);
1557 int getBass()
const;
1559 void setBassOnBottom(
bool on);
1560 bool getBassOnBottom()
const;
1562 void setAngle(
int angle);
1563 int getAngle()
const;
1566 HarmonyType harmonyType_;
1573 class Clef :
public MusicData,
public LineElement {
1579 void setClefType(
int type);
1580 ClefType getClefType()
const;
1586 class Lyric :
public MusicData {
1592 void setLyric(
const QString& lyricText);
1593 QString getLyric()
const;
1595 void setVerse(
int verse);
1596 int getVerse()
const;
1603 class Slur:
public MusicData,
public PairEnds {
1609 void setContainerCount(
int count);
1610 int getContainerCount()
const;
1612 void setShowOnTop(
bool top);
1613 bool getShowOnTop()
const;
1615 OffsetElement* getHandle2()
const;
1616 OffsetElement* getHandle3()
const;
1618 void setNoteTimePercent(
int percent);
1619 int getNoteTimePercent()
const;
1622 int containerCount_;
1624 int noteTimePercent_;
1625 OffsetElement* handle_2_;
1626 OffsetElement* handle_3_;
1629 class Dynamics:
public MusicData {
1632 virtual ~Dynamics() {}
1635 void setDynamicsType(
int type);
1636 DynamicsType getDynamicsType()
const;
1638 void setIsPlayback(
bool play);
1639 bool getIsPlayback()
const;
1641 void setVelocity(
int vel);
1642 int getVelocity()
const;
1645 DynamicsType dynamicsType_;
1650 class WedgeEndPoint:
public MusicData {
1653 virtual ~WedgeEndPoint() {}
1656 void setWedgeType(WedgeType type);
1657 WedgeType getWedgeType()
const;
1659 void setHeight(
int height);
1660 int getHeight()
const;
1662 void setWedgeStart(
bool wedgeStart);
1663 bool getWedgeStart()
const;
1667 WedgeType wedgeType_;
1671 class Wedge:
public MusicData {
1677 void setWedgeType(WedgeType type);
1678 WedgeType getWedgeType()
const;
1680 void setHeight(
int height);
1681 int getHeight()
const;
1685 WedgeType wedgeType_;
1688 class Pedal:
public MusicData,
public PairEnds {
1694 void setHalf(
bool half);
1695 bool getHalf()
const;
1697 void setIsPlayback(
bool playback);
1698 bool getIsPlayback()
const;
1700 void setPlayOffset(
int offset);
1701 int getPlayOffset()
const;
1703 OffsetElement* getPedalHandle()
const;
1709 OffsetElement* pedalHandle_;
1712 class KuoHao:
public MusicData,
public PairEnds {
1715 virtual ~KuoHao() {}
1718 void setHeight(
int height);
1719 int getHeight()
const;
1721 void setKuohaoType(
int type);
1722 KuoHaoType getKuohaoType()
const;
1726 KuoHaoType kuohaoType_;
1729 class Expressions:
public MusicData {
1732 virtual ~Expressions() {}
1735 void setText(
const QString& str);
1736 QString getText()
const;
1742 class HarpPedal:
public MusicData {
1745 virtual ~HarpPedal() {}
1748 void setShowType(
int type);
1749 int getShowType()
const;
1751 void setShowCharFlag(
int flag);
1752 int getShowCharFlag()
const;
1759 class OctaveShift:
public MusicData,
public LengthElement {
1762 virtual ~OctaveShift() {}
1765 void setOctaveShiftType(
int type);
1766 OctaveShiftType getOctaveShiftType()
const;
1768 int getNoteShift()
const;
1770 void setEndTick(
int tick);
1771 int getEndTick()
const;
1774 OctaveShiftType octaveShiftType_;
1775 OctaveShiftPosition octaveShiftPosition_;
1779 class OctaveShiftEndPoint:
public MusicData,
public LengthElement {
1781 OctaveShiftEndPoint();
1782 virtual ~OctaveShiftEndPoint() {}
1785 void setOctaveShiftType(
int type);
1786 OctaveShiftType getOctaveShiftType()
const;
1788 void setOctaveShiftPosition(
int position);
1789 OctaveShiftPosition getOctaveShiftPosition()
const;
1791 void setEndTick(
int tick);
1792 int getEndTick()
const;
1795 OctaveShiftType octaveShiftType_;
1796 OctaveShiftPosition octaveShiftPosition_;
1800 class MultiMeasureRest:
public MusicData {
1803 virtual ~MultiMeasureRest() {}
1806 void setMeasureCount(
int count);
1807 int getMeasureCount()
const;
1813 class Tempo:
public MusicData {
1819 void setLeftNoteType(
int type);
1820 NoteType getLeftNoteType()
const;
1822 void setShowMark(
bool show);
1823 bool getShowMark()
const;
1825 void setShowBeforeText(
bool show);
1826 bool getShowBeforeText()
const;
1828 void setShowParenthesis(
bool show);
1829 bool getShowParenthesis()
const;
1831 void setTypeTempo(
int tempo);
1832 int getTypeTempo()
const;
1833 int getQuarterTempo()
const;
1835 void setLeftText(
const QString& str);
1836 QString getLeftText()
const;
1838 void setRightText(
const QString& str);
1839 QString getRightText()
const;
1841 void setSwingEighth(
bool swing);
1842 bool getSwingEighth()
const;
1844 void setRightNoteType(
int type);
1845 int getRightNoteType()
const;
1851 bool showParenthesis_;
1859 class Text:
public MusicData,
public LengthElement {
1871 void setTextType(TextType type);
1872 TextType getTextType()
const;
1874 void setHorizontalMargin(
int margin);
1875 int getHorizontalMargin()
const;
1877 void setVerticalMargin(
int margin);
1878 int getVerticalMargin()
const;
1880 void setLineThick(
int thick);
1881 int getLineThick()
const;
1883 void setText(
const QString& text);
1884 QString getText()
const;
1886 void setWidth(
int width);
1887 int getWidth()
const;
1889 void setHeight(
int height);
1890 int getHeight()
const;
1904 class TimeSignature:
public MusicData {
1907 virtual ~TimeSignature() {}
1910 void setNumerator(
int numerator);
1911 int getNumerator()
const;
1913 void setDenominator(
int denominator);
1914 int getDenominator()
const;
1916 void setIsSymbol(
bool symbol);
1917 bool getIsSymbol()
const;
1919 void setBeatLength(
int length);
1920 int getBeatLength()
const;
1922 void setBarLength(
int length);
1923 int getBarLength()
const;
1925 void addBeat(
int startUnit,
int lengthUnit,
int startTick);
1927 int getUnits()
const;
1929 void setReplaceFont(
bool replace);
1930 bool getReplaceFont()
const;
1932 void setShowBeatGroup(
bool show);
1933 bool getShowBeatGroup()
const;
1935 void setGroupNumerator1(
int numerator);
1936 void setGroupNumerator2(
int numerator);
1937 void setGroupNumerator3(
int numerator);
1938 void setGroupDenominator1(
int denominator);
1939 void setGroupDenominator2(
int denominator);
1940 void setGroupDenominator3(
int denominator);
1942 void setBeamGroup1(
int count);
1943 void setBeamGroup2(
int count);
1944 void setBeamGroup3(
int count);
1945 void setBeamGroup4(
int count);
1947 void set16thBeamCount(
int count);
1948 void set32thBeamCount(
int count);
1968 QList<BeatNode> beats_;
1969 int barLengthUnits_;
1972 bool showBeatGroup_;
1974 int groupNumerator1_;
1975 int groupNumerator2_;
1976 int groupNumerator3_;
1977 int groupDenominator1_;
1978 int groupDenominator2_;
1979 int groupDenominator3_;
1990 class Key:
public MusicData {
1996 void setKey(
int key);
1998 bool getSetKey()
const;
2000 void setPreviousKey(
int key);
2001 int getPreviousKey()
const;
2003 void setSymbolCount(
int count);
2004 int getSymbolCount()
const;
2013 class RepeatSymbol:
public MusicData {
2016 virtual ~RepeatSymbol() {}
2019 void setText(
const QString& text);
2020 QString getText()
const;
2022 void setRepeatType(
int repeatType);
2023 RepeatType getRepeatType()
const;
2027 RepeatType repeatType_;
2030 class NumericEnding:
public MusicData,
public PairEnds {
2033 virtual ~NumericEnding();
2036 OffsetElement* getNumericHandle()
const;
2038 void setHeight(
int height);
2039 int getHeight()
const;
2041 void setText(
const QString& text);
2042 QString getText()
const;
2043 QList<int> getNumbers()
const;
2044 int getJumpCount()
const;
2049 OffsetElement* numericHandle_;
2052 class BarNumber:
public MusicData {
2055 virtual ~BarNumber() {}
2058 void setIndex(
int index);
2059 int getIndex()
const;
2061 void setShowOnParagraphStart(
bool show);
2062 bool getShowOnParagraphStart()
const;
2064 void setAlign(
int align);
2065 int getAlign()
const;
2067 void setShowFlag(
int flag);
2068 int getShowFlag()
const;
2070 void setShowEveryBarCount(
int count);
2071 int getShowEveryBarCount()
const;
2073 void setPrefix(
const QString& str);
2074 QString getPrefix()
const;
2078 bool showOnParagraphStart_;
2087 class MidiController:
public MidiData {
2090 virtual ~MidiController() {}
2093 void setController(
int number);
2094 int getController()
const;
2096 void setValue(
int value);
2097 int getValue()
const;
2104 class MidiProgramChange:
public MidiData {
2106 MidiProgramChange();
2107 virtual ~MidiProgramChange() {}
2110 void setPatch(
int patch);
2111 int getPatch()
const;
2117 class MidiChannelPressure:
public MidiData {
2119 MidiChannelPressure();
2120 virtual ~MidiChannelPressure() {}
2123 void setPressure(
int pressure);
2124 int getPressure()
const;
2130 class MidiPitchWheel:
public MidiData {
2133 virtual ~MidiPitchWheel() {}
2136 void setValue(
int value);
2137 int getValue()
const;
2144 class Measure:
public LengthElement {
2146 Measure(
int index = 0);
2153 BarNumber* getBarNumber()
const;
2154 TimeSignature* getTime()
const;
2156 void setLeftBarline(
int barline);
2157 BarlineType getLeftBarline()
const;
2159 void setRightBarline(
int barline);
2160 BarlineType getRightBarline()
const;
2163 void setBackwardRepeatCount(
int repeatCount);
2164 int getBackwardRepeatCount()
const;
2166 void setTypeTempo(
double tempo);
2167 double getTypeTempo()
const;
2169 void setIsPickup(
bool pickup);
2170 bool getIsPickup()
const;
2172 void setIsMultiMeasureRest(
bool rest);
2173 bool getIsMultiMeasureRest()
const;
2175 void setMultiMeasureRestCount(
int count);
2176 int getMultiMeasureRestCount()
const;
2181 BarNumber* barNumber_;
2182 TimeSignature* time_;
2184 BarlineType leftBarline_;
2185 BarlineType rightBarline_;
2189 bool multiMeasureRest_;
2190 int multiMeasureRestCount_;
2199 Clef* getClef()
const;
2200 Key* getKey()
const;
2202 void addNoteContainer(NoteContainer* ptr);
2203 QList<NoteContainer*> getNoteContainers()
const;
2206 void addMusicData(MusicData* ptr);
2208 QList<MusicData*> getMusicDatas(MusicDataType type);
2211 void addCrossMeasureElement(MusicData* ptr,
bool start);
2217 QList<MusicData*> getCrossMeasureElements(MusicDataType type, PairType pairType);
2220 void addMidiData(MidiData* ptr);
2221 QList<MidiData*> getMidiDatas(MidiType type);
2226 QList<MusicData*> musicDatas_;
2227 QList<NoteContainer*> noteContainers_;
2228 QList<QPair<MusicData*, bool> > crossMeasureElements_;
2229 QList<MidiData*> midiDatas_;
2233 class StreamHandle {
2235 StreamHandle(
unsigned char* p,
int size);
2236 virtual ~StreamHandle();
2242 virtual bool read(
char* buff,
int size);
2243 virtual bool write(
char* buff,
int size);
2248 unsigned char* point_;
2256 explicit Block(
unsigned int size);
2262 virtual void resize(
unsigned int count);
2264 const unsigned char* data()
const;
2265 unsigned char* data();
2266 unsigned int size()
const;
2268 bool operator ==(
const Block& block)
const;
2269 bool operator !=(
const Block& block)
const;
2271 bool toBoolean()
const;
2272 unsigned int toUnsignedInt()
const;
2274 QByteArray toStrByteArray()
const;
2275 QByteArray fixedSizeBufferToStrByteArray()
const;
2278 void doResize(
unsigned int count);
2282 QList<unsigned char> data_;
2285 class FixedBlock:
public Block {
2287 explicit FixedBlock(
unsigned int count);
2288 virtual ~FixedBlock() {
2296 virtual void resize(
unsigned int count);
2301 class SizeBlock:
public FixedBlock {
2304 virtual ~SizeBlock() {
2310 unsigned int toSize()
const;
2314 class NameBlock:
public FixedBlock {
2317 virtual ~NameBlock() {
2322 bool isEqual(
const QString& name)
const;
2326 class CountBlock:
public FixedBlock {
2329 virtual ~CountBlock() {
2335 unsigned short toCount()
const;
2347 const static QString TrackName;
2348 const static QString PageName;
2349 const static QString LineName;
2350 const static QString StaffName;
2351 const static QString MeasureName;
2352 const static QString ConductName;
2353 const static QString BdatName;
2355 NameBlock getName()
const;
2358 NameBlock nameBlock_;
2362 class SizeChunk:
public Chunk {
2365 virtual ~SizeChunk();
2368 SizeBlock* getSizeBlock()
const;
2369 Block* getDataBlock()
const;
2371 const static unsigned int version3TrackSize;
2374 SizeBlock* sizeBlock_;
2379 class GroupChunk:
public Chunk {
2382 virtual ~GroupChunk();
2385 CountBlock* getCountBlock()
const;
2388 CountBlock* childCount_;
2394 BasicParse(OveSong* ove);
2395 virtual ~BasicParse();
2401 void setNotify(IOveNotify* notify);
2402 virtual bool parse();
2405 bool readBuffer(Block& placeHolder,
unsigned int size);
2406 bool jump(
int offset);
2408 void messageOut(
const QString& str);
2412 StreamHandle* handle_;
2413 IOveNotify* notify_;
2418 class OvscParse:
public BasicParse {
2420 OvscParse(OveSong* ove);
2421 virtual ~OvscParse();
2424 void setOvsc(SizeChunk* chunk);
2426 virtual bool parse();
2432 class TrackParse:
public BasicParse {
2434 TrackParse(OveSong* ove);
2435 virtual ~TrackParse();
2438 void setTrack(SizeChunk* chunk);
2440 virtual bool parse();
2446 class GroupParse: BasicParse {
2448 GroupParse(OveSong* ove);
2449 virtual ~GroupParse();
2452 void addSizeChunk(SizeChunk* sizeChunk);
2454 virtual bool parse();
2457 QList<SizeChunk*> sizeChunks_;
2460 class PageGroupParse:
public BasicParse {
2462 PageGroupParse(OveSong* ove);
2463 virtual ~PageGroupParse();
2466 void addPage(SizeChunk* chunk);
2468 virtual bool parse();
2471 bool parsePage(SizeChunk* chunk, Page* page);
2474 QList<SizeChunk*> pageChunks_;
2477 class StaffCountGetter:
public BasicParse {
2479 StaffCountGetter(OveSong* ove);
2480 virtual ~StaffCountGetter() {}
2483 unsigned int getStaffCount(SizeChunk* chunk);
2486 class LineGroupParse:
public BasicParse {
2488 LineGroupParse(OveSong* ove);
2489 virtual ~LineGroupParse();
2492 void setLineGroup(GroupChunk* chunk);
2493 void addLine(SizeChunk* chunk);
2494 void addStaff(SizeChunk* chunk);
2496 virtual bool parse();
2499 bool parseLine(SizeChunk* chunk, Line* line);
2500 bool parseStaff(SizeChunk* chunk, Staff* staff);
2504 QList<SizeChunk*> lineChunks_;
2505 QList<SizeChunk*> staffChunks_;
2508 class BarsParse:
public BasicParse {
2510 BarsParse(OveSong* ove);
2511 virtual ~BarsParse();
2514 void addMeasure(SizeChunk* chunk);
2515 void addConduct(SizeChunk* chunk);
2516 void addBdat(SizeChunk* chunk);
2518 virtual bool parse();
2521 bool parseMeas(Measure* measure, SizeChunk* chunk);
2522 bool parseCond(Measure* measure, MeasureData* measureData, SizeChunk* chunk);
2523 bool parseBdat(Measure* measure, MeasureData* measureData, SizeChunk* chunk);
2525 bool getCondElementType(
unsigned int byteData, CondType& type);
2526 bool getBdatElementType(
unsigned int byteData, BdatType& type);
2529 bool parseTimeSignature(Measure* measure,
int length);
2530 bool parseTimeSignatureParameters(Measure* measure,
int length);
2531 bool parseRepeatSymbol(MeasureData* measureData,
int length);
2532 bool parseNumericEndings(MeasureData* measureData,
int length);
2533 bool parseTempo(MeasureData* measureData,
int length);
2534 bool parseBarNumber(Measure* measure,
int length);
2535 bool parseText(MeasureData* measureData,
int length);
2536 bool parseBarlineParameters(Measure* measure,
int length);
2539 bool parseNoteRest(MeasureData* measureData,
int length, BdatType type);
2540 bool parseBeam(MeasureData* measureData,
int length);
2541 bool parseTie(MeasureData* measureData,
int length);
2542 bool parseTuplet(MeasureData* measureData,
int length);
2543 bool parseHarmony(MeasureData* measureData,
int length);
2544 bool parseClef(MeasureData* measureData,
int length);
2545 bool parseLyric(MeasureData* measureData,
int length);
2546 bool parseSlur(MeasureData* measureData,
int length);
2547 bool parseGlissando(MeasureData* measureData,
int length);
2548 bool parseDecorators(MeasureData* measureData,
int length);
2549 bool parseDynamics(MeasureData* measureData,
int length);
2550 bool parseWedge(MeasureData* measureData,
int length);
2551 bool parseKey(MeasureData* measureData,
int length);
2552 bool parsePedal(MeasureData* measureData,
int length);
2553 bool parseKuohao(MeasureData* measureData,
int length);
2554 bool parseExpressions(MeasureData* measureData,
int length);
2555 bool parseHarpPedal(MeasureData* measureData,
int length);
2556 bool parseMultiMeasureRest(MeasureData* measureData,
int length);
2557 bool parseHarmonyGuitarFrame(MeasureData* measureData,
int length);
2558 bool parseOctaveShift(MeasureData* measureData,
int length);
2559 bool parseMidiController(MeasureData* measureData,
int length);
2560 bool parseMidiProgramChange(MeasureData* measureData,
int length);
2561 bool parseMidiChannelPressure(MeasureData* measureData,
int length);
2562 bool parseMidiPitchWheel(MeasureData* measureData,
int length);
2564 bool parseSizeBlock(
int length);
2565 bool parseMidiCommon(MidiData* ptr);
2566 bool parseCommonBlock(MusicData* ptr);
2567 bool parseOffsetCommonBlock(MusicData* ptr);
2568 bool parsePairLinesBlock(PairEnds* ptr);
2569 bool parseOffsetElement(OffsetElement* ptr);
2572 QList<SizeChunk*> measureChunks_;
2573 QList<SizeChunk*> conductChunks_;
2574 QList<SizeChunk*> bdatChunks_;
2577 class LyricChunkParse:
public BasicParse {
2579 LyricChunkParse(OveSong* ove);
2580 virtual ~LyricChunkParse() {}
2583 void setLyricChunk(SizeChunk* chunk);
2585 virtual bool parse();
2602 track_(0), measure_(0), verse_(0), voice_(0), wordCount_(0),
2603 lyricSize_(0), name_(QString()), lyric_(QString()),
2604 font_(0), fontSize_(12), fontStyle_(0) {}
2607 void processLyricInfo(
const LyricInfo& info);
2613 class TitleChunkParse:
public BasicParse {
2615 TitleChunkParse(OveSong* ove);
2616 virtual ~TitleChunkParse() {}
2619 void setTitleChunk(SizeChunk* chunk);
2621 virtual bool parse();
2624 void addToOve(
const QString& str,
unsigned int titleType);
2627 unsigned int titleType_;
2628 unsigned int annotateType_;
2629 unsigned int writerType_;
2630 unsigned int copyrightType_;
2631 unsigned int headerType_;
2632 unsigned int footerType_;
2638 class OveOrganizer {
2640 OveOrganizer(OveSong* ove) ;
2641 virtual ~OveOrganizer(){}
2647 void organizeAttributes() ;
2648 void organizeTracks() ;
2649 void organizeMeasures() ;
2650 void organizeMeasure(
int part,
int track, Measure* measure, MeasureData* measureData) ;
2652 void organizeContainers(
int part,
int track, Measure* measure, MeasureData* measureData) ;
2653 void organizeMusicDatas(
int part,
int track, Measure* measure, MeasureData* measureData) ;
2654 void organizeCrossMeasureElements(
int part,
int track, Measure* measure, MeasureData* measureData) ;
2656 void organizePairElement(MusicData* data,
int part,
int track, Measure* measure, MeasureData* measureData) ;
2657 void organizeOctaveShift(OctaveShift* octave, Measure* measure, MeasureData* measureData) ;
2658 void organizeWedge(Wedge* wedge,
int part,
int track, Measure* measure, MeasureData* measureData) ;
2672 class OveSerialize:
public IOVEStreamLoader {
2675 virtual ~OveSerialize();
2678 virtual void setOve(OveSong* ove);
2679 virtual void setFileStream(
unsigned char* buffer,
unsigned int size);
2680 virtual void setNotify(IOveNotify* notify);
2681 virtual bool load(
void);
2683 virtual void release();
2686 bool readNameBlock(NameBlock& nameBlock);
2687 bool readChunkName(Chunk* chunk,
const QString& name);
2688 bool readSizeChunk(SizeChunk* sizeChunk);
2689 bool readDataChunk(Block* block,
unsigned int size);
2690 bool readGroupChunk(GroupChunk* groupChunk);
2693 bool readHeadData(SizeChunk* ovscChunk);
2694 bool readTracksData();
2695 bool readPagesData();
2696 bool readLinesData();
2697 bool readBarsData();
2700 void messageOutError();
2701 void messageOut(
const QString& str);
2705 StreamHandle* streamHandle_;
2706 IOveNotify* notify_;
2718 TickElement::TickElement() {
2722 void TickElement::setTick(
int tick) {
2726 int TickElement::getTick(
void)
const {
2731 MeasurePos::MeasurePos() {
2736 void MeasurePos::setMeasure(
int measure) {
2740 int MeasurePos::getMeasure()
const {
2744 void MeasurePos::setOffset(
int offset) {
2748 int MeasurePos::getOffset()
const {
2752 MeasurePos MeasurePos::shiftMeasure(
int measure)
const {
2754 mp.setMeasure(getMeasure() + measure);
2755 mp.setOffset(getOffset());
2760 MeasurePos MeasurePos::shiftOffset(
int offset)
const {
2762 mp.setMeasure(getMeasure());
2763 mp.setOffset(getOffset() + offset);
2768 bool MeasurePos::operator ==(
const MeasurePos& mp)
const {
2769 return getMeasure() == mp.getMeasure() && getOffset() == mp.getOffset();
2772 bool MeasurePos::operator !=(
const MeasurePos& mp)
const {
2773 return !(*
this == mp);
2776 bool MeasurePos::operator <(
const MeasurePos& mp)
const {
2777 if (getMeasure() != mp.getMeasure()) {
2778 return getMeasure() < mp.getMeasure();
2781 return getOffset() < mp.getOffset();
2784 bool MeasurePos::operator <=(
const MeasurePos& mp)
const {
2785 if (getMeasure() != mp.getMeasure()) {
2786 return getMeasure() <= mp.getMeasure();
2789 return getOffset() <= mp.getOffset();
2792 bool MeasurePos::operator >(
const MeasurePos& mp)
const {
2793 return !(*
this <= mp);
2796 bool MeasurePos::operator >=(
const MeasurePos& mp)
const {
2797 return !(*
this < mp);
2801 PairElement::PairElement() {
2802 start_ =
new MeasurePos();
2803 stop_ =
new MeasurePos();
2806 PairElement::~PairElement(){
2811 MeasurePos* PairElement::start()
const {
2815 MeasurePos* PairElement::stop()
const {
2820 PairEnds::PairEnds() {
2821 leftLine_ =
new LineElement();
2822 rightLine_ =
new LineElement();
2823 leftShoulder_ =
new OffsetElement();
2824 rightShoulder_ =
new OffsetElement();
2827 PairEnds::~PairEnds(){
2830 delete leftShoulder_;
2831 delete rightShoulder_;
2834 LineElement* PairEnds::getLeftLine()
const {
2838 LineElement* PairEnds::getRightLine()
const {
2842 OffsetElement* PairEnds::getLeftShoulder()
const {
2843 return leftShoulder_;
2846 OffsetElement* PairEnds::getRightShoulder()
const {
2847 return rightShoulder_;
2851 LineElement::LineElement() {
2855 void LineElement::setLine(
int line) {
2859 int LineElement::getLine(
void)
const {
2864 OffsetElement::OffsetElement() {
2869 void OffsetElement::setXOffset(
int offset) {
2873 int OffsetElement::getXOffset()
const {
2877 void OffsetElement::setYOffset(
int offset) {
2881 int OffsetElement::getYOffset()
const {
2886 LengthElement::LengthElement() {
2890 void LengthElement::setLength(
int length) {
2894 int LengthElement::getLength()
const {
2899 MusicData::MusicData() {
2900 musicDataType_ = MusicData_None;
2906 MusicDataType MusicData::getMusicDataType()
const {
2907 return musicDataType_;
2910 MusicData::XmlDataType MusicData::getXmlDataType(MusicDataType type) {
2911 XmlDataType xmlType = None;
2914 case MusicData_Measure_Repeat: {
2915 xmlType = Attributes;
2918 case MusicData_Beam: {
2922 case MusicData_Slur:
2923 case MusicData_Glissando:
2924 case MusicData_Tuplet:
2925 case MusicData_Tie: {
2926 xmlType = Notations;
2929 case MusicData_Text:
2930 case MusicData_Repeat:
2931 case MusicData_Wedge:
2932 case MusicData_Dynamics:
2933 case MusicData_Pedal:
2934 case MusicData_OctaveShift_EndPoint: {
2935 xmlType = Direction;
2975 void MusicData::setShow(
bool show) {
2979 bool MusicData::getShow()
const {
2983 void MusicData::setColor(
unsigned int color) {
2987 unsigned int MusicData::getColor()
const {
2991 void MusicData::setVoice(
unsigned int voice) {
2995 unsigned int MusicData::getVoice()
const {
2999 void MusicData::copyCommonBlock(
const MusicData& source) {
3000 setTick(source.getTick());
3001 start()->setOffset(source.start()->getOffset());
3002 setColor(source.getColor());
3006 MidiData::MidiData() {
3007 midiType_ = Midi_None;
3010 MidiType MidiData::getMidiType()
const {
3015 OveSong::OveSong() :
3020 OveSong::~OveSong() {
3024 void OveSong::setIsVersion4(
bool version4){
3025 version4_ = version4;
3028 bool OveSong::getIsVersion4()
const {
3032 void OveSong::setQuarter(
int tick) {
3036 int OveSong::getQuarter(
void)
const {
3040 void OveSong::setShowPageMargin(
bool show){
3041 showPageMargin_ = show;
3044 bool OveSong::getShowPageMargin()
const {
3045 return showPageMargin_;
3048 void OveSong::setShowTransposeTrack(
bool show) {
3049 showTransposeTrack = show;
3052 bool OveSong::getShowTransposeTrack()
const {
3053 return showTransposeTrack;
3056 void OveSong::setShowLineBreak(
bool show) {
3057 showLineBreak_ = show;
3060 bool OveSong::getShowLineBreak()
const {
3061 return showLineBreak_;
3064 void OveSong::setShowRuler(
bool show) {
3068 bool OveSong::getShowRuler()
const {
3072 void OveSong::setShowColor(
bool show) {
3076 bool OveSong::getShowColor()
const {
3080 void OveSong::setPlayRepeat(
bool play) {
3084 bool OveSong::getPlayRepeat()
const {
3088 void OveSong::setPlayStyle(PlayStyle style) {
3092 OveSong::PlayStyle OveSong::getPlayStyle()
const {
3096 void OveSong::addTitle(
const QString& str) {
3097 titles_.push_back(str);
3100 QList<QString> OveSong::getTitles(
void)
const {
3104 void OveSong::addAnnotate(
const QString& str) {
3105 annotates_.push_back(str);
3108 QList<QString> OveSong::getAnnotates(
void)
const {
3112 void OveSong::addWriter(
const QString& str) {
3113 writers_.push_back(str);
3116 QList<QString> OveSong::getWriters(
void)
const {
3120 void OveSong::addCopyright(
const QString& str) {
3121 copyrights_.push_back(str);
3124 QList<QString> OveSong::getCopyrights(
void)
const {
3128 void OveSong::addHeader(
const QString& str) {
3129 headers_.push_back(str);
3132 QList<QString> OveSong::getHeaders(
void)
const {
3136 void OveSong::addFooter(
const QString& str) {
3137 footers_.push_back(str);
3140 QList<QString> OveSong::getFooters(
void)
const {
3144 void OveSong::addTrack(Track* ptr) {
3145 tracks_.push_back(ptr);
3148 int OveSong::getTrackCount(
void)
const {
3149 return tracks_.size();
3152 QList<Track*> OveSong::getTracks()
const {
3156 void OveSong::setTrackBarCount(
int count) {
3157 trackBarCount_ = count;
3160 int OveSong::getTrackBarCount()
const {
3161 return trackBarCount_;
3164 Track* OveSong::getTrack(
int part,
int staff)
const {
3165 int trackId = partStaffToTrack(part, staff);
3167 if( trackId >=0 && trackId < (
int)tracks_.size() ) {
3168 return tracks_[trackId];
3174 bool OveSong::addPage(Page* page) {
3175 pages_.push_back(page);
3179 int OveSong::getPageCount()
const {
3180 return pages_.size();
3183 Page* OveSong::getPage(
int idx) {
3184 if( idx>=0 && idx<(
int)pages_.size() ) {
3191 void OveSong::addLine(Line* ptr) {
3192 lines_.push_back(ptr);
3195 int OveSong::getLineCount()
const {
3196 return lines_.size();
3199 Line* OveSong::getLine(
int idx)
const {
3200 if( idx >=0 && idx<(
int)lines_.size() ) {
3207 void OveSong::addMeasure(Measure* ptr) {
3208 measures_.push_back(ptr);
3211 int OveSong::getMeasureCount(
void)
const {
3212 return measures_.size();
3215 Measure* OveSong::getMeasure(
int bar)
const {
3216 if( bar >= 0 && bar < (
int)measures_.size() ) {
3217 return measures_[bar];
3223 void OveSong::addMeasureData(MeasureData* ptr) {
3224 measureDatas_.push_back(ptr);
3227 int OveSong::getMeasureDataCount(
void)
const {
3228 return measureDatas_.size();
3231 MeasureData* OveSong::getMeasureData(
int part,
int staff,
int bar)
const {
3232 int trackId = partStaffToTrack(part, staff);
3233 int trackBarCount = getTrackBarCount();
3235 if( bar >= 0 && bar < trackBarCount ) {
3236 int measureId = trackBarCount * trackId + bar;
3238 if( measureId >=0 && measureId < (
int)measureDatas_.size() ) {
3239 return measureDatas_[measureId];
3246 MeasureData* OveSong::getMeasureData(
int track,
int bar)
const {
3247 int id = trackBarCount_*track + bar;
3249 if(
id >=0 &&
id < (
int)measureDatas_.size() ) {
3250 return measureDatas_[id];
3256 void OveSong::setPartStaffCounts(
const QList<int>& partStaffCounts) {
3258 for(
int i=0; i<partStaffCounts.size(); ++i) {
3259 partStaffCounts_.push_back(partStaffCounts[i]);
3263 int OveSong::getPartCount()
const {
3264 return partStaffCounts_.size();
3267 int OveSong::getStaffCount(
int part)
const {
3268 if( part>=0 && part<(
int)partStaffCounts_.size() ) {
3269 return partStaffCounts_[part];
3275 int OveSong::getPartBarCount()
const {
3276 return measureDatas_.size() / tracks_.size();
3279 QPair<int, int> OveSong::trackToPartStaff(
int track)
const {
3280 QPair<int, int> partStaff;
3284 for( i=0; i<partStaffCounts_.size(); ++i ) {
3285 if( staffCount + partStaffCounts_[i] > track ) {
3286 return qMakePair((
int)i, track-staffCount);
3289 staffCount += partStaffCounts_[i];
3292 return qMakePair((
int)partStaffCounts_.size(), 0);
3295 int OveSong::partStaffToTrack(
int part,
int staff)
const {
3297 unsigned int staffCount = 0;
3299 for( i=0; i<partStaffCounts_.size(); ++i ) {
3300 if( part == (
int)i && staff>=0 && staff<(int)partStaffCounts_[i] ) {
3301 int trackId = staffCount + staff;
3303 if( trackId >=0 && trackId < (
int)tracks_.size() ) {
3308 staffCount += partStaffCounts_[i];
3311 return tracks_.size();
3314 void OveSong::setTextCodecName(
const QString& codecName) {
3315 codec_ = QTextCodec::codecForName(codecName.toLatin1());
3318 QString OveSong::getCodecString(
const QByteArray& text) {
3323 s = codec_->toUnicode(text);
3328 void OveSong::clear(
void)
3332 showPageMargin_ =
false;
3333 showTransposeTrack =
false;
3334 showLineBreak_ =
false;
3338 playStyle_ = Record;
3341 copyrights_.clear();
3348 for(
int i=0; i<tracks_.size(); ++i){
3351 for(
int i=0; i<pages_.size(); ++i){
3354 for(
int i=0; i<lines_.size(); ++i){
3357 for(
int i=0; i<measures_.size(); ++i){
3358 delete measures_[i];
3360 for(
int i=0; i<measureDatas_.size(); ++i){
3361 delete measureDatas_[i];
3367 measureDatas_.clear();
3369 partStaffCounts_.clear();
3382 void Voice::setChannel(
int channel) {
3386 int Voice::getChannel()
const {
3390 void Voice::setVolume(
int volume) {
3394 int Voice::getVolume()
const {
3398 void Voice::setPitchShift(
int pitchShift) {
3399 pitchShift_ = pitchShift;
3402 int Voice::getPitchShift()
const {
3406 void Voice::setPan(
int pan) {
3410 int Voice::getPan()
const {
3414 void Voice::setPatch(
int patch) {
3418 int Voice::getPatch()
const {
3422 void Voice::setStemType(
int stemType) {
3423 stemType_ = stemType;
3426 int Voice::getStemType()
const {
3430 int Voice::getDefaultPatch() {
3434 int Voice::getDefaultVolume() {
3447 void Track::setName(
const QString& str) {
3451 QString Track::getName(
void)
const {
3455 void Track::setBriefName(
const QString& str) {
3459 QString Track::getBriefName(
void)
const {
3463 void Track::setPatch(
unsigned int patch) {
3467 unsigned int Track::getPatch()
const {
3471 void Track::setChannel(
int channel) {
3475 int Track::getChannel()
const {
3479 void Track::setShowName(
bool show) {
3483 bool Track::getShowName()
const {
3487 void Track::setShowBriefName(
bool show) {
3488 showBriefName_ = show;
3491 bool Track::getShowBriefName()
const {
3492 return showBriefName_;
3495 void Track::setMute(
bool mute) {
3499 bool Track::getMute()
const {
3503 void Track::setSolo(
bool solo) {
3507 bool Track::getSolo()
const {
3511 void Track::setShowKeyEachLine(
bool show) {
3512 showKeyEachLine_ = show;
3515 bool Track::getShowKeyEachLine()
const {
3516 return showKeyEachLine_;
3519 void Track::setVoiceCount(
int voices) {
3520 voiceCount_ = voices;
3523 int Track::getVoiceCount()
const {
3527 void Track::addVoice(Voice* voice) {
3528 voices_.push_back(voice);
3531 QList<Voice*> Track::getVoices()
const {
3535 void Track::setShowTranspose(
bool show) {
3536 showTranspose_ = show;
3539 bool Track::getShowTranspose()
const {
3540 return showTranspose_;
3543 void Track::setTranspose(
int transpose) {
3544 transpose_ = transpose;
3547 int Track::getTranspose()
const {
3551 void Track::setNoteShift(
int shift) {
3555 int Track::getNoteShift()
const {
3559 void Track::setStartClef(
int clef) {
3563 ClefType Track::getStartClef()
const {
3564 return (ClefType)startClef_;
3567 void Track::setTransposeClef(
int clef) {
3568 transposeClef_ = clef;
3571 int Track::getTansposeClef()
const {
3572 return transposeClef_;
3575 void Track::setStartKey(
int key) {
3579 int Track::getStartKey()
const {
3583 void Track::setDisplayPercent(
unsigned int percent) {
3584 displayPercent_ = percent;
3587 unsigned int Track::getDisplayPercent()
const {
3588 return displayPercent_;
3591 void Track::setShowLegerLine(
bool show) {
3592 showLegerLine_ = show;
3595 bool Track::getShowLegerLine()
const {
3596 return showLegerLine_;
3599 void Track::setShowClef(
bool show) {
3603 bool Track::getShowClef()
const {
3607 void Track::setShowTimeSignature(
bool show) {
3608 showTimeSignature_ = show;
3611 bool Track::getShowTimeSignature()
const {
3612 return showTimeSignature_;
3615 void Track::setShowKeySignature(
bool show) {
3616 showKeySignature_ = show;
3619 bool Track::getShowKeySignature()
const {
3620 return showKeySignature_;
3623 void Track::setShowBarline(
bool show) {
3624 showBarline_ = show;
3627 bool Track::getShowBarline()
const {
3628 return showBarline_;
3631 void Track::setFillWithRest(
bool fill) {
3632 fillWithRest_ = fill;
3635 bool Track::getFillWithRest()
const {
3636 return fillWithRest_;
3639 void Track::setFlatTail(
bool flat) {
3643 bool Track::getFlatTail()
const {
3647 void Track::setShowClefEachLine(
bool show) {
3648 showClefEachLine_ = show;
3651 bool Track::getShowClefEachLine()
const {
3652 return showClefEachLine_;
3655 void Track::addDrum(
const DrumNode& node) {
3661 drumKit_.push_back(node);
3664 QList<Track::DrumNode> Track::getDrumKit()
const {
3668 void Track::setPart(
int part) {
3672 int Track::getPart()
const {
3676 void Track::clear(
void) {
3684 showTranspose_ =
false;
3686 startClef_ = Clef_Treble;
3687 transposeClef_ = Clef_Treble;
3688 displayPercent_ = 100;
3693 showBriefName_ =
false;
3694 showKeyEachLine_ =
false;
3695 showLegerLine_ =
true;
3697 showTimeSignature_ =
true;
3698 showKeySignature_ =
true;
3699 showBarline_ =
true;
3700 showClefEachLine_ =
false;
3702 fillWithRest_ =
true;
3712 for(
int i=0; i<voices_.size(); ++i){
3725 staffInlineInterval_ = 6;
3732 rightMargin_ = 0xA8;
3733 bottomMargin_ = 0xA8;
3735 pageWidth_ = 0x0B40;
3736 pageHeight_ = 0x0E90;
3739 void Page::setBeginLine(
int line) {
3743 int Page::getBeginLine()
const {
3747 void Page::setLineCount(
int count) {
3751 int Page::getLineCount()
const {
3755 void Page::setLineInterval(
int interval) {
3756 lineInterval_ = interval;
3759 int Page::getLineInterval()
const {
3760 return lineInterval_;
3763 void Page::setStaffInterval(
int interval) {
3764 staffInterval_ = interval;
3767 int Page::getStaffInterval()
const {
3768 return staffInterval_;
3771 void Page::setStaffInlineInterval(
int interval) {
3772 staffInlineInterval_ = interval;
3775 int Page::getStaffInlineInterval()
const {
3776 return staffInlineInterval_;
3779 void Page::setLineBarCount(
int count) {
3780 lineBarCount_ = count;
3783 int Page::getLineBarCount()
const {
3784 return lineBarCount_;
3787 void Page::setPageLineCount(
int count) {
3788 pageLineCount_ = count;
3791 int Page::getPageLineCount()
const {
3792 return pageLineCount_;
3795 void Page::setLeftMargin(
int margin) {
3796 leftMargin_ = margin;
3799 int Page::getLeftMargin()
const {
3803 void Page::setTopMargin(
int margin) {
3804 topMargin_ = margin;
3807 int Page::getTopMargin()
const {
3811 void Page::setRightMargin(
int margin) {
3812 rightMargin_ = margin;
3815 int Page::getRightMargin()
const {
3816 return rightMargin_;
3819 void Page::setBottomMargin(
int margin) {
3820 bottomMargin_ = margin;
3823 int Page::getBottomMargin()
const {
3824 return bottomMargin_;
3827 void Page::setPageWidth(
int width) {
3831 int Page::getPageWidth()
const {
3835 void Page::setPageHeight(
int height) {
3836 pageHeight_ = height;
3839 int Page::getPageHeight()
const {
3853 for(
int i=0; i<staffs_.size(); ++i){
3859 void Line::addStaff(Staff* staff) {
3860 staffs_.push_back(staff);
3863 int Line::getStaffCount()
const {
3864 return staffs_.size();
3867 Staff* Line::getStaff(
int idx)
const {
3868 if (idx >= 0 && idx < (
int) staffs_.size()) {
3869 return staffs_[idx];
3875 void Line::setBeginBar(
unsigned int bar) {
3879 unsigned int Line::getBeginBar()
const {
3883 void Line::setBarCount(
unsigned int count) {
3887 unsigned int Line::getBarCount()
const {
3891 void Line::setYOffset(
int offset) {
3895 int Line::getYOffset()
const {
3899 void Line::setLeftXOffset(
int offset) {
3900 leftXOffset_ = offset;
3903 int Line::getLeftXOffset()
const {
3904 return leftXOffset_;
3907 void Line::setRightXOffset(
int offset) {
3908 rightXOffset_ = offset;
3911 int Line::getRightXOffset()
const {
3912 return rightXOffset_;
3917 clef_ = Clef_Treble;
3920 groupType_ = Group_None;
3921 groupStaffCount_ = 0;
3924 void Staff::setClefType(
int clef) {
3925 clef_ = (ClefType) clef;
3928 ClefType Staff::getClefType()
const {
3932 void Staff::setKeyType(
int key) {
3936 int Staff::getKeyType()
const {
3940 void Staff::setVisible(
bool visible) {
3944 bool Staff::setVisible()
const {
3948 void Staff::setGroupType(GroupType type){
3952 GroupType Staff::getGroupType()
const {
3956 void Staff::setGroupStaffCount(
int count) {
3957 groupStaffCount_ = count;
3960 int Staff::getGroupStaffCount()
const {
3961 return groupStaffCount_;
3968 accidental_ = Accidental_Normal;
3969 showAccidental_ =
false;
3970 offVelocity_ = 0x40;
3972 headType_ = NoteHead_Standard;
3979 void Note::setIsRest(
bool rest) {
3983 bool Note::getIsRest()
const {
3987 void Note::setNote(
unsigned int note) {
3991 unsigned int Note::getNote()
const {
3995 void Note::setAccidental(
int type) {
3996 accidental_ = (AccidentalType) type;
3999 AccidentalType Note::getAccidental()
const {
4003 void Note::setShowAccidental(
bool show) {
4004 showAccidental_ = show;
4007 bool Note::getShowAccidental()
const {
4008 return showAccidental_;
4011 void Note::setOnVelocity(
unsigned int velocity) {
4012 onVelocity_ = velocity;
4015 unsigned int Note::getOnVelocity()
const {
4019 void Note::setOffVelocity(
unsigned int velocity) {
4020 offVelocity_ = velocity;
4023 unsigned int Note::getOffVelocity()
const {
4024 return offVelocity_;
4027 void Note::setHeadType(
int type) {
4028 headType_ = (NoteHeadType) type;
4031 NoteHeadType Note::getHeadType()
const {
4035 void Note::setTiePos(
int tiePos) {
4036 tiePos_ = (TiePos) tiePos;
4039 TiePos Note::getTiePos()
const {
4043 void Note::setOffsetStaff(
int offset) {
4044 offsetStaff_ = offset;
4047 int Note::getOffsetStaff()
const {
4048 return offsetStaff_;
4051 void Note::setShow(
bool show) {
4055 bool Note::getShow()
const {
4059 void Note::setOffsetTick(
int offset) {
4060 offsetTick_ = offset;
4063 int Note::getOffsetTick()
const {
4068 Articulation::Articulation() {
4069 type_ = Articulation_Marcato;
4072 changeSoundEffect_ =
false;
4073 changeLength_ =
false;
4074 changeVelocity_ =
false;
4075 changeExtraLength_ =
false;
4077 soundEffect_ = qMakePair(0, 0);
4078 lengthPercentage_ = 100;
4079 velocityType_ = Velocity_Offset;
4083 trillNoteLength_ = 60;
4084 trillRate_ = Note_Sixteen;
4085 accelerateType_ = Accelerate_None;
4086 auxiliaryFirst_ =
false;
4087 trillInterval_ = TrillInterval_Chromatic;
4090 void Articulation::setArtType(
int type) {
4091 type_ = (ArticulationType) type;
4094 ArticulationType Articulation::getArtType()
const {
4098 void Articulation::setPlacementAbove(
bool above) {
4102 bool Articulation::getPlacementAbove()
const {
4106 bool Articulation::getChangeSoundEffect()
const {
4107 return changeSoundEffect_;
4110 void Articulation::setSoundEffect(
int soundFrom,
int soundTo) {
4111 soundEffect_ = qMakePair(soundFrom, soundTo);
4112 changeSoundEffect_ =
true;
4115 QPair<int, int> Articulation::getSoundEffect()
const {
4116 return soundEffect_;
4119 bool Articulation::getChangeLength()
const {
4120 return changeLength_;
4123 void Articulation::setLengthPercentage(
int percentage) {
4124 lengthPercentage_ = percentage;
4125 changeLength_ =
true;
4128 int Articulation::getLengthPercentage()
const {
4129 return lengthPercentage_;
4132 bool Articulation::getChangeVelocity()
const {
4133 return changeVelocity_;
4136 void Articulation::setVelocityType(VelocityType type) {
4137 velocityType_ = type;
4138 changeVelocity_ =
true;
4141 Articulation::VelocityType Articulation::getVelocityType()
const {
4142 return velocityType_;
4145 void Articulation::setVelocityValue(
int value) {
4146 velocityValue_ = value;
4149 int Articulation::getVelocityValue()
const {
4150 return velocityValue_;
4153 bool Articulation::getChangeExtraLength()
const {
4154 return changeExtraLength_;
4157 void Articulation::setExtraLength(
int length) {
4158 extraLength_ = length;
4159 changeExtraLength_ =
true;
4162 int Articulation::getExtraLength()
const {
4163 return extraLength_;
4166 void Articulation::setTrillNoteLength(
int length) {
4167 trillNoteLength_ = length;
4170 int Articulation::getTrillNoteLength()
const {
4171 return trillNoteLength_;
4174 void Articulation::setTrillRate(NoteType rate) {
4178 NoteType Articulation::getTrillRate()
const {
4182 void Articulation::setAccelerateType(
int type) {
4183 accelerateType_ = (AccelerateType) type;
4186 Articulation::AccelerateType Articulation::getAccelerateType()
const {
4187 return accelerateType_;
4190 void Articulation::setAuxiliaryFirst(
bool first) {
4191 auxiliaryFirst_ = first;
4194 bool Articulation::getAuxiliaryFirst()
const {
4195 return auxiliaryFirst_;
4198 void Articulation::setTrillInterval(
int interval) {
4199 trillInterval_ = (TrillInterval) interval;
4202 Articulation::TrillInterval Articulation::getTrillInterval()
const {
4203 return trillInterval_;
4206 bool Articulation::willAffectNotes()
const {
4207 bool affect =
false;
4209 switch (getArtType()) {
4210 case Articulation_Major_Trill:
4211 case Articulation_Minor_Trill:
4212 case Articulation_Trill_Section:
4213 case Articulation_Inverted_Short_Mordent:
4214 case Articulation_Inverted_Long_Mordent:
4215 case Articulation_Short_Mordent:
4216 case Articulation_Turn:
4218 case Articulation_Arpeggio:
4219 case Articulation_Tremolo_Eighth:
4220 case Articulation_Tremolo_Sixteenth:
4221 case Articulation_Tremolo_Thirty_Second:
4222 case Articulation_Tremolo_Sixty_Fourth: {
4226 case Articulation_Finger_1:
4227 case Articulation_Finger_2:
4228 case Articulation_Finger_3:
4229 case Articulation_Finger_4:
4230 case Articulation_Finger_5:
4231 case Articulation_Flat_Accidental_For_Trill:
4232 case Articulation_Sharp_Accidental_For_Trill:
4233 case Articulation_Natural_Accidental_For_Trill:
4234 case Articulation_Marcato:
4235 case Articulation_Marcato_Dot:
4236 case Articulation_Heavy_Attack:
4237 case Articulation_SForzando:
4238 case Articulation_SForzando_Dot:
4239 case Articulation_Heavier_Attack:
4240 case Articulation_SForzando_Inverted:
4241 case Articulation_SForzando_Dot_Inverted:
4242 case Articulation_Staccatissimo:
4243 case Articulation_Staccato:
4244 case Articulation_Tenuto:
4245 case Articulation_Up_Bow:
4246 case Articulation_Down_Bow:
4247 case Articulation_Up_Bow_Inverted:
4248 case Articulation_Down_Bow_Inverted:
4249 case Articulation_Natural_Harmonic:
4250 case Articulation_Artificial_Harmonic:
4251 case Articulation_Plus_Sign:
4252 case Articulation_Fermata:
4253 case Articulation_Fermata_Inverted:
4254 case Articulation_Pedal_Down:
4255 case Articulation_Pedal_Up:
4256 case Articulation_Pause:
4257 case Articulation_Grand_Pause:
4258 case Articulation_Toe_Pedal:
4259 case Articulation_Heel_Pedal:
4260 case Articulation_Toe_To_Heel_Pedal:
4261 case Articulation_Heel_To_Toe_Pedal:
4262 case Articulation_Open_String:
4263 case Articulation_Guitar_Lift:
4264 case Articulation_Guitar_Slide_Up:
4265 case Articulation_Guitar_Rip:
4266 case Articulation_Guitar_Fall_Off:
4267 case Articulation_Guitar_Slide_Down:
4268 case Articulation_Guitar_Spill:
4269 case Articulation_Guitar_Flip:
4270 case Articulation_Guitar_Smear:
4271 case Articulation_Guitar_Bend:
4272 case Articulation_Guitar_Doit:
4273 case Articulation_Guitar_Plop:
4274 case Articulation_Guitar_Wow_Wow:
4275 case Articulation_Guitar_Thumb:
4276 case Articulation_Guitar_Index_Finger:
4277 case Articulation_Guitar_Middle_Finger:
4278 case Articulation_Guitar_Ring_Finger:
4279 case Articulation_Guitar_Pinky_Finger:
4280 case Articulation_Guitar_Tap:
4281 case Articulation_Guitar_Hammer:
4282 case Articulation_Guitar_Pluck: {
4292 bool Articulation::isTrill(ArticulationType type) {
4293 bool isTrill =
false;
4296 case Articulation_Major_Trill:
4297 case Articulation_Minor_Trill:
4298 case Articulation_Trill_Section: {
4309 Articulation::XmlType Articulation::getXmlType()
const {
4310 XmlType xmlType = Xml_Unknown;
4313 case Articulation_Major_Trill:
4314 case Articulation_Minor_Trill:
4315 case Articulation_Trill_Section:
4316 case Articulation_Inverted_Short_Mordent:
4317 case Articulation_Inverted_Long_Mordent:
4318 case Articulation_Short_Mordent:
4319 case Articulation_Turn:
4323 case Articulation_Tremolo_Eighth:
4324 case Articulation_Tremolo_Sixteenth:
4325 case Articulation_Tremolo_Thirty_Second:
4326 case Articulation_Tremolo_Sixty_Fourth: {
4327 xmlType = Xml_Ornament;
4330 case Articulation_Marcato:
4331 case Articulation_Marcato_Dot:
4332 case Articulation_Heavy_Attack:
4333 case Articulation_SForzando:
4334 case Articulation_SForzando_Inverted:
4335 case Articulation_SForzando_Dot:
4336 case Articulation_SForzando_Dot_Inverted:
4337 case Articulation_Heavier_Attack:
4338 case Articulation_Staccatissimo:
4339 case Articulation_Staccato:
4340 case Articulation_Tenuto:
4341 case Articulation_Pause:
4342 case Articulation_Grand_Pause: {
4343 xmlType = Xml_Articulation;
4346 case Articulation_Up_Bow:
4347 case Articulation_Down_Bow:
4348 case Articulation_Up_Bow_Inverted:
4349 case Articulation_Down_Bow_Inverted:
4350 case Articulation_Natural_Harmonic:
4351 case Articulation_Artificial_Harmonic:
4352 case Articulation_Finger_1:
4353 case Articulation_Finger_2:
4354 case Articulation_Finger_3:
4355 case Articulation_Finger_4:
4356 case Articulation_Finger_5:
4357 case Articulation_Plus_Sign: {
4358 xmlType = Xml_Technical;
4361 case Articulation_Arpeggio: {
4362 xmlType = Xml_Arpeggiate;
4365 case Articulation_Fermata:
4366 case Articulation_Fermata_Inverted: {
4367 xmlType = Xml_Fermata;
4370 case Articulation_Pedal_Down:
4371 case Articulation_Pedal_Up: {
4372 xmlType = Xml_Direction;
4388 NoteContainer::NoteContainer() {
4389 musicDataType_ = MusicData_Note_Container;
4395 noteType_ = Note_Quarter;
4397 graceNoteType_ = Note_Eight;
4407 NoteContainer::~NoteContainer(){
4408 for(
int i=0; i<notes_.size(); ++i){
4411 for(
int i=0; i<articulations_.size(); ++i){
4412 delete articulations_[i];
4415 articulations_.clear();
4418 void NoteContainer::setIsGrace(
bool grace) {
4422 bool NoteContainer::getIsGrace()
const {
4426 void NoteContainer::setIsCue(
bool cue) {
4430 bool NoteContainer::getIsCue()
const {
4434 void NoteContainer::setIsRest(
bool rest) {
4438 bool NoteContainer::getIsRest()
const {
4442 void NoteContainer::setIsRaw(
bool raw) {
4446 bool NoteContainer::getIsRaw()
const {
4450 void NoteContainer::setNoteType(NoteType type) {
4451 noteType_ = Note_Quarter;
4454 case Note_DoubleWhole:
4473 NoteType NoteContainer::getNoteType()
const {
4477 void NoteContainer::setDot(
int dot) {
4481 int NoteContainer::getDot()
const {
4485 void NoteContainer::setGraceNoteType(NoteType type) {
4486 graceNoteType_ = type;
4489 NoteType NoteContainer::getGraceNoteType()
const {
4490 return graceNoteType_;
4493 void NoteContainer::setInBeam(
bool in) {
4497 bool NoteContainer::getInBeam()
const {
4501 void NoteContainer::setStemUp(
bool up) {
4505 bool NoteContainer::getStemUp(
void)
const {
4509 void NoteContainer::setShowStem(
bool show) {
4513 bool NoteContainer::getShowStem()
const {
4517 void NoteContainer::setStemLength(
int line) {
4521 int NoteContainer::getStemLength()
const {
4525 void NoteContainer::setTuplet(
int tuplet) {
4529 int NoteContainer::getTuplet()
const {
4533 void NoteContainer::setSpace(
int space) {
4537 int NoteContainer::getSpace()
const {
4541 void NoteContainer::addNoteRest(Note* note) {
4542 notes_.push_back(note);
4545 QList<Note*> NoteContainer::getNotesRests()
const {
4549 void NoteContainer::addArticulation(Articulation* art) {
4550 articulations_.push_back(art);
4553 QList<Articulation*> NoteContainer::getArticulations()
const {
4554 return articulations_;
4557 void NoteContainer::setNoteShift(
int octave) {
4558 noteShift_ = octave;
4561 int NoteContainer::getNoteShift()
const {
4565 int NoteContainer::getOffsetStaff()
const {
4570 QList<OVE::Note*> notes = getNotesRests();
4571 for (
int i = 0; i < notes.size(); ++i) {
4572 OVE::Note* notePtr = notes[i];
4573 staffMove = notePtr->getOffsetStaff();
4579 int NoteContainer::getDuration()
const {
4580 int duration = (int) NoteDuration_4;
4582 switch (noteType_) {
4583 case Note_DoubleWhole: {
4584 duration = (int) NoteDuration_Double_Whole;
4588 duration = (int) NoteDuration_Whole;
4592 duration = (int) NoteDuration_2;
4595 case Note_Quarter: {
4596 duration = (int) NoteDuration_4;
4600 duration = (int) NoteDuration_8;
4603 case Note_Sixteen: {
4604 duration = (int) NoteDuration_16;
4608 duration = (int) NoteDuration_32;
4612 duration = (int) NoteDuration_64;
4616 duration = (int) NoteDuration_128;
4620 duration = (int) NoteDuration_256;
4627 int dotLength = duration;
4629 for (
int i = 0; i < dot_; ++i) {
4633 dotLength = duration - dotLength;
4635 duration += dotLength;
4642 musicDataType_ = MusicData_Beam;
4646 void Beam::setIsGrace(
bool grace) {
4650 bool Beam::getIsGrace()
const {
4654 void Beam::addLine(
const MeasurePos& startMp,
const MeasurePos& endMp) {
4655 lines_.push_back(qMakePair(startMp, endMp));
4658 const QList<QPair<MeasurePos, MeasurePos> > Beam::getLines()
const {
4664 musicDataType_ = MusicData_Tie;
4671 void Tie::setShowOnTop(
bool top) {
4675 bool Tie::getShowOnTop()
const {
4679 void Tie::setNote(
int note) {
4683 int Tie::getNote()
const {
4687 void Tie::setHeight(
int height) {
4691 int Tie::getHeight()
const {
4696 Glissando::Glissando() {
4697 musicDataType_ = MusicData_Glissando;
4704 void Glissando::setStraightWavy(
bool straight) {
4705 straight_ = straight;
4708 bool Glissando::getStraightWavy()
const {
4712 void Glissando::setText(
const QString& text) {
4716 QString Glissando::getText()
const {
4720 void Glissando::setLineThick(
int thick) {
4724 int Glissando::getLineThick()
const {
4729 Decorator::Decorator() :
4730 decoratorType_(Decorator_Articulation),
4731 artType_(Articulation_Marcato) {
4732 musicDataType_ = MusicData_Decorator;
4735 void Decorator::setDecoratorType(DecoratorType type) {
4736 decoratorType_ = type;
4739 Decorator::DecoratorType Decorator::getDecoratorType()
const {
4740 return decoratorType_;
4743 void Decorator::setArticulationType(ArticulationType type) {
4747 ArticulationType Decorator::getArticulationType()
const {
4752 MeasureRepeat::MeasureRepeat() {
4753 musicDataType_ = MusicData_Measure_Repeat;
4754 singleRepeat_ =
true;
4757 void MeasureRepeat::setSingleRepeat(
bool single) {
4758 singleRepeat_ = single;
4760 start()->setMeasure(0);
4761 start()->setOffset(0);
4762 stop()->setMeasure(single ? 1 : 2);
4763 stop()->setOffset(0);
4766 bool MeasureRepeat::getSingleRepeat()
const {
4767 return singleRepeat_;
4772 tuplet_(3), space_(2), height_(0), noteType_(Note_Quarter){
4773 musicDataType_ = MusicData_Tuplet;
4774 mark_ =
new OffsetElement();
4781 void Tuplet::setTuplet(
int tuplet) {
4785 int Tuplet::getTuplet()
const {
4789 void Tuplet::setSpace(
int space) {
4793 int Tuplet::getSpace()
const {
4797 OffsetElement* Tuplet::getMarkHandle()
const {
4801 void Tuplet::setHeight(
int height) {
4805 int Tuplet::getHeight()
const {
4809 void Tuplet::setNoteType(NoteType type) {
4813 NoteType Tuplet::getNoteType()
const {
4818 Harmony::Harmony() {
4819 musicDataType_ = MusicData_Harmony;
4821 harmonyType_ = Harmony_maj;
4824 bassOnBottom_ =
false;
4828 void Harmony::setHarmonyType(HarmonyType type) {
4829 harmonyType_ = type;
4832 HarmonyType Harmony::getHarmonyType()
const {
4833 return harmonyType_;
4836 void Harmony::setRoot(
int root) {
4840 int Harmony::getRoot()
const {
4844 void Harmony::setBass(
int bass) {
4848 int Harmony::getBass()
const {
4852 void Harmony::setBassOnBottom(
bool on) {
4856 bool Harmony::getBassOnBottom()
const {
4857 return bassOnBottom_;
4860 void Harmony::setAngle(
int angle) {
4864 int Harmony::getAngle()
const {
4870 musicDataType_ = MusicData_Clef;
4872 clefType_ = Clef_Treble;
4875 void Clef::setClefType(
int type) {
4876 clefType_ = (ClefType) type;
4879 ClefType Clef::getClefType()
const {
4885 musicDataType_ = MusicData_Lyric;
4891 void Lyric::setLyric(
const QString& lyricText) {
4895 QString Lyric::getLyric()
const {
4899 void Lyric::setVerse(
int verse) {
4903 int Lyric::getVerse()
const {
4909 musicDataType_ = MusicData_Slur;
4911 containerCount_ = 1;
4913 noteTimePercent_ = 100;
4915 handle_2_ =
new OffsetElement();
4916 handle_3_ =
new OffsetElement();
4924 void Slur::setContainerCount(
int count) {
4925 containerCount_ = count;
4928 int Slur::getContainerCount()
const {
4929 return containerCount_;
4932 void Slur::setShowOnTop(
bool top) {
4936 bool Slur::getShowOnTop()
const {
4940 OffsetElement* Slur::getHandle2()
const {
4944 OffsetElement* Slur::getHandle3()
const {
4948 void Slur::setNoteTimePercent(
int percent) {
4949 noteTimePercent_ = percent;
4952 int Slur::getNoteTimePercent()
const {
4953 return noteTimePercent_;
4957 Dynamics::Dynamics() {
4958 musicDataType_ = MusicData_Dynamics;
4960 dynamicsType_ = Dynamics_pppp;
4965 void Dynamics::setDynamicsType(
int type) {
4966 dynamicsType_ = (DynamicsType) type;
4969 DynamicsType Dynamics::getDynamicsType()
const {
4970 return dynamicsType_;
4973 void Dynamics::setIsPlayback(
bool play) {
4977 bool Dynamics::getIsPlayback()
const {
4981 void Dynamics::setVelocity(
int vel) {
4985 int Dynamics::getVelocity()
const {
4990 WedgeEndPoint::WedgeEndPoint() {
4991 musicDataType_ = MusicData_Wedge_EndPoint;
4993 wedgeType_ = Wedge_Cres;
4998 void WedgeEndPoint::setWedgeType(WedgeType type) {
5002 WedgeType WedgeEndPoint::getWedgeType()
const {
5006 void WedgeEndPoint::setHeight(
int height) {
5010 int WedgeEndPoint::getHeight()
const {
5014 void WedgeEndPoint::setWedgeStart(
bool wedgeStart) {
5015 wedgeStart_ = wedgeStart;
5018 bool WedgeEndPoint::getWedgeStart()
const {
5024 musicDataType_ = MusicData_Wedge;
5026 wedgeType_ = Wedge_Cres;
5030 void Wedge::setWedgeType(WedgeType type) {
5034 WedgeType Wedge::getWedgeType()
const {
5038 void Wedge::setHeight(
int height) {
5042 int Wedge::getHeight()
const {
5048 musicDataType_ = MusicData_Pedal;
5054 pedalHandle_ =
new OffsetElement();
5058 delete pedalHandle_;
5061 void Pedal::setHalf(
bool half) {
5065 bool Pedal::getHalf()
const {
5069 OffsetElement* Pedal::getPedalHandle()
const {
5070 return pedalHandle_;
5073 void Pedal::setIsPlayback(
bool playback) {
5074 playback_ = playback;
5077 bool Pedal::getIsPlayback()
const {
5081 void Pedal::setPlayOffset(
int offset) {
5082 playOffset_ = offset;
5085 int Pedal::getPlayOffset()
const {
5091 musicDataType_ = MusicData_KuoHao;
5093 kuohaoType_ = KuoHao_Parentheses;
5097 void KuoHao::setHeight(
int height) {
5101 int KuoHao::getHeight()
const {
5105 void KuoHao::setKuohaoType(
int type) {
5106 kuohaoType_ = (KuoHaoType) type;
5109 KuoHaoType KuoHao::getKuohaoType()
const {
5114 Expressions::Expressions() {
5115 musicDataType_ = MusicData_Expressions;
5120 void Expressions::setText(
const QString& str) {
5124 QString Expressions::getText()
const {
5129 HarpPedal::HarpPedal() :
5132 musicDataType_ = MusicData_Harp_Pedal;
5135 void HarpPedal::setShowType(
int type) {
5139 int HarpPedal::getShowType()
const {
5143 void HarpPedal::setShowCharFlag(
int flag) {
5144 showCharFlag_ = flag;
5147 int HarpPedal::getShowCharFlag()
const {
5148 return showCharFlag_;
5152 OctaveShift::OctaveShift() :
5153 octaveShiftType_(OctaveShift_8),
5154 octaveShiftPosition_(OctavePosition_Start),
5156 musicDataType_ = MusicData_OctaveShift;
5159 void OctaveShift::setOctaveShiftType(
int type) {
5160 octaveShiftType_ = (OctaveShiftType) type;
5163 OctaveShiftType OctaveShift::getOctaveShiftType()
const {
5164 return octaveShiftType_;
5167 int OctaveShift::getNoteShift()
const {
5170 switch (getOctaveShiftType()) {
5171 case OctaveShift_8: {
5175 case OctaveShift_Minus_8: {
5179 case OctaveShift_15: {
5183 case OctaveShift_Minus_15: {
5194 void OctaveShift::setEndTick(
int tick) {
5198 int OctaveShift::getEndTick()
const {
5203 OctaveShiftEndPoint::OctaveShiftEndPoint() {
5204 musicDataType_ = MusicData_OctaveShift_EndPoint;
5206 octaveShiftType_ = OctaveShift_8;
5207 octaveShiftPosition_ = OctavePosition_Start;
5211 void OctaveShiftEndPoint::setOctaveShiftType(
int type) {
5212 octaveShiftType_ = (OctaveShiftType) type;
5215 OctaveShiftType OctaveShiftEndPoint::getOctaveShiftType()
const {
5216 return octaveShiftType_;
5219 void OctaveShiftEndPoint::setOctaveShiftPosition(
int position) {
5220 octaveShiftPosition_ = (OctaveShiftPosition) position;
5223 OctaveShiftPosition OctaveShiftEndPoint::getOctaveShiftPosition()
const {
5224 return octaveShiftPosition_;
5227 void OctaveShiftEndPoint::setEndTick(
int tick) {
5231 int OctaveShiftEndPoint::getEndTick()
const {
5236 MultiMeasureRest::MultiMeasureRest() {
5237 musicDataType_ = MusicData_Multi_Measure_Rest;
5241 void MultiMeasureRest::setMeasureCount(
int count) {
5242 measureCount_ = count;
5245 int MultiMeasureRest::getMeasureCount()
const {
5246 return measureCount_;
5251 musicDataType_ = MusicData_Tempo;
5256 showParenthesis_ =
false;
5258 leftText_ = QString();
5259 rightText_ = QString();
5260 swingEighth_ =
false;
5264 void Tempo::setLeftNoteType(
int type) {
5265 leftNoteType_ = type;
5268 NoteType Tempo::getLeftNoteType()
const {
5269 return (NoteType) leftNoteType_;
5272 void Tempo::setShowMark(
bool show) {
5276 bool Tempo::getShowMark()
const {
5280 void Tempo::setShowBeforeText(
bool show) {
5284 bool Tempo::getShowBeforeText()
const {
5288 void Tempo::setShowParenthesis(
bool show) {
5289 showParenthesis_ = show;
5292 bool Tempo::getShowParenthesis()
const {
5293 return showParenthesis_;
5296 void Tempo::setTypeTempo(
int tempo) {
5300 int Tempo::getTypeTempo()
const {
5304 int Tempo::getQuarterTempo()
const {
5305 double factor = pow(2.0, (
int) Note_Quarter - (
int) getLeftNoteType());
5306 int tempo = int((
double) getTypeTempo() * factor);
5311 void Tempo::setLeftText(
const QString& str) {
5315 QString Tempo::getLeftText()
const {
5319 void Tempo::setRightText(
const QString& str) {
5323 QString Tempo::getRightText()
const {
5327 void Tempo::setSwingEighth(
bool swing) {
5328 swingEighth_ = swing;
5331 bool Tempo::getSwingEighth()
const {
5332 return swingEighth_;
5335 void Tempo::setRightNoteType(
int type) {
5336 rightNoteType_ = type;
5339 int Tempo::getRightNoteType()
const {
5340 return rightNoteType_;
5345 musicDataType_ = MusicData_Text;
5347 textType_ = Text_Rehearsal;
5356 void Text::setTextType(TextType type) {
5360 Text::TextType Text::getTextType()
const {
5364 void Text::setHorizontalMargin(
int margin) {
5365 horiMargin_ = margin;
5368 int Text::getHorizontalMargin()
const {
5372 void Text::setVerticalMargin(
int margin) {
5373 vertMargin_ = margin;
5376 int Text::getVerticalMargin()
const {
5380 void Text::setLineThick(
int thick) {
5384 int Text::getLineThick()
const {
5388 void Text::setText(
const QString& text) {
5392 QString Text::getText()
const {
5396 void Text::setWidth(
int width) {
5400 int Text::getWidth()
const {
5404 void Text::setHeight(
int height) {
5408 int Text::getHeight()
const {
5413 TimeSignature::TimeSignature() {
5419 barLengthUnits_ = 0x400;
5420 replaceFont_ =
false;
5421 showBeatGroup_ =
false;
5423 groupNumerator1_ = 0;
5424 groupNumerator2_ = 0;
5425 groupNumerator3_ = 0;
5426 groupDenominator1_ = 4;
5427 groupDenominator2_ = 4;
5428 groupDenominator3_ = 4;
5439 void TimeSignature::setNumerator(
int numerator) {
5440 numerator_ = numerator;
5443 int TimeSignature::getNumerator()
const {
5447 void TimeSignature::setDenominator(
int denominator) {
5448 denominator_ = denominator;
5451 int TimeSignature::getDenominator()
const {
5452 return denominator_;
5455 void TimeSignature::setIsSymbol(
bool symbol) {
5459 bool TimeSignature::getIsSymbol()
const {
5460 if (numerator_ == 2 && denominator_ == 2) {
5467 void TimeSignature::setBeatLength(
int length) {
5468 beatLength_ = length;
5471 int TimeSignature::getBeatLength()
const {
5475 void TimeSignature::setBarLength(
int length) {
5476 barLength_ = length;
5479 int TimeSignature::getBarLength()
const {
5483 void TimeSignature::addBeat(
int startUnit,
int lengthUnit,
int startTick) {
5485 node.startUnit_ = startUnit;
5486 node.lengthUnit_ = lengthUnit;
5487 node.startTick_ = startTick;
5488 beats_.push_back(node);
5491 void TimeSignature::endAddBeat()
5494 barLengthUnits_ = 0;
5496 for (i = 0; i < beats_.size(); ++i) {
5497 barLengthUnits_ += beats_[i].lengthUnit_;
5501 int TimeSignature::getUnits()
const {
5502 return barLengthUnits_;
5505 void TimeSignature::setReplaceFont(
bool replace) {
5506 replaceFont_ = replace;
5509 bool TimeSignature::getReplaceFont()
const {
5510 return replaceFont_;
5513 void TimeSignature::setShowBeatGroup(
bool show) {
5514 showBeatGroup_ = show;
5517 bool TimeSignature::getShowBeatGroup()
const {
5518 return showBeatGroup_;
5521 void TimeSignature::setGroupNumerator1(
int numerator) {
5522 groupNumerator1_ = numerator;
5525 void TimeSignature::setGroupNumerator2(
int numerator) {
5526 groupNumerator2_ = numerator;
5529 void TimeSignature::setGroupNumerator3(
int numerator) {
5530 groupNumerator3_ = numerator;
5533 void TimeSignature::setGroupDenominator1(
int denominator) {
5534 groupDenominator1_ = denominator;
5537 void TimeSignature::setGroupDenominator2(
int denominator) {
5538 groupDenominator2_ = denominator;
5541 void TimeSignature::setGroupDenominator3(
int denominator) {
5542 groupDenominator3_ = denominator;
5545 void TimeSignature::setBeamGroup1(
int count) {
5546 beamGroup1_ = count;
5549 void TimeSignature::setBeamGroup2(
int count) {
5550 beamGroup2_ = count;
5553 void TimeSignature::setBeamGroup3(
int count) {
5554 beamGroup3_ = count;
5557 void TimeSignature::setBeamGroup4(
int count) {
5558 beamGroup4_ = count;
5561 void TimeSignature::set16thBeamCount(
int count) {
5562 beamCount16th_ = count;
5565 void TimeSignature::set32thBeamCount(
int count) {
5566 beamCount32th_ = count;
5577 void Key::setKey(
int key) {
5582 int Key::getKey()
const {
5586 bool Key::getSetKey()
const {
5590 void Key::setPreviousKey(
int key) {
5594 int Key::getPreviousKey()
const {
5595 return previousKey_;
5598 void Key::setSymbolCount(
int count) {
5599 symbolCount_ = count;
5602 int Key::getSymbolCount()
const {
5603 return symbolCount_;
5607 RepeatSymbol::RepeatSymbol() :
5608 text_(
"#1"), repeatType_(Repeat_Segno) {
5609 musicDataType_ = MusicData_Repeat;
5612 void RepeatSymbol::setText(
const QString& text) {
5616 QString RepeatSymbol::getText()
const {
5620 void RepeatSymbol::setRepeatType(
int repeatType) {
5621 repeatType_ = (RepeatType) repeatType;
5624 RepeatType RepeatSymbol::getRepeatType()
const {
5629 NumericEnding::NumericEnding() {
5630 musicDataType_ = MusicData_Numeric_Ending;
5634 numericHandle_ =
new OffsetElement();
5637 NumericEnding::~NumericEnding() {
5638 delete numericHandle_;
5641 OffsetElement* NumericEnding::getNumericHandle()
const {
5642 return numericHandle_;
5645 void NumericEnding::setHeight(
int height) {
5649 int NumericEnding::getHeight()
const {
5653 void NumericEnding::setText(
const QString& text) {
5657 QString NumericEnding::getText()
const {
5661 QList<int> NumericEnding::getNumbers()
const {
5663 QStringList strs = text_.split(
",", QString::SkipEmptyParts);
5666 for (i = 0; i < strs.size(); ++i) {
5668 int num = strs[i].toInt(&ok);
5669 endings.push_back(num);
5675 int NumericEnding::getJumpCount()
const {
5676 QList<int> numbers = getNumbers();
5679 for (
int i = 0; i < numbers.size(); ++i) {
5680 if ((
int)i + 1 != numbers[i]) {
5691 BarNumber::BarNumber() {
5693 showOnParagraphStart_ =
false;
5697 prefix_ = QString();
5700 void BarNumber::setIndex(
int index) {
5704 int BarNumber::getIndex()
const {
5708 void BarNumber::setShowOnParagraphStart(
bool show) {
5709 showOnParagraphStart_ = show;
5712 bool BarNumber::getShowOnParagraphStart()
const {
5713 return showOnParagraphStart_;
5716 void BarNumber::setAlign(
int align)
5721 int BarNumber::getAlign()
const {
5725 void BarNumber::setShowFlag(
int flag) {
5729 int BarNumber::getShowFlag()
const {
5733 void BarNumber::setShowEveryBarCount(
int count) {
5737 int BarNumber::getShowEveryBarCount()
const {
5741 void BarNumber::setPrefix(
const QString& str) {
5745 QString BarNumber::getPrefix()
const {
5750 MidiController::MidiController() {
5751 midiType_ = Midi_Controller;
5756 void MidiController::setController(
int number) {
5757 controller_ = number;
5760 int MidiController::getController()
const {
5764 void MidiController::setValue(
int value) {
5768 int MidiController::getValue()
const {
5773 MidiProgramChange::MidiProgramChange() {
5774 midiType_ = Midi_Program_Change;
5778 void MidiProgramChange::setPatch(
int patch) {
5782 int MidiProgramChange::getPatch()
const {
5787 MidiChannelPressure::MidiChannelPressure() :
5789 midiType_ = Midi_Channel_Pressure;
5792 void MidiChannelPressure::setPressure(
int pressure) {
5793 pressure_ = pressure;
5796 int MidiChannelPressure::getPressure()
const {
5801 MidiPitchWheel::MidiPitchWheel() {
5802 midiType_ = Midi_Pitch_Wheel;
5806 void MidiPitchWheel::setValue(
int value) {
5810 int MidiPitchWheel::getValue()
const {
5815 Measure::Measure(
int index) {
5816 barNumber_ =
new BarNumber();
5817 barNumber_->setIndex(index);
5818 time_ =
new TimeSignature();
5823 Measure::~Measure(){
5830 BarNumber* Measure::getBarNumber()
const {
5834 TimeSignature* Measure::getTime()
const {
5838 void Measure::setLeftBarline(
int barline) {
5839 leftBarline_ = (BarlineType) barline;
5842 BarlineType Measure::getLeftBarline()
const {
5843 return leftBarline_;
5846 void Measure::setRightBarline(
int barline) {
5847 rightBarline_ = (BarlineType) barline;
5850 BarlineType Measure::getRightBarline()
const {
5851 return rightBarline_;
5854 void Measure::setBackwardRepeatCount(
int repeatCount) {
5855 repeatCount_ = repeatCount;
5858 int Measure::getBackwardRepeatCount()
const {
5859 return repeatCount_;
5862 void Measure::setTypeTempo(
double tempo) {
5866 double Measure::getTypeTempo()
const {
5870 void Measure::setIsPickup(
bool pickup) {
5874 bool Measure::getIsPickup()
const {
5878 void Measure::setIsMultiMeasureRest(
bool rest) {
5879 multiMeasureRest_ = rest;
5882 bool Measure::getIsMultiMeasureRest()
const {
5883 return multiMeasureRest_;
5886 void Measure::setMultiMeasureRestCount(
int count) {
5887 multiMeasureRestCount_ = count;
5890 int Measure::getMultiMeasureRestCount()
const {
5891 return multiMeasureRestCount_;
5894 void Measure::clear() {
5895 leftBarline_ = Barline_Default;
5896 rightBarline_ = Barline_Default;
5901 multiMeasureRest_ =
false;
5902 multiMeasureRestCount_ = 0;
5906 MeasureData::MeasureData() {
5911 MeasureData::~MeasureData(){
5913 for(i=0; i<musicDatas_.size(); ++i){
5914 delete musicDatas_[i];
5916 musicDatas_.clear();
5919 noteContainers_.clear();
5922 for(i=0; i<crossMeasureElements_.size(); ++i){
5923 if(crossMeasureElements_[i].second){
5924 delete crossMeasureElements_[i].first;
5927 crossMeasureElements_.clear();
5929 for(i=0; i<midiDatas_.size(); ++i){
5930 delete midiDatas_[i];
5938 Key* MeasureData::getKey()
const {
5942 Clef* MeasureData::getClef()
const {
5946 void MeasureData::addNoteContainer(NoteContainer* ptr) {
5947 noteContainers_.push_back(ptr);
5950 QList<NoteContainer*> MeasureData::getNoteContainers()
const {
5951 return noteContainers_;
5954 void MeasureData::addMusicData(MusicData* ptr) {
5955 musicDatas_.push_back(ptr);
5958 QList<MusicData*> MeasureData::getMusicDatas(MusicDataType type) {
5960 QList<MusicData*> notations;
5962 for (i = 0; i < musicDatas_.size(); ++i) {
5963 if (type == MusicData_None || musicDatas_[i]->getMusicDataType() == type) {
5964 notations.push_back(musicDatas_[i]);
5971 void MeasureData::addCrossMeasureElement(MusicData* ptr,
bool start) {
5972 crossMeasureElements_.push_back(qMakePair(ptr, start));
5975 QList<MusicData*> MeasureData::getCrossMeasureElements(
5976 MusicDataType type, PairType pairType)
5979 QList<MusicData*> pairs;
5981 for (i = 0; i < crossMeasureElements_.size(); ++i) {
5982 if ((type == MusicData_None || crossMeasureElements_[i].first->getMusicDataType() == type)
5983 && (pairType == PairType_All || ((crossMeasureElements_[i].second && pairType == PairType_Start)
5984 || (!crossMeasureElements_[i].second && pairType == PairType_Stop)))) {
5985 pairs.push_back(crossMeasureElements_[i].first);
5992 void MeasureData::addMidiData(MidiData* ptr) {
5993 midiDatas_.push_back(ptr);
5996 QList<MidiData*> MeasureData::getMidiDatas(MidiType type) {
5998 QList<MidiData*> datas;
6000 for (i = 0; i < midiDatas_.size(); ++i) {
6001 if (type == Midi_None || midiDatas_[i]->getMidiType() == type) {
6002 datas.push_back(midiDatas_[i]);
6011 StreamHandle::StreamHandle() :
6012 size_(0), curPos_(0), point_(NULL) {
6015 StreamHandle::StreamHandle(
unsigned char* p,
int size) :
6016 size_(size), curPos_(0), point_(p) {
6019 StreamHandle::~StreamHandle() {
6023 bool StreamHandle::read(
char* buff,
int size) {
6024 if (point_ != NULL && curPos_ + size <= size_) {
6025 memcpy(buff, point_ + curPos_, size);
6034 bool StreamHandle::write(
char* ,
int ) {
6044 Block::Block(
unsigned int count) {
6048 void Block::resize(
unsigned int count) {
6052 void Block::doResize(
unsigned int count) {
6054 for(
unsigned int i=0; i<count; ++i) {
6055 data_.push_back(
'\0');
6060 const unsigned char* Block::data()
const {
6062 return &data_.front();
6065 unsigned char* Block::data() {
6066 return &data_.front();
6069 unsigned int Block::size()
const {
6070 return data_.size();
6073 bool Block::toBoolean()
const {
6074 if (data() == NULL) {
6078 return size() == 1 && data()[0] == 0x01;
6081 unsigned int Block::toUnsignedInt()
const {
6082 if (data() == NULL) {
6087 unsigned int num(0);
6089 for (i = 0; i <
sizeof(
unsigned int) && i < size(); ++i) {
6090 num = (num << 8) + *(data() + i);
6096 int Block::toInt()
const {
6097 if (data() == NULL) {
6104 for (i = 0; i <
sizeof(
unsigned int) && i < size(); ++i) {
6105 num = (num << 8) + (
int) *(data() + i);
6108 std::size_t minSize =
sizeof(
unsigned int);
6109 if (size() < minSize) {
6113 if ((*(data()) & 0x80) == 0x80) {
6114 int maxNum = int(pow(2.0, (
int) minSize * 8));
6122 QByteArray Block::toStrByteArray()
const {
6123 if (data() == NULL) {
6124 return QByteArray();
6127 QByteArray arr((
char*) data(), size());
6132 QByteArray Block::fixedSizeBufferToStrByteArray()
const {
6136 for (i = 0; i < size(); ++i) {
6137 if (*(data() + i) ==
'\0') {
6141 str += (char) *(data() + i);
6147 bool Block::operator ==(
const Block& block)
const {
6150 if (size() != block.size()) {
6154 for (i = 0; i < size() && i < block.size(); ++i) {
6155 if (*(data() + i) != *(block.data() + i)) {
6163 bool Block::operator !=(
const Block& block)
const {
6164 return !(*
this == block);
6168 FixedBlock::FixedBlock() :
6172 FixedBlock::FixedBlock(
unsigned int count) :
6176 void FixedBlock::resize(
unsigned int ) {
6181 SizeBlock::SizeBlock() :
6185 unsigned int SizeBlock::toSize()
const {
6187 unsigned int num(0);
6188 const unsigned int SIZE = 4;
6190 for (i = 0; i < SIZE; ++i) {
6191 num = (num << 8) + *(data() + i);
6203 NameBlock::NameBlock() :
6217 bool NameBlock::isEqual(
const QString& name)
const 6219 unsigned int i, nsize = static_cast<unsigned>(name.size());
6221 if (nsize != size()) {
6225 for (i = 0; i < size() && nsize; ++i) {
6226 if (data()[i] != name[i]) {
6235 CountBlock::CountBlock() :
6251 unsigned short CountBlock::toCount()
const {
6253 unsigned short num = 0;
6255 for (i = 0; i < size() && i <
sizeof(
unsigned short); ++i) {
6256 num = (num << 8) + *(data() + i);
6263 const QString Chunk::TrackName =
"TRAK";
6264 const QString Chunk::PageName =
"PAGE";
6265 const QString Chunk::LineName =
"LINE";
6266 const QString Chunk::StaffName =
"STAF";
6267 const QString Chunk::MeasureName =
"MEAS";
6268 const QString Chunk::ConductName =
"COND";
6269 const QString Chunk::BdatName =
"BDAT";
6274 NameBlock Chunk::getName()
const {
6279 const unsigned int SizeChunk::version3TrackSize = 0x13a;
6281 SizeChunk::SizeChunk() :
6283 sizeBlock_ =
new SizeBlock();
6284 dataBlock_ =
new Block();
6287 SizeChunk::~SizeChunk() {
6292 SizeBlock* SizeChunk::getSizeBlock()
const {
6296 Block* SizeChunk::getDataBlock()
const {
6301 GroupChunk::GroupChunk() : Chunk() {
6302 childCount_ =
new CountBlock();
6305 GroupChunk::~GroupChunk() {
6309 CountBlock* GroupChunk::getCountBlock()
const {
6314 unsigned int getHighNibble(
unsigned int byte) {
6318 unsigned int getLowNibble(
unsigned int byte) {
6322 int oveKeyToKey(
int oveKey) {
6328 else if( oveKey > 7 ) {
6331 else if( oveKey <= 7 ) {
6332 key = oveKey * (-1);
6339 BasicParse::BasicParse(OveSong* ove) :
6340 ove_(ove), handle_(NULL), notify_(NULL) {
6343 BasicParse::BasicParse() :
6344 ove_(NULL), handle_(NULL), notify_(NULL) {
6347 BasicParse::~BasicParse() {
6353 void BasicParse::setNotify(IOveNotify* notify) {
6357 bool BasicParse::parse() {
6361 bool BasicParse::readBuffer(Block& placeHolder,
unsigned int size) {
6362 if (handle_ == NULL) {
6365 if (placeHolder.size() != size) {
6366 placeHolder.resize(size);
6370 return handle_->read((
char*) placeHolder.data(), placeHolder.size());
6376 bool BasicParse::jump(
int offset) {
6377 if (handle_ == NULL || offset < 0) {
6382 Block placeHolder(offset);
6383 return handle_->read((
char*) placeHolder.data(), placeHolder.size());
6389 void BasicParse::messageOut(
const QString& str) {
6390 if (notify_ != NULL) {
6391 notify_->loadInfo(str);
6396 OvscParse::OvscParse(OveSong* ove) :
6397 BasicParse(ove), chunk_(NULL) {
6400 OvscParse::~OvscParse() {
6404 void OvscParse::setOvsc(SizeChunk* chunk) {
6408 bool OvscParse::parse() {
6409 Block* dataBlock = chunk_->getDataBlock();
6410 unsigned int blockSize = chunk_->getSizeBlock()->toSize();
6411 StreamHandle handle(dataBlock->data(), blockSize);
6417 if (!readBuffer(placeHolder, 1)) {
return false; }
6418 bool version4 = placeHolder.toUnsignedInt() == 4;
6419 ove_->setIsVersion4(version4);
6421 QString str = QString(
"This file is created by Overture ") + (version4 ?
"4" :
"3");
6424 if( !jump(6) ) {
return false; }
6427 if (!readBuffer(placeHolder, 1)) {
return false; }
6428 ove_->setShowPageMargin(placeHolder.toBoolean());
6430 if( !jump(1) ) {
return false; }
6433 if (!readBuffer(placeHolder, 1)) {
return false; }
6434 ove_->setShowTransposeTrack(placeHolder.toBoolean());
6437 if (!readBuffer(placeHolder, 1)) {
return false; }
6438 ove_->setPlayRepeat(placeHolder.toBoolean());
6441 if (!readBuffer(placeHolder, 1)) {
return false; }
6442 OveSong::PlayStyle style = OveSong::Record;
6443 if(placeHolder.toUnsignedInt() == 1){
6444 style = OveSong::Swing;
6446 else if(placeHolder.toUnsignedInt() == 2){
6447 style = OveSong::Notation;
6449 ove_->setPlayStyle(style);
6452 if (!readBuffer(placeHolder, 1)) {
return false; }
6453 ove_->setShowLineBreak(placeHolder.toBoolean());
6456 if (!readBuffer(placeHolder, 1)) {
return false; }
6457 ove_->setShowRuler(placeHolder.toBoolean());
6460 if (!readBuffer(placeHolder, 1)) {
return false; }
6461 ove_->setShowColor(placeHolder.toBoolean());
6467 TrackParse::TrackParse(OveSong* ove)
6471 TrackParse::~TrackParse() {
6474 void TrackParse::setTrack(SizeChunk* chunk) {
6478 bool TrackParse::parse()
6480 Block* dataBlock = chunk_->getDataBlock();
6481 unsigned int blockSize = ove_->getIsVersion4() ? chunk_->getSizeBlock()->toSize() : SizeChunk::version3TrackSize;
6482 StreamHandle handle(dataBlock->data(), blockSize);
6487 Track* oveTrack =
new Track();
6488 ove_->addTrack(oveTrack);
6491 if( !readBuffer(placeHolder, 32) ) {
return false; }
6492 oveTrack->setName(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
6494 if( !readBuffer(placeHolder, 32) ) {
return false; }
6495 oveTrack->setBriefName(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
6497 if( !jump(8) ) {
return false; }
6498 if( !jump(1) ) {
return false; }
6501 if( !readBuffer(placeHolder, 1) ) {
return false; }
6502 unsigned int thisByte = placeHolder.toInt();
6503 oveTrack->setPatch(thisByte&0x7f);
6506 if( !readBuffer(placeHolder, 1) ) {
return false; }
6507 oveTrack->setShowName(placeHolder.toBoolean());
6510 if( !readBuffer(placeHolder, 1) ) {
return false; }
6511 oveTrack->setShowBriefName(placeHolder.toBoolean());
6513 if( !jump(1) ) {
return false; }
6516 if( !readBuffer(placeHolder, 1) ) {
return false; }
6517 oveTrack->setShowTranspose(placeHolder.toBoolean());
6519 if( !jump(1) ) {
return false; }
6522 if( !readBuffer(placeHolder, 1) ) {
return false; }
6523 oveTrack->setMute(placeHolder.toBoolean());
6526 if( !readBuffer(placeHolder, 1) ) {
return false; }
6527 oveTrack->setSolo(placeHolder.toBoolean());
6529 if( !jump(1) ) {
return false; }
6532 if( !readBuffer(placeHolder, 1) ) {
return false; }
6533 oveTrack->setShowKeyEachLine(placeHolder.toBoolean());
6536 if( !readBuffer(placeHolder, 1) ) {
return false; }
6537 oveTrack->setVoiceCount(placeHolder.toUnsignedInt());
6539 if( !jump(3) ) {
return false; }
6542 if( !readBuffer(placeHolder, 1) ) {
return false; }
6543 oveTrack->setTranspose(placeHolder.toInt());
6545 if( !jump(2) ) {
return false; }
6548 if( !readBuffer(placeHolder, 1) ) {
return false; }
6549 oveTrack->setStartClef(placeHolder.toUnsignedInt());
6552 if( !readBuffer(placeHolder, 1) ) {
return false; }
6553 oveTrack->setTransposeClef(placeHolder.toUnsignedInt());
6556 if( !readBuffer(placeHolder, 1) ) {
return false; }
6557 oveTrack->setStartKey(placeHolder.toUnsignedInt());
6560 if( !readBuffer(placeHolder, 1) ) {
return false; }
6561 oveTrack->setDisplayPercent(placeHolder.toUnsignedInt());
6564 if( !readBuffer(placeHolder, 1) ) {
return false; }
6565 oveTrack->setShowLegerLine(placeHolder.toBoolean());
6568 if( !readBuffer(placeHolder, 1) ) {
return false; }
6569 oveTrack->setShowClef(placeHolder.toBoolean());
6572 if( !readBuffer(placeHolder, 1) ) {
return false; }
6573 oveTrack->setShowTimeSignature(placeHolder.toBoolean());
6576 if( !readBuffer(placeHolder, 1) ) {
return false; }
6577 oveTrack->setShowKeySignature(placeHolder.toBoolean());
6580 if( !readBuffer(placeHolder, 1) ) {
return false; }
6581 oveTrack->setShowBarline(placeHolder.toBoolean());
6584 if( !readBuffer(placeHolder, 1) ) {
return false; }
6585 oveTrack->setFillWithRest(placeHolder.toBoolean());
6588 if( !readBuffer(placeHolder, 1) ) {
return false; }
6589 oveTrack->setFlatTail(placeHolder.toBoolean());
6592 if( !readBuffer(placeHolder, 1) ) {
return false; }
6593 oveTrack->setShowClefEachLine(placeHolder.toBoolean());
6595 if( !jump(12) ) {
return false; }
6599 QList<Voice*> voices;
6600 for( i=0; i<8; ++i ) {
6601 Voice* voicePtr =
new Voice();
6603 if( !jump(5) ) {
return false; }
6606 if( !readBuffer(placeHolder, 1) ) {
return false; }
6607 voicePtr->setChannel(placeHolder.toUnsignedInt());
6610 if( !readBuffer(placeHolder, 1) ) {
return false; }
6611 voicePtr->setVolume(placeHolder.toInt());
6614 if( !readBuffer(placeHolder, 1) ) {
return false; }
6615 voicePtr->setPitchShift(placeHolder.toInt());
6618 if( !readBuffer(placeHolder, 1) ) {
return false; }
6619 voicePtr->setPan(placeHolder.toInt());
6621 if( !jump(6) ) {
return false; }
6624 if( !readBuffer(placeHolder, 1) ) {
return false; }
6625 voicePtr->setPatch(placeHolder.toInt());
6627 voices.push_back(voicePtr);
6631 for( i=0; i<8; ++i ) {
6632 if( !readBuffer(placeHolder, 1) ) {
return false; }
6633 voices[i]->setStemType(placeHolder.toUnsignedInt());
6635 oveTrack->addVoice(voices[i]);
6639 QList<Track::DrumNode> nodes;
6640 for(i=0; i<16; ++i) {
6641 nodes.push_back(Track::DrumNode());
6645 for( i=0; i<16; ++i ) {
6646 if( !readBuffer(placeHolder, 1) ) {
return false; }
6647 nodes[i].line_ = placeHolder.toInt();
6651 for( i=0; i<16; ++i ) {
6652 if( !readBuffer(placeHolder, 1) ) {
return false; }
6653 nodes[i].headType_ = placeHolder.toUnsignedInt();
6657 for( i=0; i<16; ++i ) {
6658 if( !readBuffer(placeHolder, 1) ) {
return false; }
6659 nodes[i].pitch_ = placeHolder.toUnsignedInt();
6663 for( i=0; i<16; ++i ) {
6664 if( !readBuffer(placeHolder, 1) ) {
return false; }
6665 nodes[i].voice_ = placeHolder.toUnsignedInt();
6668 for( i=0; i<nodes.size(); ++i ) {
6669 oveTrack->addDrum(nodes[i]);
6684 GroupParse::GroupParse(OveSong* ove)
6688 GroupParse::~GroupParse(){
6689 sizeChunks_.clear();
6692 void GroupParse::addSizeChunk(SizeChunk* sizeChunk) {
6693 sizeChunks_.push_back(sizeChunk);
6696 bool GroupParse::parse() {
6701 PageGroupParse::PageGroupParse(OveSong* ove)
6705 PageGroupParse::~PageGroupParse(){
6706 pageChunks_.clear();
6709 void PageGroupParse::addPage(SizeChunk* chunk) {
6710 pageChunks_.push_back(chunk);
6713 bool PageGroupParse::parse()
6715 if( pageChunks_.empty() ) {
6720 for( i=0; i<pageChunks_.size(); ++i ) {
6721 Page* page =
new Page();
6722 ove_->addPage(page);
6724 if( !parsePage(pageChunks_[i], page) ) {
return false; }
6730 bool PageGroupParse::parsePage(SizeChunk* chunk, Page* page) {
6731 Block placeHolder(2);
6732 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
6737 if( !readBuffer(placeHolder, 2) ) {
return false; }
6738 page->setBeginLine(placeHolder.toUnsignedInt());
6741 if( !readBuffer(placeHolder, 2) ) {
return false; }
6742 page->setLineCount(placeHolder.toUnsignedInt());
6744 if( !jump(4) ) {
return false; }
6747 if( !readBuffer(placeHolder, 2) ) {
return false; }
6748 page->setStaffInterval(placeHolder.toUnsignedInt());
6751 if( !readBuffer(placeHolder, 2) ) {
return false; }
6752 page->setLineInterval(placeHolder.toUnsignedInt());
6755 if( !readBuffer(placeHolder, 2) ) {
return false; }
6756 page->setStaffInlineInterval(placeHolder.toUnsignedInt());
6759 if( !readBuffer(placeHolder, 2) ) {
return false; }
6760 page->setLineBarCount(placeHolder.toUnsignedInt());
6763 if( !readBuffer(placeHolder, 2) ) {
return false; }
6764 page->setPageLineCount(placeHolder.toUnsignedInt());
6767 if( !readBuffer(placeHolder, 4) ) {
return false; }
6768 page->setLeftMargin(placeHolder.toUnsignedInt());
6771 if( !readBuffer(placeHolder, 4) ) {
return false; }
6772 page->setTopMargin(placeHolder.toUnsignedInt());
6775 if( !readBuffer(placeHolder, 4) ) {
return false; }
6776 page->setRightMargin(placeHolder.toUnsignedInt());
6779 if( !readBuffer(placeHolder, 4) ) {
return false; }
6780 page->setBottomMargin(placeHolder.toUnsignedInt());
6783 if( !readBuffer(placeHolder, 4) ) {
return false; }
6784 page->setPageWidth(placeHolder.toUnsignedInt());
6787 if( !readBuffer(placeHolder, 4) ) {
return false; }
6788 page->setPageHeight(placeHolder.toUnsignedInt());
6796 StaffCountGetter::StaffCountGetter(OveSong* ove)
6800 unsigned int StaffCountGetter::getStaffCount(SizeChunk* chunk) {
6801 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
6806 if( !jump(6) ) {
return false; }
6809 if( !readBuffer(placeHolder, 2) ) {
return false; }
6810 return placeHolder.toUnsignedInt();
6814 LineGroupParse::LineGroupParse(OveSong* ove) :
6815 BasicParse(ove), chunk_(NULL) {
6818 LineGroupParse::~LineGroupParse(){
6820 lineChunks_.clear();
6821 staffChunks_.clear();
6824 void LineGroupParse::setLineGroup(GroupChunk* chunk) {
6828 void LineGroupParse::addLine(SizeChunk* chunk) {
6829 lineChunks_.push_back(chunk);
6832 void LineGroupParse::addStaff(SizeChunk* chunk) {
6833 staffChunks_.push_back(chunk);
6836 bool LineGroupParse::parse()
6838 if( lineChunks_.empty() || staffChunks_.size() % lineChunks_.size() != 0 ) {
return false; }
6842 unsigned int lineStaffCount = staffChunks_.size() / lineChunks_.size();
6844 for( i=0; i<lineChunks_.size(); ++i ) {
6845 Line* linePtr =
new Line();
6847 ove_->addLine(linePtr);
6849 if( !parseLine(lineChunks_[i], linePtr) ) {
return false; }
6851 for( j=lineStaffCount*i; j<lineStaffCount*(i+1); ++j ) {
6852 Staff* staffPtr =
new Staff();
6854 linePtr->addStaff(staffPtr);
6856 if( !parseStaff(staffChunks_[j], staffPtr) ) {
return false; }
6863 bool LineGroupParse::parseLine(SizeChunk* chunk, Line* line) {
6866 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
6870 if( !jump(2) ) {
return false; }
6873 if( !readBuffer(placeHolder, 2) ) {
return false; }
6874 line->setBeginBar(placeHolder.toUnsignedInt());
6877 if( !readBuffer(placeHolder, 2) ) {
return false; }
6878 line->setBarCount(placeHolder.toUnsignedInt());
6880 if( !jump(6) ) {
return false; }
6883 if( !readBuffer(placeHolder, 2) ) {
return false; }
6884 line->setYOffset(placeHolder.toInt());
6887 if( !readBuffer(placeHolder, 2) ) {
return false; }
6888 line->setLeftXOffset(placeHolder.toInt());
6891 if( !readBuffer(placeHolder, 2) ) {
return false; }
6892 line->setRightXOffset(placeHolder.toInt());
6894 if( !jump(4) ) {
return false; }
6901 bool LineGroupParse::parseStaff(SizeChunk* chunk, Staff* staff) {
6904 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
6908 if( !jump(7) ) {
return false; }
6911 if( !readBuffer(placeHolder, 1) ) {
return false; }
6912 staff->setClefType(placeHolder.toUnsignedInt());
6915 if( !readBuffer(placeHolder, 1) ) {
return false; }
6916 staff->setKeyType(oveKeyToKey(placeHolder.toUnsignedInt()));
6918 if( !jump(2) ) {
return false; }
6921 if( !readBuffer(placeHolder, 1) ) {
return false; }
6922 staff->setVisible(placeHolder.toBoolean());
6924 if( !jump(12) ) {
return false; }
6927 if( !readBuffer(placeHolder, 2) ) {
return false; }
6928 staff->setYOffset(placeHolder.toInt());
6930 int jumpAmount = ove_->getIsVersion4() ? 26 : 18;
6931 if( !jump(jumpAmount) ) {
return false; }
6934 if( !readBuffer(placeHolder, 1) ) {
return false; }
6935 GroupType groupType = Group_None;
6936 if(placeHolder.toUnsignedInt() == 1) {
6937 groupType = Group_Brace;
6938 }
else if(placeHolder.toUnsignedInt() == 2) {
6939 groupType = Group_Bracket;
6941 staff->setGroupType(groupType);
6944 if( !readBuffer(placeHolder, 1) ) {
return false; }
6945 staff->setGroupStaffCount(placeHolder.toUnsignedInt());
6953 BarsParse::BarsParse(OveSong* ove) :
6957 BarsParse::~BarsParse(){
6958 measureChunks_.clear();
6959 conductChunks_.clear();
6960 bdatChunks_.clear();
6963 void BarsParse::addMeasure(SizeChunk* chunk) {
6964 measureChunks_.push_back(chunk);
6967 void BarsParse::addConduct(SizeChunk* chunk) {
6968 conductChunks_.push_back(chunk);
6971 void BarsParse::addBdat(SizeChunk* chunk) {
6972 bdatChunks_.push_back(chunk);
6975 bool BarsParse::parse() {
6977 int trackMeasureCount = ove_->getTrackBarCount();
6978 int trackCount = ove_->getTrackCount();
6979 int measureDataCount = trackCount * measureChunks_.size();
6980 QList<Measure*> measures;
6981 QList<MeasureData*> measureDatas;
6983 if( measureChunks_.empty() ||
6984 measureChunks_.size() != conductChunks_.size() ||
6985 (int)bdatChunks_.size() != measureDataCount ) {
6990 for ( i=0; i<(int)measureChunks_.size(); ++i ) {
6991 Measure* measure =
new Measure(i);
6993 measures.push_back(measure);
6994 ove_->addMeasure(measure);
6997 for ( i=0; i<measureDataCount; ++i ) {
6998 MeasureData* oveMeasureData =
new MeasureData();
7000 measureDatas.push_back(oveMeasureData);
7001 ove_->addMeasureData(oveMeasureData);
7004 for( i=0; i<(int)measureChunks_.size(); ++i ) {
7005 Measure* measure = measures[i];
7008 if( !parseMeas(measure, measureChunks_[i]) ) {
7009 QString ss =
"failed in parse MEAS " + i;
7016 for( i=0; i<(int)conductChunks_.size(); ++i ) {
7018 if( !parseCond(measures[i], measureDatas[i], conductChunks_[i]) ) {
7019 QString ss =
"failed in parse COND " + i;
7026 for( i=0; i<(int)bdatChunks_.size(); ++i ) {
7027 int measId = i % trackMeasureCount;
7030 if( !parseBdat(measures[measId], measureDatas[i], bdatChunks_[i]) ) {
7031 QString ss =
"failed in parse BDAT " + i;
7037 if( notify_ != NULL ) {
7038 int measureID = i % trackMeasureCount;
7039 int trackID = i / trackMeasureCount;
7045 notify_->loadPosition(measureID, trackMeasureCount, trackID, trackCount);
7052 bool BarsParse::parseMeas(Measure* measure, SizeChunk* chunk) {
7055 StreamHandle measureHandle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
7057 handle_ = &measureHandle;
7059 if( !jump(2) ) {
return false; }
7062 if( !readBuffer(placeHolder, 1) ) {
return false; }
7063 measure->setIsMultiMeasureRest(placeHolder.toBoolean());
7066 if( !readBuffer(placeHolder, 1) ) {
return false; }
7067 measure->setIsPickup(placeHolder.toBoolean());
7069 if( !jump(4) ) {
return false; }
7072 if( !readBuffer(placeHolder, 1) ) {
return false; }
7073 measure->setLeftBarline(placeHolder.toUnsignedInt());
7076 if( !readBuffer(placeHolder, 1) ) {
return false; }
7077 measure->setRightBarline(placeHolder.toUnsignedInt());
7080 if( !readBuffer(placeHolder, 2) ) {
return false; }
7081 double tempo = ((double)placeHolder.toUnsignedInt());
7082 if( ove_->getIsVersion4() ) {
7085 measure->setTypeTempo(tempo);
7088 if( !readBuffer(placeHolder, 2) ) {
return false; }
7089 measure->setLength(placeHolder.toUnsignedInt());
7091 if( !jump(6) ) {
return false; }
7094 if( !parseOffsetElement(measure->getBarNumber()) ) {
return false; }
7096 if( !jump(2) ) {
return false; }
7099 if( !readBuffer(placeHolder, 2) ) {
return false; }
7100 measure->setMultiMeasureRestCount(placeHolder.toUnsignedInt());
7107 bool BarsParse::parseCond(Measure* measure, MeasureData* measureData, SizeChunk* chunk) {
7110 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
7115 if( !readBuffer(placeHolder, 2) ) {
return false; }
7116 unsigned int cnt = placeHolder.toUnsignedInt();
7118 if( !parseTimeSignature(measure, 36) ) {
return false; }
7120 for(
unsigned int i=0; i<cnt; ++i ) {
7121 if( !readBuffer(placeHolder, 2) ) {
return false; }
7122 unsigned int twoByte = placeHolder.toUnsignedInt();
7123 unsigned int oldBlockSize = twoByte - 11;
7124 unsigned int newBlockSize = twoByte - 7;
7127 if( !readBuffer(placeHolder, 1) ) {
return false; }
7128 unsigned int thisByte = placeHolder.toUnsignedInt();
7131 if( !getCondElementType(thisByte, type) ) {
return false; }
7134 case Cond_Bar_Number: {
7135 if (!parseBarNumber(measure, twoByte - 1)) {
7141 if (!parseRepeatSymbol(measureData, oldBlockSize)) {
7146 case Cond_Numeric_Ending: {
7147 if (!parseNumericEndings(measureData, oldBlockSize)) {
7152 case Cond_Decorator: {
7153 if (!parseDecorators(measureData, newBlockSize)) {
7159 if (!parseTempo(measureData, newBlockSize)) {
7165 if (!parseText(measureData, newBlockSize)) {
7170 case Cond_Expression: {
7171 if (!parseExpressions(measureData, newBlockSize)) {
7176 case Cond_Time_Parameters: {
7177 if (!parseTimeSignatureParameters(measure, newBlockSize)) {
7182 case Cond_Barline_Parameters: {
7183 if (!parseBarlineParameters(measure, newBlockSize)) {
7189 if (!jump(newBlockSize)) {
7202 bool BarsParse::parseTimeSignature(Measure* measure,
int ) {
7205 TimeSignature* timeSignature = measure->getTime();
7208 if( !readBuffer(placeHolder, 1) ) {
return false; }
7209 timeSignature->setNumerator(placeHolder.toUnsignedInt());
7212 if( !readBuffer(placeHolder, 1) ) {
return false; }
7213 timeSignature->setDenominator(placeHolder.toUnsignedInt());
7215 if( !jump(2) ) {
return false; }
7218 if( !readBuffer(placeHolder, 2) ) {
return false; }
7219 timeSignature->setBeatLength(placeHolder.toUnsignedInt());
7222 if( !readBuffer(placeHolder, 2) ) {
return false; }
7223 timeSignature->setBarLength(placeHolder.toUnsignedInt());
7225 if( !jump(4) ) {
return false; }
7228 if( !readBuffer(placeHolder, 1) ) {
return false; }
7229 timeSignature->setIsSymbol(placeHolder.toBoolean());
7231 if( !jump(1) ) {
return false; }
7234 if( !readBuffer(placeHolder, 1) ) {
return false; }
7235 timeSignature->setReplaceFont(placeHolder.toBoolean());
7238 if( !readBuffer(placeHolder, 1) ) {
return false; }
7239 timeSignature->setColor(placeHolder.toUnsignedInt());
7242 if( !readBuffer(placeHolder, 1) ) {
return false; }
7243 timeSignature->setShow(placeHolder.toBoolean());
7246 if( !readBuffer(placeHolder, 1) ) {
return false; }
7247 timeSignature->setShowBeatGroup(placeHolder.toBoolean());
7249 if( !jump(6) ) {
return false; }
7252 if( !readBuffer(placeHolder, 1) ) {
return false; }
7253 timeSignature->setGroupNumerator1(placeHolder.toUnsignedInt());
7254 if( !readBuffer(placeHolder, 1) ) {
return false; }
7255 timeSignature->setGroupNumerator2(placeHolder.toUnsignedInt());
7256 if( !readBuffer(placeHolder, 1) ) {
return false; }
7257 timeSignature->setGroupNumerator3(placeHolder.toUnsignedInt());
7260 if( !readBuffer(placeHolder, 1) ) {
return false; }
7261 timeSignature->setGroupDenominator1(placeHolder.toUnsignedInt());
7262 if( !readBuffer(placeHolder, 1) ) {
return false; }
7263 timeSignature->setGroupDenominator2(placeHolder.toUnsignedInt());
7264 if( !readBuffer(placeHolder, 1) ) {
return false; }
7265 timeSignature->setGroupDenominator3(placeHolder.toUnsignedInt());
7268 if( !readBuffer(placeHolder, 1) ) {
return false; }
7269 timeSignature->setBeamGroup1(placeHolder.toUnsignedInt());
7270 if( !readBuffer(placeHolder, 1) ) {
return false; }
7271 timeSignature->setBeamGroup2(placeHolder.toUnsignedInt());
7272 if( !readBuffer(placeHolder, 1) ) {
return false; }
7273 timeSignature->setBeamGroup3(placeHolder.toUnsignedInt());
7274 if( !readBuffer(placeHolder, 1) ) {
return false; }
7275 timeSignature->setBeamGroup4(placeHolder.toUnsignedInt());
7278 if( !readBuffer(placeHolder, 1) ) {
return false; }
7279 timeSignature->set16thBeamCount(placeHolder.toUnsignedInt());
7282 if( !readBuffer(placeHolder, 1) ) {
return false; }
7283 timeSignature->set32thBeamCount(placeHolder.toUnsignedInt());
7288 bool BarsParse::parseTimeSignatureParameters(Measure* measure,
int length) {
7290 TimeSignature* ts = measure->getTime();
7292 int cursor = ove_->getIsVersion4() ? 10 : 8;
7293 if( !jump(cursor) ) {
return false; }
7296 if( !readBuffer(placeHolder, 1) ) {
return false; }
7297 unsigned int numerator = placeHolder.toUnsignedInt();
7299 cursor = ove_->getIsVersion4() ? 11 : 9;
7300 if( ( length - cursor ) % 8 != 0 || (length - cursor) / 8 != (
int)numerator ) {
7304 for(
unsigned int i =0; i<numerator; ++i ) {
7306 if( !readBuffer(placeHolder, 2) ) {
return false; }
7307 int beatStart = placeHolder.toUnsignedInt();
7310 if( !readBuffer(placeHolder, 2) ) {
return false; }
7311 int beatLength = placeHolder.toUnsignedInt();
7313 if( !jump(2) ) {
return false; }
7316 if( !readBuffer(placeHolder, 2) ) {
return false; }
7317 int beatStartTick = placeHolder.toUnsignedInt();
7319 ts->addBeat(beatStart, beatLength, beatStartTick);
7327 bool BarsParse::parseBarlineParameters(Measure* measure,
int ) {
7330 int cursor = ove_->getIsVersion4() ? 12 : 10;
7331 if( !jump(cursor) ) {
return false; }
7334 if( !readBuffer(placeHolder, 1) ) {
return false; }
7335 int repeatCount = placeHolder.toUnsignedInt();
7337 measure->setBackwardRepeatCount(repeatCount);
7339 if( !jump(6) ) {
return false; }
7344 bool BarsParse::parseNumericEndings(MeasureData* measureData,
int ) {
7347 NumericEnding* numeric =
new NumericEnding();
7348 measureData->addCrossMeasureElement(numeric,
true);
7350 if( !jump(3) ) {
return false; }
7353 if( !parseCommonBlock(numeric) ) {
return false; }
7355 if( !jump(6) ) {
return false; }
7358 if( !readBuffer(placeHolder, 2) ) {
return false; }
7360 int offsetMeasure = placeHolder.toUnsignedInt();
7361 numeric->stop()->setMeasure(offsetMeasure);
7363 if( !jump(2) ) {
return false; }
7366 if( !readBuffer(placeHolder, 2) ) {
return false; }
7367 numeric->getLeftShoulder()->setXOffset(placeHolder.toInt());
7370 if( !readBuffer(placeHolder, 2) ) {
return false; }
7371 numeric->setHeight(placeHolder.toUnsignedInt());
7374 if( !readBuffer(placeHolder, 2) ) {
return false; }
7375 numeric->getRightShoulder()->setXOffset(placeHolder.toInt());
7377 if( !jump(2) ) {
return false; }
7380 if( !readBuffer(placeHolder, 2) ) {
return false; }
7381 numeric->getLeftShoulder()->setYOffset(placeHolder.toInt());
7382 numeric->getRightShoulder()->setYOffset(placeHolder.toInt());
7385 if( !readBuffer(placeHolder, 2) ) {
return false; }
7386 numeric->getNumericHandle()->setXOffset(placeHolder.toInt());
7387 if( !readBuffer(placeHolder, 2) ) {
return false; }
7388 numeric->getNumericHandle()->setYOffset(placeHolder.toInt());
7390 if( !jump(6) ) {
return false; }
7393 if( !readBuffer(placeHolder, 1) ) {
return false; }
7394 unsigned int size = placeHolder.toUnsignedInt();
7397 if( !readBuffer(placeHolder, size) ) {
return false; }
7398 numeric->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7401 if( size % 2 == 0 ) {
7402 if( !jump(1) ) {
return false; }
7408 bool BarsParse::parseTempo(MeasureData* measureData,
int ) {
7410 unsigned int thisByte;
7412 Tempo* tempo =
new Tempo();
7413 measureData->addMusicData(tempo);
7415 if( !jump(3) ) {
return false; }
7418 if( !parseCommonBlock(tempo) ) {
return false; }
7420 if( !readBuffer(placeHolder, 1) ) {
return false; }
7421 thisByte = placeHolder.toUnsignedInt();
7424 tempo->setShowMark( (getHighNibble(thisByte) & 0x4) == 0x4 );
7426 tempo->setShowBeforeText( (getHighNibble(thisByte) & 0x8 ) == 0x8 ) ;
7428 tempo->setShowParenthesis( (getHighNibble(thisByte) & 0x1 ) == 0x1 );
7430 tempo->setLeftNoteType( getLowNibble(thisByte) );
7432 if( !jump(1) ) {
return false; }
7434 if( ove_->getIsVersion4() ) {
7435 if( !jump(2) ) {
return false; }
7438 if( !readBuffer(placeHolder, 2) ) {
return false; }
7439 tempo->setTypeTempo(placeHolder.toUnsignedInt()/100);
7442 if( !readBuffer(placeHolder, 2) ) {
return false; }
7443 tempo->setTypeTempo(placeHolder.toUnsignedInt());
7445 if( !jump(2) ) {
return false; }
7449 if( !parseOffsetElement(tempo) ) {
return false; }
7451 if( !jump(16) ) {
return false; }
7454 if( !readBuffer(placeHolder, 31) ) {
return false; }
7455 tempo->setLeftText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7457 if( !readBuffer(placeHolder, 1) ) {
return false; }
7458 thisByte = placeHolder.toUnsignedInt();
7461 tempo->setSwingEighth(getHighNibble(thisByte)!=8);
7464 tempo->setRightNoteType(getLowNibble(thisByte));
7467 if( ove_->getIsVersion4() ) {
7468 if( !readBuffer(placeHolder, 31) ) {
return false; }
7469 tempo->setRightText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7471 if( !jump(1) ) {
return false; }
7477 bool BarsParse::parseBarNumber(Measure* measure,
int ) {
7480 BarNumber* barNumber = measure->getBarNumber();
7482 if( !jump(2) ) {
return false; }
7485 if( !readBuffer(placeHolder, 1) ) {
return false; }
7486 barNumber->setShowOnParagraphStart(getLowNibble(placeHolder.toUnsignedInt())==8);
7488 unsigned int blankSize = ove_->getIsVersion4() ? 9 : 7;
7489 if( !jump(blankSize) ) {
return false; }
7492 if( !readBuffer(placeHolder, 1) ) {
return false; }
7493 barNumber->setAlign(placeHolder.toUnsignedInt());
7495 if( !jump(4) ) {
return false; }
7498 if( !readBuffer(placeHolder, 1) ) {
return false; }
7499 barNumber->setShowFlag(placeHolder.toUnsignedInt());
7501 if( !jump(10) ) {
return false; }
7504 if( !readBuffer(placeHolder, 1) ) {
return false; }
7505 barNumber->setShowEveryBarCount(placeHolder.toUnsignedInt());
7508 if( !readBuffer(placeHolder, 2) ) {
return false; }
7509 barNumber->setPrefix(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7511 if( !jump(18) ) {
return false; }
7516 bool BarsParse::parseText(MeasureData* measureData,
int length) {
7519 Text* text =
new Text();
7520 measureData->addMusicData(text);
7522 if( !jump(3) ) {
return false; }
7525 if( !parseCommonBlock(text) ) {
return false; }
7528 if( !readBuffer(placeHolder, 1) ) {
return false; }
7529 unsigned int thisByte = placeHolder.toUnsignedInt();
7530 bool includeLineBreak = ( (getHighNibble(thisByte)&0x2) != 0x2 );
7531 unsigned int id = getLowNibble(thisByte);
7532 Text::TextType textType = Text::Text_Rehearsal;
7535 textType = Text::Text_MeasureText;
7536 }
else if (
id == 1) {
7537 textType = Text::Text_SystemText;
7540 textType = Text::Text_Rehearsal;
7543 text->setTextType(textType);
7545 if( !jump(1) ) {
return false; }
7548 if( !readBuffer(placeHolder, 4) ) {
return false; }
7549 text->setXOffset(placeHolder.toInt());
7552 if( !readBuffer(placeHolder, 4) ) {
return false; }
7553 text->setYOffset(placeHolder.toInt());
7556 if( !readBuffer(placeHolder, 4) ) {
return false; }
7557 text->setWidth(placeHolder.toUnsignedInt());
7560 if( !readBuffer(placeHolder, 4) ) {
return false; }
7561 text->setHeight(placeHolder.toUnsignedInt());
7563 if( !jump(7) ) {
return false; }
7566 if( !readBuffer(placeHolder, 1) ) {
return false; }
7567 text->setHorizontalMargin(placeHolder.toUnsignedInt());
7569 if( !jump(1) ) {
return false; }
7572 if( !readBuffer(placeHolder, 1) ) {
return false; }
7573 text->setVerticalMargin(placeHolder.toUnsignedInt());
7575 if( !jump(1) ) {
return false; }
7578 if( !readBuffer(placeHolder, 1) ) {
return false; }
7579 text->setLineThick(placeHolder.toUnsignedInt());
7581 if( !jump(2) ) {
return false; }
7584 if( !readBuffer(placeHolder, 2) ) {
return false; }
7585 unsigned int size = placeHolder.toUnsignedInt();
7588 if( !readBuffer(placeHolder, size) ) {
return false; }
7589 text->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7591 if( !includeLineBreak ) {
7592 if( !jump(6) ) {
return false; }
7594 unsigned int cursor = ove_->getIsVersion4() ? 43 : 41;
7598 for(
unsigned int i=0; i<2; ++i ) {
7599 if( (
int)cursor < length ) {
7601 if( !readBuffer(placeHolder, 2) ) {
return false; }
7602 unsigned int lineCount = placeHolder.toUnsignedInt();
7604 if( i==0 &&
int(cursor + 2 + 8*lineCount) > length ) {
7608 if( i==1 &&
int(cursor + 2 + 8*lineCount) != length ) {
7612 if( !jump(8*lineCount) ) {
return false; }
7614 cursor += 2 + 8*lineCount;
7622 bool BarsParse::parseRepeatSymbol(MeasureData* measureData,
int ) {
7625 RepeatSymbol* repeat =
new RepeatSymbol();
7626 measureData->addMusicData(repeat);
7628 if( !jump(3) ) {
return false; }
7631 if( !parseCommonBlock(repeat) ) {
return false; }
7634 if( !readBuffer(placeHolder, 1) ) {
return false; }
7635 repeat->setRepeatType(placeHolder.toUnsignedInt());
7637 if( !jump(13) ) {
return false; }
7640 if( !parseOffsetElement(repeat) ) {
return false; }
7642 if( !jump(15) ) {
return false; }
7645 if( !readBuffer(placeHolder, 2) ) {
return false; }
7646 unsigned int size = placeHolder.toUnsignedInt();
7649 if( !readBuffer(placeHolder, size) ) {
return false; }
7650 repeat->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
7653 if( size % 2 == 0 ) {
7654 if( !jump(1) ) {
return false; }
7660 bool BarsParse::parseBdat(Measure* , MeasureData* measureData, SizeChunk* chunk) {
7662 StreamHandle handle(chunk->getDataBlock()->data(), chunk->getSizeBlock()->toSize());
7667 if( !readBuffer(placeHolder, 2) ) {
return false; }
7668 unsigned int cnt = placeHolder.toUnsignedInt();
7670 for(
unsigned int i=0; i<cnt; ++i ) {
7672 if( !readBuffer(placeHolder, 2) ) {
return false; }
7673 unsigned int count = placeHolder.toUnsignedInt() - 7;
7676 if( !readBuffer(placeHolder, 1) ) {
return false; }
7677 unsigned int thisByte = placeHolder.toUnsignedInt();
7680 if( !getBdatElementType(thisByte, type) ) {
return false; }
7683 case Bdat_Raw_Note :
7686 if( !parseNoteRest(measureData, count, type) ) {
return false; }
7690 if( !parseBeam(measureData, count) ) {
return false; }
7693 case Bdat_Harmony : {
7694 if( !parseHarmony(measureData, count) ) {
return false; }
7698 if( !parseClef(measureData, count) ) {
return false; }
7701 case Bdat_Dynamics : {
7702 if( !parseDynamics(measureData, count) ) {
return false; }
7706 if( !parseWedge(measureData, count) ) {
return false; }
7709 case Bdat_Glissando : {
7710 if( !parseGlissando(measureData, count) ) {
return false; }
7713 case Bdat_Decorator : {
7714 if( !parseDecorators(measureData, count) ) {
return false; }
7718 if( !parseKey(measureData, count) ) {
return false; }
7722 if( !parseLyric(measureData, count) ) {
return false; }
7725 case Bdat_Octave_Shift: {
7726 if( !parseOctaveShift(measureData, count) ) {
return false; }
7730 if( !parseSlur(measureData, count) ) {
return false; }
7734 if( !parseText(measureData, count) ) {
return false; }
7738 if( !parseTie(measureData, count) ) {
return false; }
7741 case Bdat_Tuplet : {
7742 if( !parseTuplet(measureData, count) ) {
return false; }
7745 case Bdat_Guitar_Bend :
7746 case Bdat_Guitar_Barre : {
7747 if( !parseSizeBlock(count) ) {
return false; }
7751 if( !parsePedal(measureData, count) ) {
return false; }
7755 if( !parseKuohao(measureData, count) ) {
return false; }
7758 case Bdat_Expressions: {
7759 if( !parseExpressions(measureData, count) ) {
return false; }
7762 case Bdat_Harp_Pedal: {
7763 if( !parseHarpPedal(measureData, count) ) {
return false; }
7766 case Bdat_Multi_Measure_Rest: {
7767 if( !parseMultiMeasureRest(measureData, count) ) {
return false; }
7770 case Bdat_Harmony_GuitarFrame: {
7771 if( !parseHarmonyGuitarFrame(measureData, count) ) {
return false; }
7774 case Bdat_Graphics_40:
7775 case Bdat_Graphics_RoundRect:
7776 case Bdat_Graphics_Rect:
7777 case Bdat_Graphics_Round:
7778 case Bdat_Graphics_Line:
7779 case Bdat_Graphics_Curve:
7780 case Bdat_Graphics_WedgeSymbol: {
7781 if( !parseSizeBlock(count) ) {
return false; }
7784 case Bdat_Midi_Controller : {
7785 if( !parseMidiController(measureData, count) ) {
return false; }
7788 case Bdat_Midi_Program_Change : {
7789 if( !parseMidiProgramChange(measureData, count) ) {
return false; }
7792 case Bdat_Midi_Channel_Pressure : {
7793 if( !parseMidiChannelPressure(measureData, count) ) {
return false; }
7796 case Bdat_Midi_Pitch_Wheel : {
7797 if( !parseMidiPitchWheel(measureData, count) ) {
return false; }
7801 if( !jump(count) ) {
return false; }
7814 int getInt(
int byte,
int bits) {
7818 int factor = int(pow(2.0, bits-1));
7819 num = (
byte % (factor*2));
7821 if ( (
byte & factor) == factor ) {
7829 bool BarsParse::parseNoteRest(MeasureData* measureData,
int length, BdatType type) {
7830 NoteContainer* container =
new NoteContainer();
7832 unsigned int thisByte;
7834 measureData->addNoteContainer(container);
7835 measureData->addMusicData(container);
7838 container->setIsRest(type==Bdat_Rest);
7839 container->setIsRaw(type==Bdat_Raw_Note);
7841 if( !readBuffer(placeHolder, 2) ) {
return false; }
7842 thisByte = placeHolder.toUnsignedInt();
7843 container->setIsGrace( thisByte == 0x3C00 );
7844 container->setIsCue( thisByte == 0x4B40 || thisByte == 0x3240 );
7847 if( !readBuffer(placeHolder, 1) ) {
return false; }
7848 thisByte = placeHolder.toUnsignedInt();
7849 container->setShow(getLowNibble(thisByte)!=0x8);
7852 container->setVoice(getLowNibble(thisByte)&0x7);
7855 if( !parseCommonBlock(container) ) {
return false; }
7858 if( !readBuffer(placeHolder, 1) ) {
return false; }
7859 container->setTuplet(placeHolder.toUnsignedInt());
7862 if( !readBuffer(placeHolder, 1) ) {
return false; }
7863 container->setSpace(placeHolder.toUnsignedInt());
7866 if( !readBuffer(placeHolder, 1) ) {
return false; }
7867 thisByte = placeHolder.toUnsignedInt();
7868 bool inBeam = ( getHighNibble(thisByte) & 0x1 ) == 0x1;
7869 container->setInBeam(inBeam);
7872 container->setGraceNoteType((NoteType)getHighNibble(thisByte));
7875 container->setDot(getLowNibble(thisByte)&0x03);
7878 if( !readBuffer(placeHolder, 1) ) {
return false; }
7879 thisByte = placeHolder.toUnsignedInt();
7880 container->setNoteType((NoteType)getLowNibble(thisByte));
7884 if( type == Bdat_Rest ) {
7885 Note* restPtr =
new Note();
7886 container->addNoteRest(restPtr);
7887 restPtr->setIsRest(
true);
7890 if( !readBuffer(placeHolder, 1) ) {
return false; }
7891 restPtr->setLine(placeHolder.toInt());
7893 if( !jump(1) ) {
return false; }
7895 cursor = ove_->getIsVersion4() ? 16 : 14;
7899 if( !readBuffer(placeHolder, 1) ) {
return false; }
7900 thisByte = placeHolder.toUnsignedInt();
7901 container->setStemUp((getHighNibble(thisByte)&0x8)==0x8);
7904 int stemOffset = thisByte%0x80;
7905 container->setStemLength(getInt(stemOffset, 7)+7);
7908 if( !readBuffer(placeHolder, 1) ) {
return false; }
7909 bool hideStem = getHighNibble(thisByte)==0x4;
7910 container->setShowStem(!hideStem);
7912 if( !jump(1) ) {
return false; }
7915 if( !readBuffer(placeHolder, 1) ) {
return false; }
7916 unsigned int noteCount = placeHolder.toUnsignedInt();
7920 for( i=0; i<noteCount; ++i ) {
7921 Note* notePtr =
new Note();
7922 notePtr->setIsRest(
false);
7924 container->addNoteRest(notePtr);
7927 if( !readBuffer(placeHolder, 1) ) {
return false; }
7928 thisByte = placeHolder.toUnsignedInt();
7929 notePtr->setShow((thisByte&0x80) != 0x80);
7932 notePtr->setHeadType(thisByte&0x7f);
7935 if( !readBuffer(placeHolder, 1) ) {
return false; }
7936 thisByte = placeHolder.toUnsignedInt();
7937 notePtr->setTiePos(getHighNibble(thisByte));
7940 if( !readBuffer(placeHolder, 1) ) {
return false; }
7941 thisByte = getLowNibble(placeHolder.toUnsignedInt());
7942 int offsetStaff = 0;
7943 if( thisByte == 1 ) { offsetStaff = 1; }
7944 if( thisByte == 7 ) { offsetStaff = -1; }
7945 notePtr->setOffsetStaff(offsetStaff);
7948 if( !readBuffer(placeHolder, 1) ) {
return false; }
7949 thisByte = placeHolder.toUnsignedInt();
7950 notePtr->setAccidental(getLowNibble(thisByte));
7952 bool notShow = ( getHighNibble(thisByte) == 0 ) || ( getHighNibble(thisByte) == 4 );
7953 notePtr->setShowAccidental(!notShow);
7955 if( !jump(1) ) {
return false; }
7958 if( !readBuffer(placeHolder, 1) ) {
return false; }
7959 notePtr->setLine(placeHolder.toInt());
7961 if( !jump(1) ) {
return false; }
7964 if( !readBuffer(placeHolder, 1) ) {
return false; }
7965 unsigned int note = placeHolder.toUnsignedInt();
7966 notePtr->setNote(note);
7969 if( !readBuffer(placeHolder, 1) ) {
return false; }
7970 unsigned int onVelocity = placeHolder.toUnsignedInt();
7971 notePtr->setOnVelocity(onVelocity);
7974 if( !readBuffer(placeHolder, 1) ) {
return false; }
7975 unsigned int offVelocity = placeHolder.toUnsignedInt();
7976 notePtr->setOffVelocity(offVelocity);
7978 if( !jump(2) ) {
return false; }
7981 if( !readBuffer(placeHolder, 2) ) {
return false; }
7982 container->setLength(placeHolder.toUnsignedInt());
7985 if( !readBuffer(placeHolder, 2) ) {
return false; }
7986 notePtr->setOffsetTick(placeHolder.toInt());
7989 cursor = ove_->getIsVersion4() ? 18 : 16;
7990 cursor += noteCount * 16;
7994 while ( cursor < length + 1 ) {
7995 Articulation* art =
new Articulation();
7996 container->addArticulation(art);
7999 if( !readBuffer(placeHolder, 2) ) {
return false; }
8000 int blockSize = placeHolder.toUnsignedInt();
8003 if( !readBuffer(placeHolder, 1) ) {
return false; }
8004 art->setArtType(placeHolder.toUnsignedInt());
8007 if( !readBuffer(placeHolder, 1) ) {
return false; }
8008 art->setPlacementAbove(placeHolder.toUnsignedInt()!=0x00);
8011 if( !parseOffsetElement(art) ) {
return false; }
8013 if( !ove_->getIsVersion4() ) {
8014 if( blockSize - 8 > 0 ) {
8015 if( !jump(blockSize-8) ) {
return false; }
8019 if( !readBuffer(placeHolder, 1) ) {
return false; }
8020 thisByte = placeHolder.toUnsignedInt();
8021 const bool changeSoundEffect = ( ( thisByte & 0x1 ) == 0x1 );
8022 const bool changeLength = ( ( thisByte & 0x2 ) == 0x2 );
8023 const bool changeVelocity = ( ( thisByte & 0x4 ) == 0x4 );
8026 if( !jump(8) ) {
return false; }
8029 if( !readBuffer(placeHolder, 1) ) {
return false; }
8030 thisByte = placeHolder.toUnsignedInt();
8031 if( changeVelocity ) {
8032 art->setVelocityType((Articulation::VelocityType)thisByte);
8035 if( !jump(14) ) {
return false; }
8038 if( !readBuffer(placeHolder, 2) ) {
return false; }
8039 int from = placeHolder.toInt();
8040 if( !readBuffer(placeHolder, 2) ) {
return false; }
8041 int to = placeHolder.toInt();
8042 if( changeSoundEffect ) {
8043 art->setSoundEffect(from, to);
8046 if( !jump(1) ) {
return false; }
8049 if( !readBuffer(placeHolder, 1) ) {
return false; }
8050 if( changeLength ) {
8051 art->setLengthPercentage(placeHolder.toUnsignedInt());
8055 if( !readBuffer(placeHolder, 2) ) {
return false; }
8056 if( changeVelocity ) {
8057 art->setVelocityValue(placeHolder.toInt());
8060 if( Articulation::isTrill(art->getArtType()) ) {
8061 if( !jump(8) ) {
return false; }
8064 if( !readBuffer(placeHolder, 1) ) {
return false; }
8065 art->setTrillNoteLength(placeHolder.toUnsignedInt());
8068 if( !readBuffer(placeHolder, 1) ) {
return false; }
8069 thisByte = placeHolder.toUnsignedInt();
8070 NoteType trillNoteType = Note_Sixteen;
8071 switch ( getHighNibble(thisByte) ) {
8073 trillNoteType = Note_None;
8076 trillNoteType = Note_Sixteen;
8079 trillNoteType = Note_32;
8082 trillNoteType = Note_64;
8085 trillNoteType = Note_128;
8090 art->setTrillRate(trillNoteType);
8093 art->setAccelerateType(thisByte&0xf);
8095 if( !jump(1) ) {
return false; }
8098 if( !readBuffer(placeHolder, 1) ) {
return false; }
8099 art->setAuxiliaryFirst(placeHolder.toBoolean());
8101 if( !jump(1) ) {
return false; }
8104 if( !readBuffer(placeHolder, 1) ) {
return false; }
8105 art->setTrillInterval(placeHolder.toUnsignedInt());
8107 if( blockSize > 40 ) {
8108 if( !jump( blockSize - 40 ) ) {
return false; }
8113 cursor += blockSize;
8119 int tupletToSpace(
int tuplet) {
8122 while( a*2 < tuplet ) {
8129 bool BarsParse::parseBeam(MeasureData* measureData,
int length)
8134 Beam* beam =
new Beam();
8135 measureData->addCrossMeasureElement(beam,
true);
8138 bool createTuplet =
false;
8140 Tuplet* tuplet =
new Tuplet();
8143 if( !readBuffer(placeHolder, 1) ) {
return false; }
8144 beam->setIsGrace(placeHolder.toBoolean());
8146 if( !jump(1) ) {
return false; }
8149 if( !readBuffer(placeHolder, 1) ) {
return false; }
8150 beam->setVoice(getLowNibble(placeHolder.toUnsignedInt())&0x7);
8153 if( !parseCommonBlock(beam) ) {
return false; }
8155 if( !jump(2) ) {
return false; }
8158 if( !readBuffer(placeHolder, 1) ) {
return false; }
8159 int beamCount = placeHolder.toUnsignedInt();
8161 if( !jump(1) ) {
return false; }
8164 if( !readBuffer(placeHolder, 1) ) {
return false; }
8165 beam->getLeftLine()->setLine(placeHolder.toInt());
8168 if( !readBuffer(placeHolder, 1) ) {
return false; }
8169 beam->getRightLine()->setLine(placeHolder.toInt());
8171 if( ove_->getIsVersion4() ) {
8172 if( !jump(8) ) {
return false; }
8175 int currentCursor = ove_->getIsVersion4() ? 23 : 13;
8176 int count = (length - currentCursor)/16;
8178 if( count != beamCount ) {
return false; }
8180 for( i=0; i<count; ++i ) {
8181 if( !jump(1) ) {
return false; }
8184 if( !readBuffer(placeHolder, 1) ) {
return false; }
8185 int tupletCount = placeHolder.toUnsignedInt();
8186 if( tupletCount > 0 ) {
8187 createTuplet =
true;
8188 tuplet->setTuplet(tupletCount);
8189 tuplet->setSpace(tupletToSpace(tupletCount));
8197 if( !readBuffer(placeHolder, 1) ) {
return false; }
8198 startMp.setMeasure(placeHolder.toUnsignedInt());
8199 if( !readBuffer(placeHolder, 1) ) {
return false; }
8200 stopMp.setMeasure(placeHolder.toUnsignedInt());
8202 if( !readBuffer(placeHolder, 2) ) {
return false; }
8203 startMp.setOffset(placeHolder.toInt());
8204 if( !readBuffer(placeHolder, 2) ) {
return false; }
8205 stopMp.setOffset(placeHolder.toInt());
8207 beam->addLine(startMp, stopMp);
8209 if( stopMp.getOffset() > maxEndUnit ) {
8210 maxEndUnit = stopMp.getOffset();
8214 if( !jump(4) ) {
return false; }
8217 if( !readBuffer(placeHolder, 2) ) {
return false; }
8218 beam->getLeftShoulder()->setYOffset(placeHolder.toInt());
8221 if( !readBuffer(placeHolder, 2) ) {
return false; }
8222 beam->getRightShoulder()->setYOffset(placeHolder.toInt());
8224 if( !jump(8) ) {
return false; }
8228 const QList<QPair<MeasurePos, MeasurePos> > lines = beam->getLines();
8229 MeasurePos offsetMp;
8231 for( i=0; i<lines.size(); ++i ) {
8232 if( lines[i].second > offsetMp ) {
8233 offsetMp = lines[i].second;
8237 beam->stop()->setMeasure(offsetMp.getMeasure());
8238 beam->stop()->setOffset(offsetMp.getOffset());
8241 if( createTuplet ) {
8242 tuplet->copyCommonBlock(*beam);
8243 tuplet->getLeftLine()->setLine(beam->getLeftLine()->getLine());
8244 tuplet->getRightLine()->setLine(beam->getRightLine()->getLine());
8245 tuplet->stop()->setMeasure(beam->stop()->getMeasure());
8246 tuplet->stop()->setOffset(maxEndUnit);
8248 measureData->addCrossMeasureElement(tuplet,
true);
8256 bool BarsParse::parseTie(MeasureData* measureData,
int ) {
8259 Tie* tie =
new Tie();
8260 measureData->addCrossMeasureElement(tie,
true);
8262 if( !jump(3) ) {
return false; }
8265 if( !parseCommonBlock(tie) ) {
return false; }
8267 if( !jump(1) ) {
return false; }
8270 if( !readBuffer(placeHolder, 1) ) {
return false; }
8271 tie->setNote(placeHolder.toUnsignedInt());
8274 if( !parsePairLinesBlock(tie) ) {
return false; }
8277 if( !parseOffsetCommonBlock(tie) ) {
return false; }
8280 if( !parseOffsetElement(tie->getLeftShoulder()) ) {
return false; }
8283 if( !parseOffsetElement(tie->getRightShoulder()) ) {
return false; }
8286 if( !readBuffer(placeHolder, 2) ) {
return false; }
8287 tie->setHeight(placeHolder.toUnsignedInt());
8292 bool BarsParse::parseTuplet(MeasureData* measureData,
int ) {
8295 Tuplet* tuplet =
new Tuplet();
8296 measureData->addCrossMeasureElement(tuplet,
true);
8298 if( !jump(3) ) {
return false; }
8301 if( !parseCommonBlock(tuplet) ) {
return false; }
8303 if( !jump(2) ) {
return false; }
8306 if( !parsePairLinesBlock(tuplet) ) {
return false; }
8309 if( !parseOffsetCommonBlock(tuplet) ) {
return false; }
8312 if( !parseOffsetElement(tuplet->getLeftShoulder()) ) {
return false; }
8315 if( !parseOffsetElement(tuplet->getRightShoulder()) ) {
return false; }
8317 if( !jump(2) ) {
return false; }
8320 if( !readBuffer(placeHolder, 2) ) {
return false; }
8321 tuplet->setHeight(placeHolder.toUnsignedInt());
8324 if( !readBuffer(placeHolder, 1) ) {
return false; }
8325 tuplet->setTuplet(placeHolder.toUnsignedInt());
8328 if( !readBuffer(placeHolder, 1) ) {
return false; }
8329 tuplet->setSpace(placeHolder.toUnsignedInt());
8332 if( !parseOffsetElement(tuplet->getMarkHandle()) ) {
return false; }
8337 HarmonyType binaryToHarmonyType(
int bin) {
8338 HarmonyType type = Harmony_maj;
8339 if( bin == 0x0091 ) {
8341 }
else if( bin == 0x0089 ) {
8343 }
else if( bin == 0x0489 ) {
8344 type = Harmony_min7;
8345 }
else if( bin == 0x0491 ) {
8347 }
else if( bin == 0x0495 ) {
8349 }
else if( bin == 0x0449 ) {
8350 type = Harmony_min7b5;
8351 }
else if( bin == 0x04A1 ) {
8352 type = Harmony_7sus4;
8353 }
else if( bin == 0x00A1 ) {
8354 type = Harmony_sus4;
8355 }
else if( bin == 0x0049 ) {
8357 }
else if( bin == 0x0249 ) {
8358 type = Harmony_dim7;
8359 }
else if( bin == 0x0111 ) {
8361 }
else if( bin == 0x0511 ) {
8362 type = Harmony_aug7;
8363 }
else if( bin == 0x044D ) {
8364 type = Harmony_min9_b5;
8365 }
else if( bin == 0x0499 ) {
8367 }
else if( bin == 0x0615 ) {
8369 }
else if( bin == 0x0289 ) {
8370 type = Harmony_min6;
8371 }
else if( bin == 0x0291 ) {
8373 }
else if( bin == 0x0295 ) {
8375 }
else if( bin == 0x0095 ) {
8377 }
else if( bin == 0x008D ) {
8378 type = Harmony_maj7;
8379 }
else if( bin == 0x0891 ) {
8380 type = Harmony_maj7;
8381 }
else if( bin == 0x0881 ) {
8382 type = Harmony_maj7_s5;
8383 }
else if( bin == 0x0911 ) {
8384 type = Harmony_maj7_s5;
8385 }
else if( bin == 0x0991 ) {
8386 type = Harmony_maj7_s11;
8387 }
else if( bin == 0x0851 ) {
8388 type = Harmony_maj7_s11;
8389 }
else if( bin == 0x08D1 ) {
8390 type = Harmony_maj9;
8391 }
else if( bin == 0x0895 ) {
8392 type = Harmony_maj9_s5;
8393 }
else if( bin == 0x0995 ) {
8394 type = Harmony_maj13_s11;
8395 }
else if( bin == 0x0855 ) {
8396 type = Harmony_maj9_s11;
8397 }
else if( bin == 0x08D5 ) {
8398 type = Harmony_maj13;
8399 }
else if( bin == 0x0A95 ) {
8400 type = Harmony_maj13_s11;
8401 }
else if( bin == 0x0A55 ) {
8402 type = Harmony_maj13;
8403 }
else if( bin == 0x0A85 ) {
8404 type = Harmony_maj9_s5;
8405 }
else if( bin == 0x0B45 ) {
8407 }
else if( bin == 0x0493 ) {
8409 }
else if( bin == 0x0451 ) {
8411 }
else if( bin == 0x0455 ) {
8413 }
else if( bin == 0x0519 ) {
8415 }
else if( bin == 0x0513 ) {
8416 type = Harmony_aug7;
8417 }
else if( bin == 0x0515 ) {
8418 type = Harmony_sus4;
8419 }
else if( bin == 0x04A5 ) {
8420 type = Harmony_13b9;
8421 }
else if( bin == 0x0613 ) {
8422 type = Harmony_13b9;
8423 }
else if( bin == 0x0611 ) {
8425 }
else if( bin == 0x0653 ) {
8427 }
else if( bin == 0x0889 ) {
8428 type = Harmony_min9;
8429 }
else if( bin == 0x088D ) {
8430 type = Harmony_min11;
8431 }
else if( bin == 0x04AD ) {
8432 type = Harmony_9s11;
8433 }
else if( bin == 0x04D5 ) {
8434 type = Harmony_7sus4;
8435 }
else if( bin == 0x0421 ) {
8436 type = Harmony_min11;
8437 }
else if( bin == 0x04A9 ) {
8438 type = Harmony_min9;
8439 }
else if( bin == 0x048D ) {
8440 type = Harmony_7b5b9;
8441 }
else if( bin == 0x0453 ) {
8443 }
else if( bin == 0x0011 ) {
8444 type = Harmony_maj7;
8445 }
else if( bin == 0x0081 ) {
8447 }
else if( bin == 0x0481 ) {
8449 }
else if( bin == 0x0411 ) {
8451 }
else if( bin == 0x0291 ) {
8452 type = Harmony_sus4;
8453 }
else if( bin == 0x00A5 ) {
8454 type = Harmony_13s9;
8455 }
else if( bin == 0x0659 ) {
8456 type = Harmony_sus4;
8457 }
else if( bin == 0x0021 ) {
8458 type = Harmony_7b5b9;
8459 }
else if( bin == 0x045B ) {
8460 type = Harmony_13b5;
8461 }
else if( bin == 0x065B ) {
8462 type = Harmony_13b9;
8463 }
else if( bin == 0x061B ) {
8464 type = Harmony_7b9s9;
8465 }
else if( bin == 0x04B5 ) {
8472 bool BarsParse::parseHarmony(MeasureData* measureData,
int ) {
8475 Harmony* harmony =
new Harmony();
8476 measureData->addMusicData(harmony);
8478 if( !jump(3) ) {
return false; }
8481 if( !parseCommonBlock(harmony) ) {
return false; }
8484 if( !readBuffer(placeHolder, 1) ) {
return false; }
8485 harmony->setBassOnBottom((getHighNibble(placeHolder.toUnsignedInt())==0x4));
8487 if( !jump(1) ) {
return false; }
8490 if( !readBuffer(placeHolder, 2) ) {
return false; }
8491 harmony->setYOffset(placeHolder.toInt());
8494 if( !readBuffer(placeHolder, 2) ) {
return false; }
8495 harmony->setHarmonyType(binaryToHarmonyType(placeHolder.toUnsignedInt()));
8498 if( !readBuffer(placeHolder, 1) ) {
return false; }
8499 harmony->setRoot(placeHolder.toInt());
8502 if( !readBuffer(placeHolder, 1) ) {
return false; }
8503 harmony->setBass(placeHolder.toInt());
8506 if( !readBuffer(placeHolder, 2) ) {
return false; }
8507 harmony->setAngle(placeHolder.toInt());
8509 if( ove_->getIsVersion4() ) {
8511 if( !readBuffer(placeHolder, 2) ) {
return false; }
8512 harmony->setLength(placeHolder.toUnsignedInt());
8514 if( !jump(4) ) {
return false; }
8520 bool BarsParse::parseClef(MeasureData* measureData,
int ) {
8523 Clef* clef =
new Clef();
8524 measureData->addMusicData(clef);
8526 if( !jump(3) ) {
return false; }
8529 if( !parseCommonBlock(clef) ) {
return false; }
8532 if( !readBuffer(placeHolder, 1) ) {
return false; }
8533 clef->setClefType(placeHolder.toUnsignedInt());
8536 if( !readBuffer(placeHolder, 1) ) {
return false; }
8537 clef->setLine(placeHolder.toInt());
8539 if( !jump(2) ) {
return false; }
8544 bool BarsParse::parseLyric(MeasureData* measureData,
int length) {
8547 Lyric*
lyric =
new Lyric();
8548 measureData->addMusicData(
lyric);
8550 if( !jump(3) ) {
return false; }
8553 if( !parseCommonBlock(
lyric) ) {
return false; }
8555 if( !jump(2) ) {
return false; }
8558 if( !parseOffsetElement(
lyric) ) {
return false; }
8560 if( !jump(7) ) {
return false; }
8563 if( !readBuffer(placeHolder, 1) ) {
return false; }
8564 lyric->setVerse(placeHolder.toUnsignedInt());
8566 if( ove_->getIsVersion4() ) {
8567 if( !jump(6) ) {
return false; }
8571 if( !readBuffer(placeHolder, length-29) ) {
return false; }
8572 lyric->setLyric(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
8579 bool BarsParse::parseSlur(MeasureData* measureData,
int ) {
8582 Slur* slur =
new Slur();
8583 measureData->addCrossMeasureElement(slur,
true);
8585 if( !jump(2) ) {
return false; }
8588 if( !readBuffer(placeHolder, 1) ) {
return false; }
8589 slur->setVoice(getLowNibble(placeHolder.toUnsignedInt())&0x7);
8592 if( !parseCommonBlock(slur) ) {
return false; }
8595 if( !readBuffer(placeHolder, 1) ) {
return false; }
8596 slur->setShowOnTop(getHighNibble(placeHolder.toUnsignedInt())==0x8);
8598 if( !jump(1) ) {
return false; }
8601 if( !parsePairLinesBlock(slur) ) {
return false; }
8604 if( !parseOffsetCommonBlock(slur) ) {
return false; }
8607 if( !parseOffsetElement(slur->getLeftShoulder()) ) {
return false; }
8610 if( !parseOffsetElement(slur->getRightShoulder()) ) {
return false; }
8613 if( !parseOffsetElement(slur->getHandle2()) ) {
return false; }
8616 if( !parseOffsetElement(slur->getHandle3()) ) {
return false; }
8618 if( ove_->getIsVersion4() ) {
8619 if( !jump(3) ) {
return false; }
8622 if( !readBuffer(placeHolder, 1) ) {
return false; }
8623 slur->setNoteTimePercent(placeHolder.toUnsignedInt());
8625 if( !jump(36) ) {
return false; }
8631 bool BarsParse::parseGlissando(MeasureData* measureData,
int ) {
8634 Glissando* glissando =
new Glissando();
8635 measureData->addCrossMeasureElement(glissando,
true);
8637 if( !jump(3) ) {
return false; }
8640 if( !parseCommonBlock(glissando) ) {
return false; }
8643 if( !readBuffer(placeHolder, 1) ) {
return false; }
8644 unsigned int thisByte = placeHolder.toUnsignedInt();
8645 glissando->setStraightWavy(getHighNibble(thisByte)==4);
8647 if( !jump(1) ) {
return false; }
8650 if( !parsePairLinesBlock(glissando) ) {
return false; }
8653 if( !parseOffsetCommonBlock(glissando) ) {
return false; }
8656 if( !parseOffsetElement(glissando->getLeftShoulder()) ) {
return false; }
8659 if( !parseOffsetElement(glissando->getRightShoulder()) ) {
return false; }
8661 if( ove_->getIsVersion4() ) {
8662 if( !jump(1) ) {
return false; }
8665 if( !readBuffer(placeHolder, 1) ) {
return false; }
8666 glissando->setLineThick(placeHolder.toUnsignedInt());
8668 if( !jump(12) ) {
return false; }
8671 if( !readBuffer(placeHolder, 32) ) {
return false; }
8672 glissando->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
8674 if( !jump(6) ) {
return false; }
8680 bool getDecoratorType(
8681 unsigned int thisByte,
8682 bool& measureRepeat,
8683 Decorator::DecoratorType& decoratorType,
8685 ArticulationType& artType) {
8686 measureRepeat =
false;
8687 decoratorType = Decorator::Decorator_Articulation;
8688 singleRepeat =
true;
8689 artType = Articulation_None;
8693 decoratorType = Decorator::Decorator_Dotted_Barline;
8697 artType = Articulation_Open_String;
8701 artType = Articulation_Finger_1;
8705 artType = Articulation_Finger_2;
8709 artType = Articulation_Finger_3;
8713 artType = Articulation_Finger_4;
8717 artType = Articulation_Finger_5;
8721 artType = Articulation_Flat_Accidental_For_Trill;
8725 artType = Articulation_Sharp_Accidental_For_Trill;
8729 artType = Articulation_Natural_Accidental_For_Trill;
8733 measureRepeat =
true;
8734 singleRepeat =
true;
8738 measureRepeat =
true;
8739 singleRepeat =
false;
8743 artType = Articulation_Minor_Trill;
8747 artType = Articulation_Major_Trill;
8751 artType = Articulation_Trill_Section;
8755 artType = Articulation_Turn;
8759 artType = Articulation_Tremolo_Eighth;
8763 artType = Articulation_Tremolo_Sixteenth;
8767 artType = Articulation_Tremolo_Thirty_Second;
8771 artType = Articulation_Tremolo_Sixty_Fourth;
8775 artType = Articulation_Fermata;
8779 artType = Articulation_Fermata_Inverted;
8783 artType = Articulation_Pause;
8787 artType = Articulation_Grand_Pause;
8791 artType = Articulation_Marcato;
8795 artType = Articulation_Marcato_Dot;
8799 artType = Articulation_SForzando;
8803 artType = Articulation_SForzando_Dot;
8807 artType = Articulation_SForzando_Inverted;
8811 artType = Articulation_SForzando_Dot_Inverted;
8815 artType = Articulation_Staccatissimo;
8819 artType = Articulation_Staccato;
8823 artType = Articulation_Tenuto;
8827 artType = Articulation_Natural_Harmonic;
8831 artType = Articulation_Artificial_Harmonic;
8835 artType = Articulation_Plus_Sign;
8839 artType = Articulation_Up_Bow;
8843 artType = Articulation_Down_Bow;
8847 artType = Articulation_Up_Bow_Inverted;
8851 artType = Articulation_Down_Bow_Inverted;
8855 artType = Articulation_Pedal_Down;
8859 artType = Articulation_Pedal_Up;
8863 artType = Articulation_Heavy_Attack;
8867 artType = Articulation_Heavier_Attack;
8878 bool BarsParse::parseDecorators(MeasureData* measureData,
int length) {
8880 MusicData* musicData =
new MusicData();
8882 if( !jump(3) ) {
return false; }
8885 if( !parseCommonBlock(musicData) ) {
return false; }
8887 if( !jump(2) ) {
return false; }
8890 if( !readBuffer(placeHolder, 2) ) {
return false; }
8891 musicData->setYOffset(placeHolder.toInt());
8893 if( !jump(2) ) {
return false; }
8896 if( !readBuffer(placeHolder, 1) ) {
return false; }
8897 unsigned int thisByte = placeHolder.toUnsignedInt();
8899 Decorator::DecoratorType decoratorType;
8900 bool isMeasureRepeat;
8901 bool isSingleRepeat =
true;
8902 ArticulationType artType = Articulation_None;
8904 getDecoratorType(thisByte, isMeasureRepeat, decoratorType, isSingleRepeat, artType);
8906 if( isMeasureRepeat ) {
8907 MeasureRepeat* measureRepeat =
new MeasureRepeat();
8908 measureData->addCrossMeasureElement(measureRepeat,
true);
8910 measureRepeat->copyCommonBlock(*musicData);
8911 measureRepeat->setYOffset(musicData->getYOffset());
8913 measureRepeat->setSingleRepeat(isSingleRepeat);
8915 Decorator* decorator =
new Decorator();
8916 measureData->addMusicData(decorator);
8918 decorator->copyCommonBlock(*musicData);
8919 decorator->setYOffset(musicData->getYOffset());
8921 decorator->setDecoratorType(decoratorType);
8922 decorator->setArticulationType(artType);
8925 int cursor = ove_->getIsVersion4() ? 16 : 14;
8926 if( !jump(length-cursor) ) {
return false; }
8931 bool BarsParse::parseWedge(MeasureData* measureData,
int length) {
8933 Wedge* wedge =
new Wedge();
8935 if( !jump(3) ) {
return false; }
8938 if( !parseCommonBlock(wedge) ) {
return false; }
8941 if( !readBuffer(placeHolder, 1) ) {
return false; }
8942 WedgeType wedgeType = Wedge_Cres_Line;
8943 bool wedgeOrExpression =
true;
8944 unsigned int highHalfByte = getHighNibble(placeHolder.toUnsignedInt());
8945 unsigned int lowHalfByte = getLowNibble(placeHolder.toUnsignedInt());
8947 switch (highHalfByte) {
8949 wedgeType = Wedge_Cres_Line;
8950 wedgeOrExpression =
true;
8954 wedgeType = Wedge_Decresc_Line;
8955 wedgeOrExpression =
true;
8959 wedgeType = Wedge_Decresc;
8960 wedgeOrExpression =
false;
8964 wedgeType = Wedge_Cres;
8965 wedgeOrExpression =
false;
8973 if( (lowHalfByte & 0x8) == 0x8 ) {
8974 wedgeType = Wedge_Double_Line;
8975 wedgeOrExpression =
true;
8978 if( !jump(1) ) {
return false; }
8981 if( !readBuffer(placeHolder, 2) ) {
return false; }
8982 wedge->setYOffset(placeHolder.toInt());
8985 if( wedgeOrExpression ) {
8986 measureData->addCrossMeasureElement(wedge,
true);
8987 wedge->setWedgeType(wedgeType);
8989 if( !jump(2) ) {
return false; }
8992 if( !readBuffer(placeHolder, 2) ) {
return false; }
8993 wedge->setHeight(placeHolder.toUnsignedInt());
8996 if( !parseOffsetCommonBlock(wedge) ) {
return false; }
8998 int cursor = ove_->getIsVersion4() ? 21 : 19;
8999 if( !jump(length-cursor) ) {
return false; }
9003 Expressions* express =
new Expressions();
9004 measureData->addMusicData(express);
9006 express->copyCommonBlock(*wedge);
9007 express->setYOffset(wedge->getYOffset());
9009 if( !jump(4) ) {
return false; }
9012 if( !parseOffsetCommonBlock(express) ) {
return false; }
9014 if( ove_->getIsVersion4() ) {
9015 if( !jump(18) ) {
return false; }
9019 if( !readBuffer(placeHolder, length-39) ) {
return false; }
9020 express->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
9023 QString str = wedgeType==Wedge_Cres ?
"cresc" :
"decresc";
9024 express->setText(str);
9026 if( !jump(8) ) {
return false; }
9033 bool BarsParse::parseDynamics(MeasureData* measureData,
int ) {
9036 Dynamics* dynamics =
new Dynamics();
9037 measureData->addMusicData(dynamics);
9039 if( !jump(1) ) {
return false; }
9042 if( !readBuffer(placeHolder, 1) ) {
return false; }
9043 dynamics->setIsPlayback(getHighNibble(placeHolder.toUnsignedInt())!=0x4);
9045 if( !jump(1) ) {
return false; }
9048 if( !parseCommonBlock(dynamics) ) {
return false; }
9051 if( !readBuffer(placeHolder, 2) ) {
return false; }
9052 dynamics->setYOffset(placeHolder.toInt());
9055 if( !readBuffer(placeHolder, 1) ) {
return false; }
9056 dynamics->setDynamicsType(getLowNibble(placeHolder.toUnsignedInt()));
9059 if( !readBuffer(placeHolder, 1) ) {
return false; }
9060 dynamics->setVelocity(placeHolder.toUnsignedInt());
9062 int cursor = ove_->getIsVersion4() ? 4 : 2;
9064 if( !jump(cursor) ) {
return false; }
9069 bool BarsParse::parseKey(MeasureData* measureData,
int ) {
9071 Key* key = measureData->getKey();
9072 int cursor = ove_->getIsVersion4() ? 9 : 7;
9074 if( !jump(cursor) ) {
return false; }
9077 if( !readBuffer(placeHolder, 1) ) {
return false; }
9078 key->setKey(oveKeyToKey(placeHolder.toUnsignedInt()));
9081 if( !readBuffer(placeHolder, 1) ) {
return false; }
9082 key->setPreviousKey(oveKeyToKey(placeHolder.toUnsignedInt()));
9084 if( !jump(3) ) {
return false; }
9087 if( !readBuffer(placeHolder, 1) ) {
return false; }
9088 key->setSymbolCount(placeHolder.toUnsignedInt());
9090 if( !jump(4) ) {
return false; }
9095 bool BarsParse::parsePedal(MeasureData* measureData,
int length) {
9098 Pedal* pedal =
new Pedal();
9100 measureData->addCrossMeasureElement(pedal,
true);
9102 if( !jump(1) ) {
return false; }
9105 if( !readBuffer(placeHolder, 1) ) {
return false; }
9106 pedal->setIsPlayback(getHighNibble(placeHolder.toUnsignedInt())!=4);
9108 if( !jump(1) ) {
return false; }
9111 if( !parseCommonBlock(pedal) ) {
return false; }
9113 if( !jump(2) ) {
return false; }
9116 if( !parsePairLinesBlock(pedal) ) {
return false; }
9119 if( !parseOffsetCommonBlock(pedal) ) {
return false; }
9122 if( !parseOffsetElement(pedal->getLeftShoulder()) ) {
return false; }
9125 if( !parseOffsetElement(pedal->getRightShoulder()) ) {
return false; }
9127 int cursor = ove_->getIsVersion4() ? 0x45 : 0x23;
9128 int blankCount = ove_->getIsVersion4() ? 42 : 10;
9130 pedal->setHalf( length > cursor );
9132 if( !jump(blankCount) ) {
return false; }
9134 if( length > cursor ) {
9135 if( !jump(2) ) {
return false; }
9138 if( !readBuffer(placeHolder, 2) ) {
return false; }
9139 pedal->getPedalHandle()->setXOffset(placeHolder.toInt());
9141 if( !jump(6) ) {
return false; }
9147 bool BarsParse::parseKuohao(MeasureData* measureData,
int ) {
9150 KuoHao* kuoHao =
new KuoHao();
9151 measureData->addMusicData(kuoHao);
9153 if( !jump(3) ) {
return false; }
9156 if( !parseCommonBlock(kuoHao) ) {
return false; }
9158 if( !jump(2) ) {
return false; }
9161 if( !parsePairLinesBlock(kuoHao) ) {
return false; }
9163 if( !jump(4) ) {
return false; }
9166 if( !parseOffsetElement(kuoHao->getLeftShoulder()) ) {
return false; }
9169 if( !parseOffsetElement(kuoHao->getRightShoulder()) ) {
return false; }
9172 if( !readBuffer(placeHolder, 1) ) {
return false; }
9173 kuoHao->setKuohaoType(placeHolder.toUnsignedInt());
9176 if( !readBuffer(placeHolder, 1) ) {
return false; }
9177 kuoHao->setHeight(placeHolder.toUnsignedInt());
9179 int jumpAmount = ove_->getIsVersion4() ? 40 : 8;
9180 if( !jump(jumpAmount) ) {
return false; }
9185 bool BarsParse::parseExpressions(MeasureData* measureData,
int length) {
9188 Expressions* expressions =
new Expressions();
9189 measureData->addMusicData(expressions);
9191 if( !jump(3) ) {
return false; }
9194 if( !parseCommonBlock(expressions) ) {
return false; }
9196 if( !jump(2) ) {
return false; }
9199 if( !readBuffer(placeHolder, 2) ) {
return false; }
9200 expressions->setYOffset(placeHolder.toInt());
9203 if( !readBuffer(placeHolder, 2) ) {
return false; }
9206 if( !jump(10) ) {
return false; }
9209 if( !readBuffer(placeHolder, 2) ) {
return false; }
9213 if( !readBuffer(placeHolder, 2) ) {
return false; }
9216 if( !jump(6) ) {
return false; }
9219 int cursor = ove_->getIsVersion4() ? 35 : 33;
9220 if( length > cursor ) {
9221 if( !readBuffer(placeHolder, length-cursor) ) {
return false; }
9222 expressions->setText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));
9228 bool BarsParse::parseHarpPedal(MeasureData* measureData,
int ) {
9231 HarpPedal* harpPedal =
new HarpPedal();
9232 measureData->addMusicData(harpPedal);
9234 if( !jump(3) ) {
return false; }
9237 if( !parseCommonBlock(harpPedal) ) {
return false; }
9239 if( !jump(2) ) {
return false; }
9242 if( !readBuffer(placeHolder, 2) ) {
return false; }
9243 harpPedal->setYOffset(placeHolder.toInt());
9246 if( !readBuffer(placeHolder, 1) ) {
return false; }
9247 harpPedal->setShowType(placeHolder.toUnsignedInt());
9250 if( !readBuffer(placeHolder, 1) ) {
return false; }
9251 harpPedal->setShowCharFlag(placeHolder.toUnsignedInt());
9253 if( !jump(8) ) {
return false; }
9258 bool BarsParse::parseMultiMeasureRest(MeasureData* measureData,
int ) {
9259 Block placeHolder(2);
9260 MultiMeasureRest* measureRest =
new MultiMeasureRest();
9261 measureData->addMusicData(measureRest);
9263 if( !jump(3) ) {
return false; }
9266 if( !parseCommonBlock(measureRest) ) {
return false; }
9268 if( !jump(6) ) {
return false; }
9273 bool BarsParse::parseHarmonyGuitarFrame(MeasureData* measureData,
int length) {
9276 Harmony* harmony =
new Harmony();
9277 measureData->addMusicData(harmony);
9279 if( !jump(3) ) {
return false; }
9282 if( !parseCommonBlock(harmony) ) {
return false; }
9285 if( !readBuffer(placeHolder, 1) ) {
return false; }
9286 harmony->setRoot(placeHolder.toUnsignedInt());
9289 if( !readBuffer(placeHolder, 1) ) {
return false; }
9290 harmony->setHarmonyType((HarmonyType)placeHolder.toUnsignedInt());
9293 if( !readBuffer(placeHolder, 1) ) {
return false; }
9294 harmony->setBass(placeHolder.toUnsignedInt());
9296 int jumpAmount = ove_->getIsVersion4() ? length - 12 : length - 10;
9297 if( !jump(jumpAmount) ) {
return false; }
9302 void extractOctave(
unsigned int Bits, OctaveShiftType& octaveShiftType, QList<OctaveShiftPosition>& positions) {
9303 octaveShiftType = OctaveShift_8;
9308 octaveShiftType = OctaveShift_8;
9309 positions.push_back(OctavePosition_Continue);
9313 octaveShiftType = OctaveShift_Minus_8;
9314 positions.push_back(OctavePosition_Continue);
9318 octaveShiftType = OctaveShift_15;
9319 positions.push_back(OctavePosition_Continue);
9323 octaveShiftType = OctaveShift_Minus_15;
9324 positions.push_back(OctavePosition_Continue);
9328 octaveShiftType = OctaveShift_8;
9329 positions.push_back(OctavePosition_Stop);
9333 octaveShiftType = OctaveShift_Minus_8;
9334 positions.push_back(OctavePosition_Stop);
9338 octaveShiftType = OctaveShift_15;
9339 positions.push_back(OctavePosition_Stop);
9343 octaveShiftType = OctaveShift_Minus_15;
9344 positions.push_back(OctavePosition_Stop);
9348 octaveShiftType = OctaveShift_8;
9349 positions.push_back(OctavePosition_Start);
9353 octaveShiftType = OctaveShift_Minus_8;
9354 positions.push_back(OctavePosition_Start);
9358 octaveShiftType = OctaveShift_15;
9359 positions.push_back(OctavePosition_Start);
9363 octaveShiftType = OctaveShift_Minus_15;
9364 positions.push_back(OctavePosition_Start);
9369 octaveShiftType = OctaveShift_8;
9370 positions.push_back(OctavePosition_Start);
9371 positions.push_back(OctavePosition_Stop);
9375 octaveShiftType = OctaveShift_Minus_8;
9376 positions.push_back(OctavePosition_Start);
9377 positions.push_back(OctavePosition_Stop);
9381 octaveShiftType = OctaveShift_15;
9382 positions.push_back(OctavePosition_Start);
9383 positions.push_back(OctavePosition_Stop);
9387 octaveShiftType = OctaveShift_Minus_15;
9388 positions.push_back(OctavePosition_Start);
9389 positions.push_back(OctavePosition_Stop);
9397 bool BarsParse::parseOctaveShift(MeasureData* measureData,
int )
9401 OctaveShift* octave =
new OctaveShift();
9402 measureData->addCrossMeasureElement(octave,
true);
9404 if( !jump(3) ) {
return false; }
9407 if( !parseCommonBlock(octave) ) {
return false; }
9410 if( !readBuffer(placeHolder, 1) ) {
return false; }
9411 unsigned int type = getLowNibble(placeHolder.toUnsignedInt());
9412 OctaveShiftType octaveShiftType = OctaveShift_8;
9413 QList<OctaveShiftPosition> positions;
9414 extractOctave(type, octaveShiftType, positions);
9416 octave->setOctaveShiftType(octaveShiftType);
9418 if( !jump(1) ) {
return false; }
9421 if( !readBuffer(placeHolder, 2) ) {
return false; }
9422 octave->setYOffset(placeHolder.toInt());
9424 if( !jump(4) ) {
return false; }
9427 if( !readBuffer(placeHolder, 2) ) {
return false; }
9428 octave->setLength(placeHolder.toUnsignedInt());
9431 if( !readBuffer(placeHolder, 2) ) {
return false; }
9432 octave->setEndTick(placeHolder.toUnsignedInt());
9435 for (
int i=0; i<positions.size(); ++i) {
9436 OctaveShiftPosition position = positions[i];
9437 OctaveShiftEndPoint* octavePoint =
new OctaveShiftEndPoint();
9438 measureData->addMusicData(octavePoint);
9440 octavePoint->copyCommonBlock(*octave);
9441 octavePoint->setOctaveShiftType(octaveShiftType);
9442 octavePoint->setOctaveShiftPosition(position);
9443 octavePoint->setEndTick(octave->getEndTick());
9446 if( i==0 && position == OctavePosition_Stop ) {
9447 octavePoint->start()->setOffset(octave->start()->getOffset()+octave->getLength());
9452 octavePoint->start()->setOffset(octave->start()->getOffset()+octave->getLength());
9453 octavePoint->setTick(octave->getEndTick());
9460 bool BarsParse::parseMidiController(MeasureData* measureData,
int ) {
9462 MidiController* controller =
new MidiController();
9463 measureData->addMidiData(controller);
9465 parseMidiCommon(controller);
9468 if( !readBuffer(placeHolder, 1) ) {
return false; }
9469 controller->setValue(placeHolder.toUnsignedInt());
9472 if( !readBuffer(placeHolder, 1) ) {
return false; }
9473 controller->setController(placeHolder.toUnsignedInt());
9475 if( ove_->getIsVersion4() ) {
9476 if( !jump(2) ) {
return false; }
9482 bool BarsParse::parseMidiProgramChange(MeasureData* measureData,
int ) {
9484 MidiProgramChange* program =
new MidiProgramChange();
9485 measureData->addMidiData(program);
9487 parseMidiCommon(program);
9489 if( !jump(1) ) {
return false; }
9492 if( !readBuffer(placeHolder, 1) ) {
return false; }
9493 program->setPatch(placeHolder.toUnsignedInt());
9495 if( ove_->getIsVersion4() ) {
9496 if( !jump(2) ) {
return false; }
9502 bool BarsParse::parseMidiChannelPressure(MeasureData* measureData,
int ) {
9504 MidiChannelPressure* pressure =
new MidiChannelPressure();
9505 measureData->addMidiData(pressure);
9507 parseMidiCommon(pressure);
9509 if( !jump(1) ) {
return false; }
9512 if( !readBuffer(placeHolder, 1) ) {
return false; }
9513 pressure->setPressure(placeHolder.toUnsignedInt());
9515 if( ove_->getIsVersion4() )
9517 if( !jump(2) ) {
return false; }
9523 bool BarsParse::parseMidiPitchWheel(MeasureData* measureData,
int ) {
9525 MidiPitchWheel* wheel =
new MidiPitchWheel();
9526 measureData->addMidiData(wheel);
9528 parseMidiCommon(wheel);
9531 if( !readBuffer(placeHolder, 2) ) {
return false; }
9532 int value = placeHolder.toUnsignedInt();
9533 wheel->setValue(value);
9535 if( ove_->getIsVersion4() ) {
9536 if( !jump(2) ) {
return false; }
9542 bool BarsParse::parseSizeBlock(
int length) {
9543 if( !jump(length) ) {
return false; }
9548 bool BarsParse::parseMidiCommon(MidiData* ptr) {
9551 if( !jump(3) ) {
return false; }
9554 if( !readBuffer(placeHolder, 2) ) {
return false; }
9555 ptr->setTick(placeHolder.toUnsignedInt());
9560 bool BarsParse::parseCommonBlock(MusicData* ptr) {
9564 if( !readBuffer(placeHolder, 2) ) {
return false; }
9565 ptr->setTick(placeHolder.toInt());
9568 if( !readBuffer(placeHolder, 2) ) {
return false; }
9569 ptr->start()->setOffset(placeHolder.toInt());
9571 if( ove_->getIsVersion4() ) {
9573 if( !readBuffer(placeHolder, 1) ) {
return false; }
9574 ptr->setColor(placeHolder.toUnsignedInt());
9576 if( !jump(1) ) {
return false; }
9582 bool BarsParse::parseOffsetCommonBlock(MusicData* ptr) {
9586 if( !readBuffer(placeHolder, 2) ) {
return false; }
9587 ptr->stop()->setMeasure(placeHolder.toUnsignedInt());
9590 if( !readBuffer(placeHolder, 2) ) {
return false; }
9591 ptr->stop()->setOffset(placeHolder.toInt());
9596 bool BarsParse::parsePairLinesBlock(PairEnds* ptr) {
9600 if( !readBuffer(placeHolder, 2) ) {
return false; }
9601 ptr->getLeftLine()->setLine(placeHolder.toInt());
9604 if( !readBuffer(placeHolder, 2) ) {
return false; }
9605 ptr->getRightLine()->setLine(placeHolder.toInt());
9610 bool BarsParse::parseOffsetElement(OffsetElement* ptr) {
9614 if( !readBuffer(placeHolder, 2) ) {
return false; }
9615 ptr->setXOffset(placeHolder.toInt());
9618 if( !readBuffer(placeHolder, 2) ) {
return false; }
9619 ptr->setYOffset(placeHolder.toInt());
9624 bool BarsParse::getCondElementType(
unsigned int byteData, CondType& type) {
9625 if( byteData == 0x09 ) {
9626 type = Cond_Time_Parameters;
9627 }
else if (byteData == 0x0A) {
9628 type = Cond_Bar_Number;
9629 }
else if (byteData == 0x16) {
9630 type = Cond_Decorator;
9631 }
else if (byteData == 0x1C) {
9633 }
else if (byteData == 0x1D) {
9635 }
else if (byteData == 0x25) {
9636 type = Cond_Expression;
9637 }
else if (byteData == 0x30) {
9638 type = Cond_Barline_Parameters;
9639 }
else if (byteData == 0x31) {
9641 }
else if (byteData == 0x32) {
9642 type = Cond_Numeric_Ending;
9650 bool BarsParse::getBdatElementType(
unsigned int byteData, BdatType& type) {
9651 if (byteData == 0x70) {
9652 type = Bdat_Raw_Note;
9653 }
else if (byteData == 0x80) {
9655 }
else if (byteData == 0x90) {
9657 }
else if (byteData == 0x10) {
9659 }
else if (byteData == 0x11) {
9660 type = Bdat_Harmony;
9661 }
else if (byteData == 0x12) {
9663 }
else if (byteData == 0x13) {
9665 }
else if (byteData == 0x14) {
9666 type = Bdat_Dynamics;
9667 }
else if (byteData == 0x15) {
9668 type = Bdat_Glissando;
9669 }
else if (byteData == 0x16) {
9670 type = Bdat_Decorator;
9671 }
else if (byteData == 0x17) {
9673 }
else if (byteData == 0x18) {
9675 }
else if (byteData == 0x19) {
9676 type = Bdat_Octave_Shift;
9677 }
else if (byteData == 0x1B) {
9679 }
else if (byteData == 0x1D) {
9681 }
else if (byteData == 0x1E) {
9683 }
else if (byteData == 0x1F) {
9685 }
else if (byteData == 0x21) {
9686 type = Bdat_Guitar_Bend;
9687 }
else if (byteData == 0x22) {
9688 type = Bdat_Guitar_Barre;
9689 }
else if (byteData == 0x23) {
9691 }
else if (byteData == 0x24) {
9693 }
else if (byteData == 0x25) {
9694 type = Bdat_Expressions;
9695 }
else if (byteData == 0x26) {
9696 type = Bdat_Harp_Pedal;
9697 }
else if (byteData == 0x27) {
9698 type = Bdat_Multi_Measure_Rest;
9699 }
else if (byteData == 0x28) {
9700 type = Bdat_Harmony_GuitarFrame;
9701 }
else if (byteData == 0x40) {
9702 type = Bdat_Graphics_40;
9703 }
else if (byteData == 0x41) {
9704 type = Bdat_Graphics_RoundRect;
9705 }
else if (byteData == 0x42) {
9706 type = Bdat_Graphics_Rect;
9707 }
else if (byteData == 0x43) {
9708 type = Bdat_Graphics_Round;
9709 }
else if (byteData == 0x44) {
9710 type = Bdat_Graphics_Line;
9711 }
else if (byteData == 0x45) {
9712 type = Bdat_Graphics_Curve;
9713 }
else if (byteData == 0x46) {
9714 type = Bdat_Graphics_WedgeSymbol;
9715 }
else if (byteData == 0xAB) {
9716 type = Bdat_Midi_Controller;
9717 }
else if (byteData == 0xAC) {
9718 type = Bdat_Midi_Program_Change;
9719 }
else if (byteData == 0xAD) {
9720 type = Bdat_Midi_Channel_Pressure;
9721 }
else if (byteData == 0xAE) {
9722 type = Bdat_Midi_Pitch_Wheel;
9723 }
else if (byteData == 0xFF) {
9724 type = Bdat_Bar_End;
9733 LyricChunkParse::LyricChunkParse(OveSong* ove) :
9737 void LyricChunkParse::setLyricChunk(SizeChunk* chunk) {
9742 bool LyricChunkParse::parse() {
9744 Block* dataBlock = chunk_->getDataBlock();
9745 unsigned int blockSize = chunk_->getSizeBlock()->toSize();
9746 StreamHandle handle(dataBlock->data(), blockSize);
9751 if( !jump(4) ) {
return false; }
9754 if( !readBuffer(placeHolder, 2) ) {
return false; }
9755 unsigned int count = placeHolder.toUnsignedInt();
9757 for( i=0; i<count; ++i ) {
9760 if( !readBuffer(placeHolder, 2) ) {
return false; }
9764 if( !jump(2) ) {
return false; }
9767 if( !readBuffer(placeHolder, 1) ) {
return false; }
9768 info.voice_ = placeHolder.toUnsignedInt();
9771 if( !readBuffer(placeHolder, 1) ) {
return false; }
9772 info.verse_ = placeHolder.toUnsignedInt();
9775 if( !readBuffer(placeHolder, 1) ) {
return false; }
9776 info.track_ = placeHolder.toUnsignedInt();
9778 if( !jump(1) ) {
return false; }
9781 if( !readBuffer(placeHolder, 2) ) {
return false; }
9782 info.measure_ = placeHolder.toUnsignedInt();
9785 if( !readBuffer(placeHolder, 2) ) {
return false; }
9786 info.wordCount_ = placeHolder.toUnsignedInt();
9789 if( !readBuffer(placeHolder, 2) ) {
return false; }
9790 info.lyricSize_ = placeHolder.toUnsignedInt();
9792 if( !jump(6) ) {
return false; }
9795 if( !readBuffer(placeHolder, 32) ) {
return false; }
9796 info.name_ = ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray());
9798 if( info.lyricSize_ > 0 ) {
9800 if( info.lyricSize_ > 0 ) {
9801 if( !readBuffer(placeHolder, info.lyricSize_) ) {
return false; }
9802 info.lyric_ = ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray());
9805 if( !jump(4) ) {
return false; }
9808 if( !readBuffer(placeHolder, 2) ) {
return false; }
9809 info.font_ = placeHolder.toUnsignedInt();
9811 if( !jump(1) ) {
return false; }
9814 if( !readBuffer(placeHolder, 1) ) {
return false; }
9815 info.fontSize_ = placeHolder.toUnsignedInt();
9818 if( !readBuffer(placeHolder, 1) ) {
return false; }
9819 info.fontStyle_ = placeHolder.toUnsignedInt();
9821 if( !jump(1) ) {
return false; }
9823 for(
int j=0; j<info.wordCount_; ++j ) {
9824 if( !jump(8) ) {
return false; }
9828 processLyricInfo(info);
9834 bool isSpace(
char c) {
9835 return c ==
' ' || c ==
'\n';
9838 void LyricChunkParse::processLyricInfo(
const LyricInfo& info)
9844 int measureId = info.measure_-1;
9845 bool changeMeasure =
true;
9846 MeasureData* measureData = 0;
9847 int trackMeasureCount = ove_->getTrackBarCount();
9848 QStringList words = info.lyric_.split(
" ", QString::SkipEmptyParts);
9850 while ( index < words.size() && measureId+1 < trackMeasureCount ) {
9851 if( changeMeasure ) {
9853 measureData = ove_->getMeasureData(info.track_, measureId);
9854 changeMeasure =
false;
9857 if( measureData == 0 ) {
return; }
9858 QList<NoteContainer*> containers = measureData->getNoteContainers();
9859 QList<MusicData*> lyrics = measureData->getMusicDatas(MusicData_Lyric);
9861 for( i=0; i<containers.size() && index<words.size(); ++i ) {
9862 if( containers[i]->getIsRest() ) {
9866 for( j=0; j<lyrics.size(); ++j ) {
9867 Lyric*
lyric = static_cast<Lyric*>(lyrics[j]);
9869 if( containers[i]->start()->getOffset() ==
lyric->start()->getOffset() &&
9870 (int)containers[i]->getVoice() == info.voice_ &&
9871 lyric->getVerse() == info.verse_ ) {
9872 if(index<words.size()) {
9873 QString l = words[index].trimmed();
9876 lyric->setVoice(info.voice_);
9885 changeMeasure =
true;
9890 TitleChunkParse::TitleChunkParse(OveSong* ove) :
9892 titleType_ = 0x00000001;
9893 annotateType_ = 0x00010000;
9894 writerType_ = 0x00020002;
9895 copyrightType_ = 0x00030001;
9896 headerType_ = 0x00040000;
9897 footerType_ = 0x00050002;
9900 void TitleChunkParse::setTitleChunk(SizeChunk* chunk) {
9904 bool TitleChunkParse::parse() {
9905 Block* dataBlock = chunk_->getDataBlock();
9906 unsigned int blockSize = chunk_->getSizeBlock()->toSize();
9907 StreamHandle handle(dataBlock->data(), blockSize);
9909 unsigned int titleType;
9913 if( !readBuffer(typeBlock, 4) ) {
return false; }
9915 titleType = typeBlock.toUnsignedInt();
9917 if( titleType == titleType_ || titleType == annotateType_ || titleType == writerType_ || titleType == copyrightType_ ) {
9920 if( !readBuffer(offsetBlock, 4) ) {
return false; }
9922 const unsigned int itemCount = 4;
9925 for( i=0; i<itemCount; ++i ) {
9928 if( !jump(6) ) {
return false; }
9932 if( !readBuffer(countBlock, 2) ) {
return false; }
9933 unsigned int titleSize = countBlock.toUnsignedInt();
9936 if( !readBuffer(dataBlock, titleSize) ) {
return false; }
9938 QByteArray array((
char*)dataBlock.data(), dataBlock.size());
9939 addToOve(ove_->getCodecString(array), titleType);
9945 if( titleType == headerType_ || titleType == footerType_ ) {
9946 if( !jump(10) ) {
return false; }
9949 if( !readBuffer(countBlock, 2) ) {
return false; }
9950 unsigned int titleSize = countBlock.toUnsignedInt();
9953 if( !readBuffer(dataBlock, titleSize) ) {
return false; }
9955 QByteArray array((
char*)dataBlock.data(), dataBlock.size());
9956 addToOve(ove_->getCodecString(array), titleType);
9959 if( !jump(6) ) {
return false; }
9967 void TitleChunkParse::addToOve(
const QString& str,
unsigned int titleType) {
9968 if( str.isEmpty() ) {
return; }
9970 if (titleType == titleType_) {
9971 ove_->addTitle(str);
9974 if (titleType == annotateType_) {
9975 ove_->addAnnotate(str);
9978 if (titleType == writerType_) {
9979 ove_->addWriter(str);
9982 if (titleType == copyrightType_) {
9983 ove_->addCopyright(str);
9986 if (titleType == headerType_) {
9987 ove_->addHeader(str);
9990 if (titleType == footerType_) {
9991 ove_->addFooter(str);
9996 OveOrganizer::OveOrganizer(OveSong* ove) {
10000 void OveOrganizer::organize() {
10006 organizeAttributes();
10007 organizeMeasures();
10010 void OveOrganizer::organizeAttributes() {
10016 if(ove_->getLineCount() > 0) {
10017 Line* line = ove_->getLine(0);
10018 int partBarCount = ove_->getPartBarCount();
10022 for(i=0; i<line->getStaffCount(); ++i) {
10023 QPair<int, int> partStaff = ove_->trackToPartStaff(i);
10024 Staff* staff = line->getStaff(i);
10025 lastKey = staff->getKeyType();
10027 for(j=0; j<partBarCount; ++j) {
10028 MeasureData* measureData = ove_->getMeasureData(partStaff.first, partStaff.second, j);
10030 if(measureData != 0) {
10031 Key* key = measureData->getKey();
10034 key->setKey(lastKey);
10035 key->setPreviousKey(lastKey);
10038 if( !key->getSetKey() ) {
10039 key->setKey(lastKey);
10040 key->setPreviousKey(lastKey);
10043 if( key->getKey() != lastKey ) {
10044 lastKey = key->getKey();
10054 if( ove_->getLineCount() > 0 ) {
10055 Line* line = ove_->getLine(0);
10056 int partBarCount = ove_->getPartBarCount();
10057 ClefType lastClefType = Clef_Treble;
10060 for( i=0; i<line->getStaffCount(); ++i ) {
10061 QPair<int, int> partStaff = ove_->trackToPartStaff(i);
10062 Staff* staff = line->getStaff(i);
10063 lastClefType = staff->getClefType();
10065 for( j=0; j<partBarCount; ++j ) {
10066 MeasureData* measureData = ove_->getMeasureData(partStaff.first, partStaff.second, j);
10068 if(measureData != 0) {
10069 Clef* clefPtr = measureData->getClef();
10070 clefPtr->setClefType((
int)lastClefType);
10072 const QList<MusicData*>& clefs = measureData->getMusicDatas(MusicData_Clef);
10074 for( k=0; k<clefs.size(); ++k ) {
10075 Clef* clef = static_cast<Clef*>(clefs[k]);
10076 lastClefType = clef->getClefType();
10085 Staff* getStaff(OveSong* ove,
int track) {
10086 if (ove->getLineCount() > 0) {
10087 Line* line = ove->getLine(0);
10088 if(line != 0 && line->getStaffCount() > 0) {
10089 Staff* staff = line->getStaff(track);
10097 void OveOrganizer::organizeTracks() {
10100 QList<Track*> tracks = ove_->getTracks();
10101 QList<bool> comboStaveStarts;
10103 for( i=0; i<tracks.size(); ++i ) {
10104 comboStaveStarts.push_back(
false);
10107 for( i=0; i<tracks.size(); ++i ) {
10108 Staff* staff = getStaff(ove_, i);
10110 if(staff->getGroupType() == Group_Brace && staff->getGroupStaffCount() == 1 ) {
10111 comboStaveStarts[i] =
true;
10124 QList<int> partStaffCounts;
10126 while( trackId < (
int)tracks.size() ) {
10127 int partTrackCount = 1;
10129 if( comboStaveStarts[trackId] ) {
10130 partTrackCount = 2;
10133 partStaffCounts.push_back(partTrackCount);
10134 trackId += partTrackCount;
10137 ove_->setPartStaffCounts(partStaffCounts);
10140 void OveOrganizer::organizeMeasures() {
10141 int trackBarCount = ove_->getTrackBarCount();
10143 for(
int i=0; i<ove_->getPartCount(); ++i ) {
10144 int partStaffCount = ove_->getStaffCount(i);
10146 for(
int j=0; j<partStaffCount; ++j ) {
10147 for(
int k=0; k<trackBarCount; ++k ) {
10148 Measure* measure = ove_->getMeasure(k);
10149 MeasureData* measureData = ove_->getMeasureData(i, j, k);
10151 organizeMeasure(i, j, measure, measureData);
10157 void OveOrganizer::organizeMeasure(
int part,
int track, Measure* measure, MeasureData* measureData) {
10159 organizeContainers(part, track, measure, measureData);
10162 organizeMusicDatas(part, track, measure, measureData);
10165 organizeCrossMeasureElements(part, track, measure, measureData);
10168 void addToList(QList<int>& list,
int number) {
10169 for(
int i=0; i<list.size(); ++i){
10170 if(list[i] == number){
10175 list.push_back(number);
10178 void OveOrganizer::organizeContainers(
int ,
int ,
10179 Measure* measure, MeasureData* measureData)
10182 QList<NoteContainer*> containers = measureData->getNoteContainers();
10183 int barUnits = measure->getTime()->getUnits();
10186 for(i=0; i<containers.size(); ++i){
10187 int endUnit = barUnits;
10188 if( i < containers.size() - 1 ) {
10189 endUnit = containers[i+1]->start()->getOffset();
10192 containers[i]->stop()->setOffset(endUnit);
10193 addToList(voices, containers[i]->getVoice());
10197 qSort(voices.begin(), voices.end());
10199 for (i = 0; i < voices.size(); ++i) {
10200 int voice = voices[i];
10202 for(
int j=0; j<(int)containers.size(); ++j) {
10203 int avoice = containers[j]->getVoice();
10204 if ( avoice == voice && avoice != i ) {
10205 containers[j]->setVoice(i);
10211 void OveOrganizer::organizeMusicDatas(
int ,
int , Measure* measure, MeasureData* measureData) {
10213 int barIndex = measure->getBarNumber()->getIndex();
10214 QList<MusicData*> datas = measureData->getMusicDatas(MusicData_None);
10216 for(i=0; i<datas.size(); ++i) {
10217 datas[i]->start()->setMeasure(barIndex);
10221 void OveOrganizer::organizeCrossMeasureElements(
int part,
int track, Measure* measure, MeasureData* measureData)
10224 QList<MusicData*> pairs = measureData->getCrossMeasureElements(MusicData_None, MeasureData::PairType_Start);
10226 for(i=0; i<pairs.size(); ++i) {
10227 MusicData* pair = pairs[i];
10229 switch ( pair->getMusicDataType() ) {
10230 case MusicData_Beam :
10231 case MusicData_Glissando :
10232 case MusicData_Slur :
10233 case MusicData_Tie :
10234 case MusicData_Tuplet :
10235 case MusicData_Pedal :
10236 case MusicData_Numeric_Ending :
10238 case MusicData_Measure_Repeat : {
10239 organizePairElement(pair, part, track, measure, measureData);
10242 case MusicData_OctaveShift : {
10243 OctaveShift* octave = static_cast<OctaveShift*>(pair);
10244 organizeOctaveShift(octave, measure, measureData);
10247 case MusicData_Wedge : {
10248 Wedge* wedge = static_cast<Wedge*>(pair);
10249 organizeWedge(wedge, part, track, measure, measureData);
10258 void OveOrganizer::organizePairElement(
10263 MeasureData* measureData) {
10264 int bar1Index = measure->getBarNumber()->getIndex();
10265 int bar2Index = bar1Index + data->stop()->getMeasure();
10266 MeasureData* measureData2 = ove_->getMeasureData(part, track, bar2Index);
10268 data->start()->setMeasure(bar1Index);
10270 if(measureData2 != 0 && measureData != measureData2) {
10271 measureData2->addCrossMeasureElement(data,
false);
10274 if( data->getMusicDataType() == MusicData_Tuplet ){
10275 Tuplet* tuplet = static_cast<Tuplet*>(data);
10276 const QList<NoteContainer*> containers = measureData->getNoteContainers();
10278 for(
int i=0; i<containers.size(); ++i){
10279 if(containers[i]->getTick() > tuplet->getTick()){
10283 if(containers[i]->getTick() == tuplet->getTick()){
10284 tuplet->setNoteType(containers[i]->getNoteType());
10288 int tupletTick = NoteTypeToTick(tuplet->getNoteType(), ove_->getQuarter())*tuplet->getSpace();
10289 if( tuplet->getTick() % tupletTick != 0 ) {
10290 int newStartTick = (tuplet->getTick() / tupletTick) * tupletTick;
10292 for(
int i=0; i<containers.size(); ++i){
10293 if( containers[i]->getTick() == newStartTick &&
10294 containers[i]->getTuplet() == tuplet->getTuplet()) {
10295 tuplet->setTick(containers[i]->getTick());
10296 tuplet->start()->setOffset(containers[i]->start()->getOffset());
10303 void OveOrganizer::organizeOctaveShift(
10304 OctaveShift* octave,
10306 MeasureData* measureData)
10310 const QList<NoteContainer*> containers = measureData->getNoteContainers();
10311 int barIndex = measure->getBarNumber()->getIndex();
10313 octave->start()->setMeasure(barIndex);
10315 for(i=0; i<containers.size(); ++i) {
10316 int noteShift = octave->getNoteShift();
10317 int containerTick = containers[i]->getTick();
10319 if( octave->getTick() <= containerTick && octave->getEndTick() > containerTick ) {
10320 containers[i]->setNoteShift(noteShift);
10325 bool getMiddleUnit(
10326 OveSong* ove,
int ,
int ,
10327 Measure* measure1, Measure* measure2,
int unit1,
int ,
10328 Measure* middleMeasure,
int& middleUnit) {
10329 QList<int> barUnits;
10331 int bar1Index = measure1->getBarNumber()->getIndex();
10332 int bar2Index = measure2->getBarNumber()->getIndex();
10335 for(
int j=bar1Index; j<=bar2Index; ++j ) {
10336 Measure* measure = ove->getMeasure(j);
10337 barUnits.push_back(measure->getTime()->getUnits());
10338 sumUnit += measure->getTime()->getUnits();
10341 int currentSumUnit = 0;
10342 for( i=0; i<barUnits.size(); ++i ) {
10343 int barUnit = barUnits[i];
10346 barUnit = barUnits[i] - unit1;
10349 if( currentSumUnit + barUnit < sumUnit/2 ) {
10350 currentSumUnit += barUnit;
10357 if( i < barUnits.size() ) {
10358 int barMiddleIndex = bar1Index + i;
10359 middleMeasure = ove->getMeasure(barMiddleIndex);
10360 middleUnit = sumUnit/2 - currentSumUnit;
10368 void OveOrganizer::organizeWedge(Wedge* wedge,
int part,
int track, Measure* measure, MeasureData* measureData) {
10369 int bar1Index = measure->getBarNumber()->getIndex();
10370 int bar2Index = bar1Index + wedge->stop()->getMeasure();
10371 MeasureData* measureData2 = ove_->getMeasureData(part, track, bar2Index);
10372 WedgeType wedgeType = wedge->getWedgeType();
10374 if( wedge->getWedgeType() == Wedge_Double_Line ) {
10375 wedgeType = Wedge_Cres_Line;
10378 wedge->start()->setMeasure(bar1Index);
10380 WedgeEndPoint* startPoint =
new WedgeEndPoint();
10381 measureData->addMusicData(startPoint);
10383 startPoint->setTick(wedge->getTick());
10384 startPoint->start()->setOffset(wedge->start()->getOffset());
10385 startPoint->setWedgeStart(
true);
10386 startPoint->setWedgeType(wedgeType);
10387 startPoint->setHeight(wedge->getHeight());
10389 WedgeEndPoint* stopPoint =
new WedgeEndPoint();
10391 stopPoint->setTick(wedge->getTick());
10392 stopPoint->start()->setOffset(wedge->stop()->getOffset());
10393 stopPoint->setWedgeStart(
false);
10394 stopPoint->setWedgeType(wedgeType);
10395 stopPoint->setHeight(wedge->getHeight());
10397 if(measureData2 != 0) {
10398 measureData2->addMusicData(stopPoint);
10401 if( wedge->getWedgeType() == Wedge_Double_Line ) {
10402 Measure* middleMeasure = NULL;
10403 int middleUnit = 0;
10407 measure, ove_->getMeasure(bar2Index),
10408 wedge->start()->getOffset(), wedge->stop()->getOffset(),
10409 middleMeasure, middleUnit);
10411 if( middleMeasure != 0 ) {
10412 WedgeEndPoint* midStopPoint =
new WedgeEndPoint();
10413 measureData->addMusicData(midStopPoint);
10415 midStopPoint->setTick(wedge->getTick());
10416 midStopPoint->start()->setOffset(middleUnit);
10417 midStopPoint->setWedgeStart(
false);
10418 midStopPoint->setWedgeType(Wedge_Cres_Line);
10419 midStopPoint->setHeight(wedge->getHeight());
10421 WedgeEndPoint* midStartPoint =
new WedgeEndPoint();
10422 measureData->addMusicData(midStartPoint);
10424 midStartPoint->setTick(wedge->getTick());
10425 midStartPoint->start()->setOffset(middleUnit);
10426 midStartPoint->setWedgeStart(
true);
10427 midStartPoint->setWedgeType(Wedge_Decresc_Line);
10428 midStartPoint->setHeight(wedge->getHeight());
10463 ChunkType nameToChunkType(
const NameBlock& name) {
10464 ChunkType type = Chunk_NONE;
10466 if (name.isEqual(
"OVSC")) {
10468 }
else if (name.isEqual(
"TRKL")) {
10470 }
else if (name.isEqual(
"TRAK")) {
10472 }
else if (name.isEqual(
"PAGL")) {
10474 }
else if (name.isEqual(
"PAGE")) {
10476 }
else if (name.isEqual(
"LINL")) {
10478 }
else if (name.isEqual(
"LINE")) {
10480 }
else if (name.isEqual(
"STAF")) {
10482 }
else if (name.isEqual(
"BARL")) {
10484 }
else if (name.isEqual(
"MEAS")) {
10486 }
else if (name.isEqual(
"COND")) {
10488 }
else if (name.isEqual(
"BDAT")) {
10490 }
else if (name.isEqual(
"PACH")) {
10492 }
else if (name.isEqual(
"FNTS")) {
10494 }
else if (name.isEqual(
"ODEV")) {
10496 }
else if (name.isEqual(
"TITL")) {
10498 }
else if (name.isEqual(
"ALOT")) {
10500 }
else if (name.isEqual(
"ENGR")) {
10502 }
else if (name.isEqual(
"FMAP")) {
10504 }
else if (name.isEqual(
"PCPR")) {
10506 }
else if (name.isEqual(
"LYRC")) {
10513 int chunkTypeToMaxTimes(ChunkType type) {
10570 OveSerialize::OveSerialize() :
10576 OveSerialize::~OveSerialize() {
10577 if(streamHandle_ != 0) {
10578 delete streamHandle_;
10583 void OveSerialize::setOve(OveSong* ove) {
10587 void OveSerialize::setFileStream(
unsigned char* buffer,
unsigned int size) {
10588 streamHandle_ =
new StreamHandle(buffer, size);
10591 void OveSerialize::setNotify(IOveNotify* notify) {
10595 void OveSerialize::messageOutError() {
10596 if (notify_ != NULL) {
10597 notify_->loadError();
10601 void OveSerialize::messageOut(
const QString& str) {
10602 if (notify_ != NULL) {
10603 notify_->loadInfo(str);
10607 bool OveSerialize::load(
void) {
10608 if(streamHandle_ == 0)
10611 if( !readHeader() ) {
10617 QMap<ChunkType, int> chunkTimes;
10620 for( i=(
int)Chunk_OVSC; i<(int)Chunk_NONE; ++i ) {
10621 chunkTimes[(ChunkType)i] = 0;
10624 ChunkType chunkType = Chunk_NONE;
10627 NameBlock nameBlock;
10628 SizeChunk sizeChunk;
10630 if( !readNameBlock(nameBlock) ) {
return false; }
10632 chunkType = nameToChunkType(nameBlock);
10633 ++chunkTimes[chunkType];
10634 int maxTime = chunkTypeToMaxTimes(chunkType);
10636 if( maxTime > 0 && chunkTimes[chunkType] > maxTime ) {
10637 messageOut(
"format not support, chunk appear more than accept.");
10641 switch (chunkType) {
10653 if (!readTracksData()) {
10661 if (!readPagesData()) {
10669 if (!readLinesData()) {
10677 if (!readBarsData()) {
10695 SizeChunk lyricChunk;
10696 if (!readSizeChunk(&lyricChunk)) {
10701 LyricChunkParse parse(ove_);
10703 parse.setLyricChunk(&lyricChunk);
10709 SizeChunk titleChunk;
10710 if (!readSizeChunk(&titleChunk)) {
10715 TitleChunkParse titleChunkParse(ove_);
10717 titleChunkParse.setTitleChunk(&titleChunk);
10718 titleChunkParse.parse();
10729 if (!readSizeChunk(&sizeChunk)) {
10751 while ( chunkType != Chunk_NONE );
10756 OVE::OveOrganizer organizer(ove_);
10757 organizer.organize();
10762 void OveSerialize::release() {
10766 bool OveSerialize::readHeader() {
10767 ChunkType chunkType = Chunk_NONE;
10768 NameBlock nameBlock;
10769 SizeChunk sizeChunk;
10771 if (!readNameBlock(nameBlock)) {
10775 chunkType = nameToChunkType(nameBlock);
10778 if (chunkType == Chunk_OVSC) {
10779 if (readHeadData(&sizeChunk)) {
10784 QString info =
"Not compatible file, try to load and save with newer version, Overture 4 is recommended.";
10790 bool OveSerialize::readHeadData(SizeChunk* ovscChunk) {
10791 if (!readSizeChunk(ovscChunk))
10794 OvscParse ovscParse(ove_);
10796 ovscParse.setNotify(notify_);
10797 ovscParse.setOvsc(ovscChunk);
10799 return ovscParse.parse();
10802 bool OveSerialize::readTracksData() {
10803 GroupChunk trackGroupChunk;
10805 if (!readGroupChunk(&trackGroupChunk))
10809 unsigned short trackCount = trackGroupChunk.getCountBlock()->toCount();
10811 for (i = 0; i < trackCount; ++i) {
10812 SizeChunk* trackChunk =
new SizeChunk();
10814 if (ove_->getIsVersion4()) {
10815 if (!readChunkName(trackChunk, Chunk::TrackName)) {
10818 if (!readSizeChunk(trackChunk)) {
10822 if (!readDataChunk(trackChunk->getDataBlock(),
10823 SizeChunk::version3TrackSize)) {
10828 TrackParse trackParse(ove_);
10830 trackParse.setTrack(trackChunk);
10831 trackParse.parse();
10837 bool OveSerialize::readPagesData() {
10838 GroupChunk pageGroupChunk;
10840 if (!readGroupChunk(&pageGroupChunk))
10843 unsigned short pageCount = pageGroupChunk.getCountBlock()->toCount();
10845 PageGroupParse parse(ove_);
10847 for (i = 0; i < pageCount; ++i) {
10848 SizeChunk* pageChunk =
new SizeChunk();
10850 if (!readChunkName(pageChunk, Chunk::PageName)) {
10853 if (!readSizeChunk(pageChunk)) {
10857 parse.addPage(pageChunk);
10860 if (!parse.parse()) {
10867 bool OveSerialize::readLinesData() {
10868 GroupChunk lineGroupChunk;
10869 if (!readGroupChunk(&lineGroupChunk))
10872 unsigned short lineCount = lineGroupChunk.getCountBlock()->toCount();
10875 QList<SizeChunk*> lineChunks;
10876 QList<SizeChunk*> staffChunks;
10878 for (i = 0; i < lineCount; ++i) {
10879 SizeChunk* lineChunk =
new SizeChunk();
10881 if (!readChunkName(lineChunk, Chunk::LineName)) {
10884 if (!readSizeChunk(lineChunk)) {
10888 lineChunks.push_back(lineChunk);
10890 StaffCountGetter getter(ove_);
10891 unsigned int staffCount = getter.getStaffCount(lineChunk);
10893 for (j = 0; j < staffCount; ++j) {
10894 SizeChunk* staffChunk =
new SizeChunk();
10896 if (!readChunkName(staffChunk, Chunk::StaffName)) {
10899 if (!readSizeChunk(staffChunk)) {
10903 staffChunks.push_back(staffChunk);
10907 LineGroupParse parse(ove_);
10909 parse.setLineGroup(&lineGroupChunk);
10911 for (i = 0; i < lineChunks.size(); ++i) {
10912 parse.addLine(lineChunks[i]);
10915 for (i = 0; i < staffChunks.size(); ++i) {
10916 parse.addStaff(staffChunks[i]);
10919 if (!parse.parse()) {
10926 bool OveSerialize::readBarsData() {
10927 GroupChunk barGroupChunk;
10928 if (!readGroupChunk(&barGroupChunk))
10931 unsigned short measCount = barGroupChunk.getCountBlock()->toCount();
10934 QList<SizeChunk*> measureChunks;
10935 QList<SizeChunk*> conductChunks;
10936 QList<SizeChunk*> bdatChunks;
10938 ove_->setTrackBarCount(measCount);
10941 for (i = 0; i < measCount; ++i) {
10942 SizeChunk* measureChunkPtr =
new SizeChunk();
10944 if (!readChunkName(measureChunkPtr, Chunk::MeasureName)) {
10947 if (!readSizeChunk(measureChunkPtr)) {
10951 measureChunks.push_back(measureChunkPtr);
10954 for (i = 0; i < measCount; ++i) {
10955 SizeChunk* conductChunkPtr =
new SizeChunk();
10957 if (!readChunkName(conductChunkPtr, Chunk::ConductName))
10960 if (!readSizeChunk(conductChunkPtr))
10963 conductChunks.push_back(conductChunkPtr);
10966 int bdatCount = ove_->getTrackCount() * measCount;
10967 for (i = 0; i < bdatCount; ++i) {
10968 SizeChunk* batChunkPtr =
new SizeChunk();
10970 if (!readChunkName(batChunkPtr, Chunk::BdatName)) {
10973 if (!readSizeChunk(batChunkPtr)) {
10977 bdatChunks.push_back(batChunkPtr);
10981 BarsParse barsParse(ove_);
10983 for (i = 0; i < (int) measureChunks.size(); ++i) {
10984 barsParse.addMeasure(measureChunks[i]);
10987 for (i = 0; i < (int) conductChunks.size(); ++i) {
10988 barsParse.addConduct(conductChunks[i]);
10991 for (i = 0; i < (int) bdatChunks.size(); ++i) {
10992 barsParse.addBdat(bdatChunks[i]);
10995 barsParse.setNotify(notify_);
10996 if (!barsParse.parse()) {
11003 bool OveSerialize::readOveEnd() {
11004 if (streamHandle_ == 0)
11007 const unsigned int END_OVE1 = 0xffffffff;
11008 const unsigned int END_OVE2 = 0x00000000;
11009 unsigned int buffer;
11011 if (!streamHandle_->read((
char*) &buffer,
sizeof(
unsigned int)))
11014 if (buffer != END_OVE1)
11017 if (!streamHandle_->read((
char*) &buffer,
sizeof(
unsigned int)))
11020 if (buffer != END_OVE2)
11027 bool OveSerialize::readNameBlock(NameBlock& nameBlock) {
11028 if (streamHandle_ == 0)
11031 if (!streamHandle_->read((
char*) nameBlock.data(), nameBlock.size()))
11037 bool OveSerialize::readChunkName(Chunk* ,
const QString& name) {
11038 if (streamHandle_ == 0)
11041 NameBlock nameBlock;
11043 if (!streamHandle_->read((
char*) nameBlock.data(), nameBlock.size()))
11046 if (!(nameBlock.toStrByteArray() == name))
11052 bool OveSerialize::readSizeChunk(SizeChunk* sizeChunk) {
11053 if (streamHandle_ == 0)
11056 SizeBlock* sizeBlock = sizeChunk->getSizeBlock();
11058 if (!streamHandle_->read((
char*) sizeBlock->data(), sizeBlock->size()))
11061 unsigned int blockSize = sizeBlock->toSize();
11063 sizeChunk->getDataBlock()->resize(blockSize);
11065 Block* dataBlock = sizeChunk->getDataBlock();
11067 if (!streamHandle_->read((
char*) dataBlock->data(), blockSize))
11073 bool OveSerialize::readDataChunk(Block* block,
unsigned int size) {
11074 if (streamHandle_ == 0)
11077 block->resize(size);
11079 if (!streamHandle_->read((
char*) block->data(), size))
11085 bool OveSerialize::readGroupChunk(GroupChunk* groupChunk) {
11086 if (streamHandle_ == 0)
11089 CountBlock* countBlock = groupChunk->getCountBlock();
11091 if (!streamHandle_->read((
char*) countBlock->data(), countBlock->size()))
11097 IOVEStreamLoader* createOveStreamLoader() {
11098 return new OveSerialize;
11104 namespace drumstick {
11120 class MeasureToTick {
11123 virtual ~MeasureToTick() {
11127 void build(OVE::OveSong* ove,
int quarter);
11136 numerator_(4), denominator_(4), measure_(0), tick_(0) {
11139 int getTick(
int measure,
int tickOffset);
11140 QList<TimeTick> getTimeTicks()
const;
11144 OVE::OveSong* ove_;
11146 QList<TimeTick> tts_;
11149 int getMeasureTick(
int quarter,
int num,
int den) {
11150 return quarter * 4 * num / den;
11153 MeasureToTick::MeasureToTick() {
11158 void MeasureToTick::build(OVE::OveSong* ove,
int quarter) {
11160 int currentTick = 0;
11161 unsigned int measureCount = ove->getMeasureCount();
11163 quarter_ = quarter;
11167 for (i = 0; i < measureCount; ++i) {
11168 OVE::Measure* measure = ove_->getMeasure(i);
11169 OVE::TimeSignature* time = measure->getTime();
11171 bool change =
false;
11173 tt.tick_ = currentTick;
11174 tt.numerator_ = time->getNumerator();
11175 tt.denominator_ = time->getDenominator();
11181 OVE::TimeSignature* previousTime = ove_->getMeasure(i - 1)->getTime();
11183 if (time->getNumerator() != previousTime->getNumerator()
11184 || time->getDenominator() != previousTime->getDenominator()) {
11190 tts_.push_back(tt);
11193 currentTick += getMeasureTick(quarter_, tt.numerator_, tt.denominator_);
11197 int MeasureToTick::getTick(
int measure,
int tickOffset) {
11201 for (i = 0; i < tts_.size(); ++i) {
11202 if (measure >= tts_[i].measure_ && (i == tts_.size() - 1 || measure < tts_[i + 1].measure_)) {
11203 int measuresTick = (measure - tts_[i].measure_) *
11204 getMeasureTick(quarter_, tts_[i].numerator_, tts_[i].denominator_);
11206 return tts_[i].tick_ + measuresTick + tickOffset;
11213 QList<MeasureToTick::TimeTick> MeasureToTick::getTimeTicks()
const {
11218 class QOve::QOvePrivate {
11250 d->ove.setTextCodecName(codec);
11259 QFile oveFile(fileName);
11260 bool success =
true;
11262 if (oveFile.open(QFile::ReadOnly)) {
11263 QByteArray buffer = oveFile.readAll();
11269 OVE::IOVEStreamLoader* oveLoader = OVE::createOveStreamLoader();
11271 oveLoader->setOve(&d->ove);
11272 oveLoader->setFileStream((
unsigned char*) buffer.data(), buffer.size());
11273 oveLoader->setNotify(0);
11274 bool result = oveLoader->load();
11275 oveLoader->release();
11287 "Cannot read this OVE file, " 11288 "probably because it has an incompatible format.\n" 11289 "Please, convert it using Overture 4 or a newer version.");
11293 void QOve::convertSong() {
11297 d->mtt.build(&d->ove, d->ove.getQuarter());
11301 convertSignatures();
11303 for (i = 0; i < (
unsigned int) d->ove.getPartCount(); ++i) {
11304 int partStaffCount = d->ove.getStaffCount(i);
11306 for (
int j = 0; j < partStaffCount; ++j) {
11307 OVE::Track* trackPtr = d->ove.getTrack(i, j);
11308 int transpose = trackPtr->getShowTranspose() ? trackPtr->getTranspose() : 0;
11310 convertTrackHeader(trackPtr, trackNo);
11313 int endMeasure = d->ove.getMeasureCount();
11314 int offsetTick = 0;
11316 for (
int l = 0; l < endMeasure; ++l) {
11317 OVE::Measure* measure = d->ove.getMeasure(l);
11318 OVE::MeasureData* measureData = d->ove.getMeasureData(i, j, l);
11324 convertMeasure(trackPtr, trackNo, trackPtr->getVoices(), measure, measureData, transpose, offsetTick);
11334 void QOve::convertSignatures() {
11336 int beginMeasure = 0;
11337 int endMeasure = d->ove.getMeasureCount();
11340 QMap<int, int> tempos;
11341 for (i = 0; i < d->ove.getPartCount(); ++i) {
11346 int partStaffCount = d->ove.getStaffCount(i);
11348 for (
int j = 0; j < partStaffCount; ++j) {
11353 for (
int k = beginMeasure; k < endMeasure; ++k) {
11354 OVE::Measure* measure = d->ove.getMeasure(k);
11355 OVE::MeasureData* measureData = d->ove.getMeasureData(i, j, k);
11356 QList<OVE::MusicData*> tempoPtrs = measureData->getMusicDatas(OVE::MusicData_Tempo);
11358 if (k == 0 || (k > 0 && std::abs(measure->getTypeTempo() - d->ove.getMeasure(k - 1)->getTypeTempo()) > 0.01)) {
11359 int tick = d->mtt.getTick(k, 0);
11360 int tempo = (int) measure->getTypeTempo();
11361 tempos[tick] = tempo;
11364 for (
int l = 0; l < tempoPtrs.size(); ++l) {
11365 OVE::Tempo* ptr = static_cast<OVE::Tempo*> (tempoPtrs[l]);
11366 int tick = d->mtt.getTick(measure->getBarNumber()->getIndex(), ptr->getTick());
11367 int tempo = ptr->getQuarterTempo() > 0 ? ptr->getQuarterTempo() : 1;
11369 tempos[tick] = tempo;
11375 QMap<int, int>::iterator it;
11377 for (it = tempos.begin(); it != tempos.end(); ++it) {
11378 if (it == tempos.begin() || it.value() != lastTempo) {
11382 lastTempo = it.value();
11386 const QList<MeasureToTick::TimeTick> tts = d->mtt.getTimeTicks();
11387 for (i = 0; i < (int) tts.size(); ++i) {
11388 if (beginMeasure <= tts[i].measure_ && endMeasure > tts[i].measure_) {
11389 Q_EMIT
signalOVETimeSig(tts[i].measure_, tts[i].tick_, tts[i].numerator_, tts[i].denominator_);
11394 bool createKey =
false;
11395 for (i = beginMeasure; i < endMeasure; ++i) {
11396 OVE::MeasureData* measureData = d->ove.getMeasureData(0, 0, i);
11398 if (measureData != NULL) {
11399 OVE::Key* keyPtr = measureData->getKey();
11401 if (i == 0 || keyPtr->getKey() != keyPtr->getPreviousKey()) {
11414 void QOve::convertTrackHeader(OVE::Track* track,
int trackNo) {
11416 const QList<OVE::Voice*> voices = track->getVoices();
11417 QMap<int, int> patches;
11418 QMap<int, int> pans;
11419 QMap<int, int> volumes;
11420 QMap<int, int>::iterator it;
11426 QString trackName = track->getName();
11429 for (i = 0; i < voices.size() && i < (
unsigned int)track->getVoiceCount(); ++i) {
11430 int patch = voices[i]->getPatch();
11431 int channel = voices[i]->getChannel();
11432 int volume = voices[i]->getVolume();
11434 if (patch != OVE::Voice::getDefaultPatch()) {
11435 patches[channel] = patch;
11438 pans[channel] = voices[i]->getPan();
11440 if (volume != OVE::Voice::getDefaultVolume()) {
11441 volumes[channel] = volume;
11449 for (it = patches.begin(); it != patches.end(); ++it) {
11450 patch = it.value();
11456 for (it = pans.begin(); it != pans.end(); ++it) {
11457 if (it.value() != 0 && it.value() != lastPan) {
11461 lastPan = it.value();
11465 for (it = volumes.begin(); it != volumes.end(); ++it) {
11466 int volume = it.value();
11467 if (volume != -1) {
11472 Q_EMIT
signalOVENewTrack(track->getName(), trackNo, ch, 0, vol, 0,
false,
false,
false);
11477 int getPitchShift(
const QList<OVE::Voice*>& voices,
int voice) {
11478 if (voice >= 0 && voice < (
int) voices.size())
11479 return voices[voice]->getPitchShift();
11483 int getChannel(
const QList<OVE::Voice*>& voices,
int voice) {
11484 if (voice >= 0 && voice < (
int) voices.size())
11485 return voices[voice]->getChannel();
11489 int getTick(
int tick) {
11495 void QOve::convertMeasure(
11496 OVE::Track* track,
int trackNo,
const QList<OVE::Voice*>& voices,
11497 OVE::Measure* measure, OVE::MeasureData* measureData,
int transpose,
int offsetTick)
11501 int measureId = measure->getBarNumber()->getIndex();
11502 QList<OVE::NoteContainer*> containers = measureData->getNoteContainers();
11505 for (i = 0; i < containers.size(); ++i) {
11506 OVE::NoteContainer* container = containers[i];
11507 int measureTick = d->mtt.getTick(measureId, 0);
11512 getChannel(voices, container->getVoice()),
11513 getPitchShift(voices, container->getVoice()) - transpose);
11517 QList<OVE::MidiData*> midiDatas = measureData->getMidiDatas(OVE::Midi_None);
11518 int channel = getChannel(voices, 0);
11520 for (i = 0; i < midiDatas.size(); ++i) {
11521 OVE::MidiType midiType = midiDatas[i]->getMidiType();
11522 int midiTick = getTick(d->mtt.getTick(measureId, midiDatas[i]->getTick()) + offsetTick);
11524 switch (midiType) {
11525 case OVE::Midi_Controller: {
11526 OVE::MidiController* controller = static_cast<OVE::MidiController*> (midiDatas[i]);
11528 Q_EMIT
signalOVECtlChange(trackNo, midiTick, channel, controller->getController(), controller->getValue());
11532 case OVE::Midi_Program_Change: {
11533 OVE::MidiProgramChange* program = static_cast<OVE::MidiProgramChange*> (midiDatas[i]);
11539 case OVE::Midi_Channel_Pressure: {
11540 OVE::MidiChannelPressure* pressure = static_cast<OVE::MidiChannelPressure*> (midiDatas[i]);
11546 case OVE::Midi_Pitch_Wheel: {
11547 OVE::MidiPitchWheel* pitchWheel = static_cast<OVE::MidiPitchWheel*> (midiDatas[i]);
11559 QList<OVE::MusicData*> musicDatas = measureData->getMusicDatas(OVE::MusicData_None);
11561 for (i = 0; i < musicDatas.size(); ++i) {
11562 OVE::MusicDataType type = musicDatas[i]->getMusicDataType();
11563 int musicDataTick = getTick(d->mtt.getTick(measureId, musicDatas[i]->getTick()) + offsetTick);
11566 case OVE::MusicData_Lyric: {
11567 OVE::Lyric* lyricPtr = static_cast<OVE::Lyric*> (musicDatas[i]);
11569 Q_EMIT
signalOVEText(trackNo, musicDataTick, lyricPtr->getLyric());
11573 case OVE::MusicData_Dynamics: {
11574 OVE::Dynamics* dynamicPtr = static_cast<OVE::Dynamics*> (musicDatas[i]);
11576 Q_EMIT
signalOVECtlChange(trackNo, musicDataTick, channel, 7, dynamicPtr->getVelocity());
11580 case OVE::MusicData_Decorator: {
11581 OVE::Decorator* decorator = static_cast<OVE::Decorator*> (musicDatas[i]);
11583 if (decorator->getDecoratorType() == OVE::Decorator::Decorator_Articulation) {
11584 OVE::ArticulationType artType = decorator->getArticulationType();
11587 case OVE::Articulation_Pedal_Down: {
11592 case OVE::Articulation_Pedal_Up: {
11610 bool hasNoteOn(
int pos) {
11611 return (pos & OVE::Tie_RightEnd) != OVE::Tie_RightEnd;
11614 bool hasNoteOff(
int pos) {
11615 return (pos & OVE::Tie_LeftEnd) != OVE::Tie_LeftEnd;
11618 int noteTypeToTick(OVE::NoteType type,
int quarter = 480) {
11619 int c = int(pow(2.0, (
int) type));
11620 return quarter * 4 * 2 / c;
11623 void QOve::convertNotes(
int trackNo,
int measureTick, OVE::NoteContainer* container,
int channel,
int pitchShift)
11625 if (container->getIsRest()) {
11632 QList<OVE::Note*> notes = container->getNotesRests();
11633 QList<OVE::Articulation*> articulations = container->getArticulations();
11634 bool changeNoteCount =
false;
11637 for (i = 0; i < articulations.size(); ++i) {
11638 OVE::Articulation* art = articulations[i];
11639 OVE::ArticulationType type = art->getArtType();
11641 for (j = 0; j < notes.size(); ++j) {
11642 OVE::Note* notePtr = notes[j];
11643 unsigned int velocityValue = notePtr->getOnVelocity();
11644 int noteValue = notePtr->getNote() + container->getNoteShift() + pitchShift;
11645 int startTick = measureTick + container->getTick() + notePtr->getOffsetTick();
11648 if (hasNoteOn(notePtr->getTiePos())) {
11651 case OVE::Articulation_Tremolo_Eighth:
11652 case OVE::Articulation_Tremolo_Sixteenth:
11653 case OVE::Articulation_Tremolo_Thirty_Second:
11654 case OVE::Articulation_Tremolo_Sixty_Fourth: {
11655 int noteCount = (int) pow(2.0, ((
int) type - (int) OVE::Articulation_Tremolo_Eighth) + 1);
11656 int noteTick = noteTypeToTick(container->getNoteType(), d->ove.getQuarter()) / noteCount;
11658 for (k = 0; k < noteCount; ++k) {
11660 int onTick = getTick(startTick + k * noteTick);
11662 Q_EMIT
signalOVENoteOn(trackNo, onTick, channel, noteValue, velocityValue);
11664 if (k < noteCount - 1 || hasNoteOff((
int) notePtr->getTiePos())) {
11666 int offTick = getTick(startTick + (k + 1) * noteTick);
11668 Q_EMIT signalOVENoteOff(trackNo, offTick, channel, noteValue, velocityValue);
11672 changeNoteCount =
true;
11683 if (changeNoteCount) {
11688 for (i = 0; i < notes.size(); ++i) {
11689 OVE::Note* notePtr = notes[i];
11690 unsigned int velocityValue = notePtr->getOnVelocity();
11691 int noteValue = notePtr->getNote() + container->getNoteShift() + pitchShift;
11693 int startTick = getTick(measureTick + container->getTick() + notePtr->getOffsetTick());
11694 int lengthTick = container->getLength();
11697 if (hasNoteOn((
int) notePtr->getTiePos())) {
11698 for (j = 0; j < articulations.size(); ++j) {
11699 OVE::Articulation* art = articulations[j];
11700 OVE::ArticulationType type = art->getArtType();
11702 if (art->getChangeLength()) {
11703 lengthTick = noteTypeToTick(container->getNoteType(), d->ove.getQuarter()) * art->getLengthPercentage() / 100;
11706 if (art->getChangeVelocity()) {
11707 switch (art->getVelocityType()) {
11708 case OVE::Articulation::Velocity_Offset: {
11709 velocityValue += art->getVelocityValue();
11712 case OVE::Articulation::Velocity_Percentage: {
11713 velocityValue *= (
unsigned int) ((
double) art->getVelocityValue() / (double) 100);
11716 case OVE::Articulation::Velocity_SetValue: {
11717 velocityValue = art->getVelocityValue();
11725 if (art->getChangeExtraLength()) {
11729 case OVE::Articulation_Pedal_Down: {
11734 case OVE::Articulation_Pedal_Up: {
11739 case OVE::Articulation_Arpeggio: {
11741 unsigned int soundEffect = std::abs(art->getSoundEffect().first) + std::abs(art->getSoundEffect().second);
11742 int tickAmount = (soundEffect / notes.size()) * ((notes.size() - i) - 1);
11743 startTick -= tickAmount;
11753 Q_EMIT
signalOVENoteOn(trackNo, getTick(startTick), channel, noteValue, velocityValue);
11757 if (hasNoteOff(notePtr->getTiePos())) {
11758 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 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.