File: ove.h

package info (click to toggle)
musescore 2.0.3%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 202,532 kB
  • ctags: 58,769
  • sloc: cpp: 257,595; xml: 172,226; ansic: 139,931; python: 6,565; sh: 6,383; perl: 423; makefile: 290; awk: 142; pascal: 67; sed: 3
file content (2717 lines) | stat: -rw-r--r-- 64,286 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
//=============================================================================
//  MusE Score
//  Linux Music Score Editor
//  $Id: importove.cpp 3763 2010-12-15 15:52:09Z vanferry $
//
//  Copyright (C) 2002-2009 Werner Schweer and others
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================

#ifndef OVE_DATA_H
#define OVE_DATA_H

#ifdef WIN32
#define DLL_EXPORT extern "C" __declspec(dllexport)
#else
#define DLL_EXPORT
#endif

namespace OVE {

class OveSong;
class Track;
class Page;
class Voice;
class Line;
class Staff;
class Measure;
class MeasureData;
class MusicData;
class OffsetElement;
class LineElement;
class PairEnds;
class Note;
class NoteContainer;
class Beam;
class Tie;
class Tuplet;
class Harmony;
class Clef;
class Lyric;
class Slur;
class MeasureText;
class Articulation;
class Glissando;
class Decorator;
class MeasureRepeat;
class Dynamics;
class Wedge;
class WedgeEndPoint;
class Pedal;
class KuoHao;
class Expressions;
class HarpPedal;
class MultiMeasureRest;
class OctaveShift;
class OctaveShiftEndPoint;
class BarNumber;
class Tempo;
class Text;
class TimeSignature;
class Key;
class RepeatSymbol;
class NumericEnding;
class MidiData;
class MidiController;
class MidiProgramChange;
class MidiChannelPressure;
class MidiPitchWheel;

const int TWELVE_TONE = 12 ;
const int INVALID_NOTE = -1 ;
const int OCTAVE = 7 ;

enum class CondType : char {
      None,
      Time_Parameters    = 0x09, // size - 7, TimeSignature
      Bar_Number         = 0x0A, // size, compatible with previous version
      Decorator          = 0x16,
      Tempo              = 0x1C, // size - 7
      Text               = 0x1D, // size - 7, Rehearsal | SystemText
      Expression         = 0x25, // size - 7, if set playback parameters in Expression, will store in COND
      Barline_Parameters = 0x30, // size - 7, include :|| repeat count
      Repeat             = 0x31, //
      Numeric_Ending     = 0x32,
      };

enum class BdatType : unsigned char {
      None,
      Raw_Note              = 0x70,
      Rest                  = 0x80,
      Note                  = 0x90,
      Beam                  = 0x10,
      Harmony               = 0x11,
      Clef                  = 0x12,
      Dynamics              = 0x13,
      Wedge                 = 0x14, // cresendo, decresendo
      Glissando             = 0x15,
      Decorator             = 0x16, // measure repeat | piano pedal | dotted barline
      Key                   = 0x17,
      Lyric                 = 0x18,
      Octave_Shift          = 0x19,
      Slur                  = 0x1B,
      Text                  = 0x1D,
      Tie                   = 0x1E,
      Tuplet                = 0x1F,
      Guitar_Bend           = 0x21, //
      Guitar_Barre          = 0x22, //
      Pedal                 = 0x23,
      KuoHao                = 0x24, // () [] {}
      Expressions           = 0x25,
      Harp_Pedal            = 0x26,
      Multi_Measure_Rest    = 0x27,
      Harmony_GuitarFrame   = 0x28,
      Graphics_40           = 0x40, // unknown
      Graphics_RoundRect    = 0x41,
      Graphics_Rect         = 0x42,
      Graphics_Round        = 0x43,
      Graphics_Line         = 0x44,
      Graphics_Curve        = 0x45,
      Graphics_WedgeSymbol  = 0x46,
      Midi_Controller       = 0xAB,
      Midi_Program_Change   = 0xAC,
      Midi_Channel_Pressure = 0xAD,
      Midi_Pitch_Wheel      = 0xAE,
      Bar_End               = 0xFF,
      };

////////////////////////////////////////

enum class MusicDataType : char {
      None,

      // attributes
      Clef,
      Key,
      Measure_Repeat,

      // sound
      Tempo,

      // direction
      Dynamics,
      Wedge,
      Wedge_EndPoint,
      OctaveShift,
      OctaveShift_EndPoint,
      Expressions,
      Repeat,
      Text,
      Harp_Pedal,
      Pedal,

      // note & harmony
      Note_Container,
      Harmony,

      // note's children
      Beam,
      Glissando,
      Lyric,
      Slur,
      Tie,
      Tuplet,

      // barline
      Numeric_Ending,

      KuoHao,
      Bar_End,
      Decorator,
      Multi_Measure_Rest,
      };

enum class MidiType : signed char {
      None = -1,
      Controller,
      Program_Change,
      Channel_Pressure,
      Pitch_Wheel,
      };

enum class ClefType : char {
      Treble = 0x00, //0x00
      Bass,          //0x01
      Alto,          //0x02
      UpAlto,        //0x03
      DownDownAlto,  //0x04
      DownAlto,      //0x05
      UpUpAlto,      //0x06
      Treble8va,     //0x07
      Bass8va,       //0x08
      Treble8vb,     //0x09
      Bass8vb,       //0x0A
      Percussion1,   //0x0B
      Percussion2,   //0x0C
      TAB            //0x0D
      };

enum class GroupType : char {
      None = 0,
      Brace,
      Bracket
      };

enum class AccidentalType : char {
      Normal              = 0x0,
      Sharp               = 0x1,
      Flat                = 0x2,
      Natural             = 0x3,
      DoubleSharp         = 0x4,
      DoubleFlat          = 0x5,
      Sharp_Caution       = 0x9,
      Flat_Caution        = 0xA,
      Natural_Caution     = 0xB,
      DoubleSharp_Caution = 0xC,
      DoubleFlat_Caution  = 0xD
      };

enum class NoteHeadType : char {
      Standard = 0x00,
      Invisible,
      Rhythmic_Slash,
      Percussion,
      Closed_Rhythm,
      Open_Rhythm,
      Closed_Slash,
      Open_Slash,
      Closed_Do,
      Open_Do,
      Closed_Re,
      Open_Re,
      Closed_Mi,
      Open_Mi,
      Closed_Fa,
      Open_Fa,
      Closed_Sol,
      Open_Sol,
      Closed_La,
      Open_La,
      Closed_Ti,
      Open_Ti
      };

enum class TiePos : char {
      None     = 0x0,
      LeftEnd  = 0x1,
      RightEnd = 0x2
      };

enum class ArticulationType : char {
      Major_Trill                  = 0x00,
      Minor_Trill                  = 0x01,
      Trill_Section                = 0x02,
      Inverted_Short_Mordent       = 0x03,
      Inverted_Long_Mordent        = 0x04,
      Short_Mordent                = 0x05,
      Turn                         = 0x06,
      Finger_1                     = 0x07,
      Finger_2                     = 0x08,
      Finger_3                     = 0x09,
      Finger_4                     = 0x0A,
      Finger_5                     = 0x0B,
      Flat_Accidental_For_Trill    = 0x0C,
      Sharp_Accidental_For_Trill   = 0x0D,
      Natural_Accidental_For_Trill = 0x0E,
      Marcato                      = 0x0F,
      Marcato_Dot                  = 0x10,
      Heavy_Attack                 = 0x11,
      SForzando                    = 0x12,
      SForzando_Dot                = 0x13,
      Heavier_Attack               = 0x14,
      SForzando_Inverted           = 0x15,
      SForzando_Dot_Inverted       = 0x16,
      Staccatissimo                = 0x17,
      Staccato                     = 0x18,
      Tenuto                       = 0x19,
      Up_Bow                       = 0x1A,
      Down_Bow                     = 0x1B,
      Up_Bow_Inverted              = 0x1C,
      Down_Bow_Inverted            = 0x1D,
      Arpeggio                     = 0x1E,
      Tremolo_Eighth               = 0x1F,
      Tremolo_Sixteenth            = 0x20,
      Tremolo_Thirty_Second        = 0x21,
      Tremolo_Sixty_Fourth         = 0x22,
      Natural_Harmonic             = 0x23,
      Artificial_Harmonic          = 0x24,
      Plus_Sign                    = 0x25,
      Fermata                      = 0x26,
      Fermata_Inverted             = 0x27,
      Pedal_Down                   = 0x28,
      Pedal_Up                     = 0x29,
      Pause                        = 0x2A,
      Grand_Pause                  = 0x2B,
      Toe_Pedal                    = 0x2C,
      Heel_Pedal                   = 0x2D,
      Toe_To_Heel_Pedal            = 0x2E,
      Heel_To_Toe_Pedal            = 0x2F,
      Open_String                  = 0x30, // finger 0 in guitar
      Guitar_Lift                  = 0x46,
      Guitar_Slide_Up              = 0x47,
      Guitar_Rip                   = 0x48,
      Guitar_Fall_Off              = 0x49,
      Guitar_Slide_Down            = 0x4A,
      Guitar_Spill                 = 0x4B,
      Guitar_Flip                  = 0x4C,
      Guitar_Smear                 = 0x4D,
      Guitar_Bend                  = 0x4E,
      Guitar_Doit                  = 0x4F,
      Guitar_Plop                  = 0x50,
      Guitar_Wow_Wow               = 0x51,
      Guitar_Thumb                 = 0x64,
      Guitar_Index_Finger          = 0x65,
      Guitar_Middle_Finger         = 0x66,
      Guitar_Ring_Finger           = 0x67,
      Guitar_Pinky_Finger          = 0x68,
      Guitar_Tap                   = 0x69,
      Guitar_Hammer                = 0x6A,
      Guitar_Pluck                 = 0x6B,

      None

      /*	Detached_Legato,
      Spiccato,
      Scoop,
      Plop,
      Doit,
      Falloff,
      Breath_Mark,
      Caesura,*/
      };

enum class NoteType : char {
      Note_DoubleWhole = 0x0,
      Note_Whole       = 0x1,
      Note_Half        = 0x2,
      Note_Quarter     = 0x3,
      Note_Eight       = 0x4,
      Note_Sixteen     = 0x5,
      Note_32          = 0x6,
      Note_64          = 0x7,
      Note_128         = 0x8,
      Note_256         = 0x9,

      Note_None
      };

inline int NoteTypeToTick(NoteType type, int quarter) {
      int c = int(pow(2.0, int(type))) ;
      return quarter * 4 * 2 / c ;
      }

enum class HarmonyType : char {
      H_maj = 0,
      H_min,
      H_aug,
      H_dim,
      H_dim7,
      H_sus2,
      H_sus4,
      H_sus24,
      H_add2,
      H_add9,
      H_omit3,
      H_omit5,
      H_2,
      H_5,
      H_6,
      H_69,
      H_7,
      H_7b5,
      H_7b9,
      H_7s9,
      H_7s11,
      H_7b5s9,
      H_7b5b9,
      H_7b9s9,
      H_7b9s11,
      H_7sus4,
      H_9,
      H_9b5,
      H_9s11,
      H_9sus4,
      H_11,
      H_13,
      H_13b5,
      H_13b9,
      H_13s9,
      H_13s11,
      H_13sus4,
      H_min_add2,
      H_min_add9,
      H_min_maj7,
      H_min6,
      H_min6_add9,
      H_min7,
      H_min7b5,
      H_min7_add4,
      H_min7_add11,
      H_min9,
      H_min9_b5,
      H_min9_maj7,
      H_min11,
      H_min13,
      H_maj7,
      H_maj7_b5,
      H_maj7_s5,
      H_maj7_69,
      H_maj7_add9,
      H_maj7_s11,
      H_maj9,
      H_maj9_sus4,
      H_maj9_b5,
      H_maj9_s5,
      H_maj9_s11,
      H_maj13,
      H_maj13_b5,
      H_maj13_b9,
      H_maj13_b9b5,
      H_maj13_s11,
      H_aug7,
      H_aug7_b9,
      H_aug7_s9,

      H_None
      };

enum class DynamicsType : char {
      PPPP = 0,
      PPP,
      PP,
      P,
      MP,
      MF,
      F,
      FF,
      FFF,
      FFFF,
      SF,
      FZ,
      SFZ,
      SFFZ,
      FP,
      SFP
      };

enum class WedgeType : char {
      Cres_Line = 0, // <
      Double_Line,   // <>, not appear in xml
      Decresc_Line,  // >
      Cres,          // cresc., not appear in xml, will create Expression
      Decresc        // decresc., not appear in xml, will create Expression
      };

enum class KuoHaoType : char {
      Parentheses = 0,
      Brace,
      Bracket
      };

enum class OctaveShiftType : char {
      OS_8 = 0,
      OS_Minus_8,
      OS_15,
      OS_Minus_15
      };

enum class OctaveShiftPosition : char {
      Start = 0 ,
      Continue,
      Stop
      };

enum class RepeatType : char {
      Segno = 0,
      Coda,
      ToCoda,
      DSAlCoda,
      DSAlFine,
      DCAlCoda,
      DCAlFine,
      Fine,

      Null
      };

enum class BarLineType : char {
      Default = 0, //0x00 will be | or final (at last measure)
      Double,      //0x01 ||
      RepeatLeft,  //0x02 ||:
      RepeatRight, //0x03 :||
      Final,       //0x04
      Dashed,      //0x05
      Null         //0x06
      } ;

enum class NoteDuration {
      D_256 = 15,
      D_128 = NoteDuration::D_256 * 2,           // 30
      D_64 = NoteDuration::D_128 * 2,            // 60
      D_32 = NoteDuration::D_64 * 2,             // 120
      D_16 = NoteDuration::D_32 * 2,             // 240
      D_8 = NoteDuration::D_16 * 2,              // 480
      D_4 = NoteDuration::D_8 * 2,               // 960
      D_2 = NoteDuration::D_4 * 2,               // 1920
      D_Whole = NoteDuration::D_2 * 2,           // 3840
      D_Double_Whole = NoteDuration::D_Whole * 2 // 7680
      };

enum class ToneType : char {
      C = 0,
      D,
      E,
      F,
      G,
      A,
      B
      };

enum class KeyType : char {
      Key_C = 0,		// C
      Key_Bass_1,		// F
      Key_Bass_2,		// Bb
      Key_Bass_3,		// Eb
      Key_Bass_4,		// Ab
      Key_Bass_5,		// Db
      Key_Bass_6,		// Gb
      Key_Bass_7,		// Cb
      Key_Sharp_1,	// G
      Key_Sharp_2,	// D
      Key_Sharp_3,	// A
      Key_Sharp_4,	// E
      Key_Sharp_5,	// B
      Key_Sharp_6,	// F#
      Key_Sharp_7		// C#
      };

// IOveNotify.h
class IOveNotify {
public:
      IOveNotify() {}
      virtual ~IOveNotify() {}

public:
      virtual void loadInfo(const QString& info) = 0;
      virtual void loadError() = 0;
      virtual void loadPosition(int currentMeasure, int totalMeasure, int currentTrack, int totalTrack) = 0;
      };

class IOVEStreamLoader {
public:
      IOVEStreamLoader() {}
      virtual ~IOVEStreamLoader() {}

public:
      virtual void setNotify(IOveNotify* notify) = 0;
      virtual void setFileStream(unsigned char* buffer, unsigned int size) = 0;
      virtual void setOve(OveSong* ove) = 0;

      // read stream, set readed data to setOve(ove)
      virtual bool load() = 0;

      virtual void release() = 0;
      };

DLL_EXPORT IOVEStreamLoader* createOveStreamLoader();

/////////////////////////////////////////////////////////////////////////////
// basic element
class TickElement {
public:
      TickElement();
      virtual ~TickElement() {}

public:
      void setTick(int tick);
      int getTick(void) const;

private:
      int tick_;
      };

class MeasurePos {
public:
      MeasurePos();
      virtual ~MeasurePos() {}

public:
      void setMeasure(int measure);
      int getMeasure() const;

      void setOffset(int offset);
      int getOffset() const;

      MeasurePos shiftMeasure(int measure) const;
      MeasurePos shiftOffset(int offset) const; // ignore cross measure

      bool operator ==(const MeasurePos& mp) const;
      bool operator !=(const MeasurePos& mp) const;
      bool operator <(const MeasurePos& mp) const;
      bool operator <=(const MeasurePos& mp) const;
      bool operator >(const MeasurePos& mp) const;
      bool operator >=(const MeasurePos& mp) const;

private:
      int measure_;
      int offset_;
      };

class PairElement {
public:
      PairElement();
      virtual ~PairElement();

public:
      MeasurePos* start() const;
      MeasurePos* stop() const;

private:
      MeasurePos* start_;
      MeasurePos* stop_;
      };

class PairEnds {
public:
      PairEnds();
      virtual ~PairEnds();

public:
      LineElement* getLeftLine() const;
      LineElement* getRightLine() const;

      OffsetElement* getLeftShoulder() const;
      OffsetElement* getRightShoulder() const;

private:
      LineElement* leftLine_;
      LineElement* rightLine_;
      OffsetElement* leftShoulder_;
      OffsetElement* rightShoulder_;
      };

class LineElement {
public:
      LineElement();
      virtual ~LineElement() {}

public:
      virtual void setLine(int line); // middle line (3rd line of each clef) is set 0
      virtual int getLine(void) const;

private:
      int line_;
      };

class OffsetElement {
public:
      OffsetElement();
      virtual ~OffsetElement() {}

public:
      virtual void setXOffset(int offset);
      virtual int getXOffset() const;

      virtual void setYOffset(int offset);
      virtual int getYOffset() const;

private:
      int xOffset_;
      int yOffset_;
      };

class LengthElement {
public:
      LengthElement();
      virtual ~LengthElement() {}

public:
      void setLength(int length);
      int getLength() const;

private:
      int length_; // tick
      };

// base class of many ove music element
class MusicData: public TickElement, public PairElement, public OffsetElement {
public:
      MusicData();
      virtual ~MusicData() {}

public:
      MusicDataType getMusicDataType() const;

      enum class XmlDataType : char {
            Attributes = 0, NoteBeam, Notations, Direction, None
            };
      static XmlDataType getXmlDataType(MusicDataType type);
      //	static bool get_is_pair_element(MusicDataType type) ;

      // show / hide
      void setShow(bool show);
      bool getShow() const;

      // color
      void setColor(unsigned int color); // not exists in ove 3
      unsigned int getColor() const;

      void setVoice(unsigned int voice);
      unsigned int getVoice() const;

      void copyCommonBlock(const MusicData& source);

protected:
      MusicDataType musicDataType_;

private:
      bool show_;
      unsigned int color_;
      unsigned int voice_;
      };

class MidiData: public TickElement {
public:
      MidiData();
      virtual ~MidiData() {}

public:
      MidiType getMidiType() const;

protected:
      MidiType midiType_;
      };


////////////////////////////////////////////////////////////////////////////////
class OveSong {
public:
      OveSong();
      ~OveSong();

public:
      void setIsVersion4(bool version4 = true);
      bool getIsVersion4() const;

      void setQuarter(int tick);
      int getQuarter(void) const;

      void setShowPageMargin(bool show);
      bool getShowPageMargin() const;

      void setShowTransposeTrack(bool show);
      bool getShowTransposeTrack() const;

      void setShowLineBreak(bool show);
      bool getShowLineBreak() const;

      void setShowRuler(bool show);
      bool getShowRuler() const;

      void setShowColor(bool show);
      bool getShowColor() const;

      void setPlayRepeat(bool play);
      bool getPlayRepeat() const;

      enum class PlayStyle : char {
            Record, Swing, Notation
            };
      void setPlayStyle(PlayStyle style);
      PlayStyle getPlayStyle() const;

      void addTitle(const QString& str);
      QList<QString> getTitles(void) const;

      void addAnnotate(const QString& str);
      QList<QString> getAnnotates(void) const;

      void addWriter(const QString& str);
      QList<QString> getWriters(void) const;

      void addCopyright(const QString& str);
      QList<QString> getCopyrights(void) const;

      void addHeader(const QString& str);
      QList<QString> getHeaders(void) const;

      void addFooter(const QString& str);
      QList<QString> getFooters(void) const;

      void addTrack(Track* ptr);
      int getTrackCount(void) const;
      QList<Track*> getTracks() const;
      Track* getTrack(int part, int staff) const;

      void setTrackBarCount(int count);
      int getTrackBarCount() const;

      bool addPage(Page* page);
      int getPageCount() const;
      Page* getPage(int idx);

      void addLine(Line* ptr);
      int getLineCount() const;
      Line* getLine(int idx) const;

      void addMeasure(Measure* ptr);
      int getMeasureCount(void) const;
      Measure* getMeasure(int bar) const;

      void addMeasureData(MeasureData* ptr);
      int getMeasureDataCount(void) const;
      MeasureData* getMeasureData(int part, int staff/*=0*/, int bar) const;
      MeasureData* getMeasureData(int track, int bar) const;

      // tool
      void setPartStaffCounts(const QList<int>& partStaffCounts);
      int getPartCount() const;
      int getStaffCount(int part) const;
      int getPartBarCount() const;

      void clear(void);

      QPair<int, int> trackToPartStaff(int track) const;

      void setTextCodecName(const QString& codecName);
      QString getCodecString(const QByteArray& text);

private:
      int partStaffToTrack(int part, int staff) const;

private:
      bool version4_;
      int quarter_;

      bool showPageMargin_;
      bool showTransposeTrack;
      bool showLineBreak_;
      bool showRuler_;
      bool showColor_;
      bool playRepeat_;
      PlayStyle playStyle_;

      QList<QString> titles_;
      QList<QString> annotates_;
      QList<QString> writers_;
      QList<QString> copyrights_;
      QList<QString> headers_;
      QList<QString> footers_;

      QList<Track*> tracks_;
      QList<Page*> pages_;
      QList<Line*> lines_;
      QList<Measure*> measures_;
      QList<MeasureData*> measureDatas_;
      int trackBarCount_;	//equal to measures_.size()

      QList<int> partStaffCounts_;
      QTextCodec* codec_;
      };

class Voice {
public:
      Voice();
      ~Voice(){}

public:
      void setChannel(int channel);
      int getChannel() const;

      void setVolume(int volume);
      int getVolume() const;

      void setPitchShift(int pitchShift);
      int getPitchShift() const;

      void setPan(int pan);
      int getPan() const;

      void setPatch(int patch);
      int getPatch() const;

      void setStemType(int stemType);
      int getStemType() const;

      static int getDefaultPatch();
      static int getDefaultVolume();

private:
      int channel_;		// [0, 15]
      int volume_;		// [-1, 127], -1 default
      int pitchShift_;	// [-36, 36]
      int pan_;			// [-64, 63]
      int patch_;			// [0, 127]
      int stemType_;		// 0, 1, 2
      };

class Track {
public:
      Track();
      ~Track();

public:
      void setName(const QString& str);
      QString getName(void) const;

      void setBriefName(const QString& str);
      QString getBriefName(void) const;

      void setPatch(unsigned int patch); // -1: percussion
      unsigned int getPatch() const;

      void setChannel(int channel);
      int getChannel() const;

      void setShowName(bool show);
      bool getShowName() const;

      void setShowBriefName(bool show);
      bool getShowBriefName() const;

      void setMute(bool mute);
      bool getMute() const;

      void setSolo(bool solo);
      bool getSolo() const;

      void setShowKeyEachLine(bool show);
      bool getShowKeyEachLine() const;

      void setVoiceCount(int voices);
      int getVoiceCount() const;

      void addVoice(Voice* voice);
      QList<Voice*> getVoices() const;

      void setShowTranspose(bool show);
      bool getShowTranspose() const;

      void setTranspose(int transpose);
      int getTranspose() const;

      void setNoteShift(int shift);
      int getNoteShift() const;

      void setStartClef(int clef/*in ClefType*/);
      ClefType getStartClef() const;

      void setTransposeClef(int clef/*in ClefType*/);
      ClefType getTansposeClef() const;

      void setStartKey(int key/*in KeyType*/);
      int getStartKey() const;

      void setDisplayPercent(unsigned int percent/*25~100*/);
      unsigned int getDisplayPercent() const;

      void setShowLegerLine(bool show);
      bool getShowLegerLine() const;

      void setShowClef(bool show);
      bool getShowClef() const;

      void setShowTimeSignature(bool show);
      bool getShowTimeSignature() const;

      void setShowKeySignature(bool show);
      bool getShowKeySignature() const;

      void setShowBarline(bool show);
      bool getShowBarline() const;

      void setFillWithRest(bool fill);
      bool getFillWithRest() const;

      void setFlatTail(bool flat);
      bool getFlatTail() const;

      void setShowClefEachLine(bool show);
      bool getShowClefEachLine() const;

      struct DrumNode {
            int line_;
            int headType_;
            int pitch_;
            int voice_;

      public:
            DrumNode():line_(0), headType_(0), pitch_(0), voice_(0){}
            };
      void addDrum(const DrumNode& node);
      QList<DrumNode> getDrumKit() const;

      void clear(void);

      /////////////////////////////////////////////////
      void setPart(int part);
      int getPart() const;

private:
      int number_;
      QString name_;
      QString briefName_;
      unsigned int patch_;
      int channel_;
      int transpose_;
      bool showTranspose_;
      int noteShift_;
      ClefType startClef_;
      ClefType transposeClef_;
      unsigned int displayPercent_;
      int startKey_;
      int voiceCount_;
      QList<Voice*> voices_;

      bool showName_;
      bool showBriefName_;
      bool showKeyEachLine_;
      bool showLegerLine_;
      bool showClef_;
      bool showTimeSignature_;
      bool showKeySignature_;
      bool showBarline_;
      bool showClefEachLine_;

      bool fillWithRest_;
      bool flatTail_;

      bool mute_;
      bool solo_;

      QList<DrumNode> drumKit_;

      //////////////////////////////
      int part_;
      };

class Page {
public:
      Page();
      ~Page(){}

public:
      void setBeginLine(int line);
      int getBeginLine() const;

      void setLineCount(int count);
      int getLineCount() const;

      void setLineInterval(int interval);	// between system
      int getLineInterval() const;

      void setStaffInterval(int interval);
      int getStaffInterval() const;

      void setStaffInlineInterval(int interval); // between treble-bass staff
      int getStaffInlineInterval() const;

      void setLineBarCount(int count);
      int getLineBarCount() const;

      void setPageLineCount(int count);
      int getPageLineCount() const;

      void setLeftMargin(int margin);
      int getLeftMargin() const;

      void setTopMargin(int margin);
      int getTopMargin() const;

      void setRightMargin(int margin);
      int getRightMargin() const;

      void setBottomMargin(int margin);
      int getBottomMargin() const;

      void setPageWidth(int width);
      int getPageWidth() const;

      void setPageHeight(int height);
      int getPageHeight() const;

private:
      int beginLine_;
      int lineCount_;

      int lineInterval_;
      int staffInterval_;
      int staffInlineInterval_;

      int lineBarCount_;
      int pageLineCount_;

      int leftMargin_;
      int topMargin_;
      int rightMargin_;
      int bottomMargin_;

      int pageWidth_;
      int pageHeight_;
      };

class Line {
public:
      Line();
      ~Line();

public:
      void addStaff(Staff* staff);
      int getStaffCount() const;
      Staff* getStaff(int idx) const;

      void setBeginBar(unsigned int bar);
      unsigned int getBeginBar() const;

      void setBarCount(unsigned int count);
      unsigned int getBarCount() const;

      void setYOffset(int offset);
      int getYOffset() const;

      void setLeftXOffset(int offset);
      int getLeftXOffset() const;

      void setRightXOffset(int offset);
      int getRightXOffset() const;

private:
      QList<Staff*> staffs_;
      unsigned int beginBar_;
      unsigned int barCount_;
      int yOffset_;
      int leftXOffset_;
      int rightXOffset_;
      };

class Staff : public OffsetElement {
public:
      Staff();
      virtual ~Staff(){}

public:
      void setClefType(int clef);
      ClefType getClefType() const;

      void setKeyType(int key);
      int getKeyType() const;

      void setVisible(bool visible);
      bool setVisible() const;

      void setGroupType(GroupType type);
      GroupType getGroupType() const;

      void setGroupStaffCount(int count);
      int getGroupStaffCount() const;

private:
      ClefType clef_;
      int key_;
      bool visible_;
      GroupType groupType_;
      int groupStaffCount_;
      };

///////////////////////////////////////////////////////////////////////////////

class Note : public LineElement {
public:
      Note();
      virtual ~Note(){}

public:
      void setIsRest(bool rest);
      bool getIsRest() const;

      void setNote(unsigned int note);
      unsigned int getNote() const;

      void setAccidental(int type);		//AccidentalType
      AccidentalType getAccidental() const;

      void setShowAccidental(bool show);
      bool getShowAccidental() const;

      void setOnVelocity(unsigned int velocity);
      unsigned int getOnVelocity() const;

      void setOffVelocity(unsigned int velocity);
      unsigned int getOffVelocity() const;

      void setHeadType(int type);		//NoteHeadType
      NoteHeadType getHeadType() const;

      void setTiePos(int tiePos);
      TiePos getTiePos() const;

      void setOffsetStaff(int offset);	// cross staff notes
      int getOffsetStaff() const;

      void setShow(bool show);
      bool getShow() const;

      void setOffsetTick(int offset);
      int getOffsetTick() const;

private:
      bool rest_;
      unsigned int note_;
      AccidentalType accidental_;
      bool showAccidental_;
      unsigned int onVelocity_;
      unsigned int offVelocity_;
      NoteHeadType headType_;
      TiePos tiePos_;
      int offsetStaff_;
      bool show_;
      int offsetTick_;//for playback
      };

class Articulation : public OffsetElement {
public:
      Articulation();
      virtual ~Articulation(){}

public:
      void setArtType(int type);//ArticulationType
      ArticulationType getArtType() const;

      void setPlacementAbove(bool above);
      bool getPlacementAbove() const;

      // for midi
      bool willAffectNotes() const;

      static bool isTrill(ArticulationType type);

      // for xml
      enum class XmlType : char {
            Articulation,
            Technical,
            Arpeggiate,
            Ornament,
            Fermata,
            Direction,

            Unknown
            };
      XmlType getXmlType() const;

      // sound setting
      bool getChangeSoundEffect() const;
      void setSoundEffect(int soundFrom, int soundTo);
      QPair<int, int> getSoundEffect() const;

      bool getChangeLength() const;
      void setLengthPercentage(int percentage);
      int getLengthPercentage() const;

      bool getChangeVelocity() const;
      enum class VelocityType : char {
            Offset,
            SetValue,
            Percentage
            };
      void setVelocityType(VelocityType type);
      VelocityType getVelocityType() const;

      void setVelocityValue(int value);
      int getVelocityValue() const;

      bool getChangeExtraLength() const;
      void setExtraLength(int length);
      int getExtraLength() const;

      // trill
      enum class TrillInterval : char {
            Diatonic = 0,
            Chromatic,
            Whole
            };
      void setTrillInterval(int interval);
      TrillInterval getTrillInterval() const;

      void setAuxiliaryFirst(bool first);
      bool getAuxiliaryFirst() const;

      void setTrillRate(NoteType rate);
      NoteType getTrillRate() const;

      void setTrillNoteLength(int length);
      int getTrillNoteLength() const;

      enum class AccelerateType : char {
            None = 0 ,
            Slow,
            Normal,
            Fast
            };
      void setAccelerateType(int type);
      AccelerateType getAccelerateType() const;

private:
      ArticulationType type_;
      bool above_;

      bool changeSoundEffect_;
      QPair<int, int> soundEffect_;
      bool changeLength_;
      int lengthPercentage_;
      bool changeVelocity_;
      VelocityType velocityType_;
      int velocityValue_;
      bool changeExtraLength_;
      int extraLength_;

      // trill
      TrillInterval trillInterval_;
      bool auxiliaryFirst_;
      NoteType trillRate_;
      int trillNoteLength_;
      AccelerateType accelerateType_;
      };

class NoteContainer : public MusicData, public LengthElement {
public:
      NoteContainer();
      virtual ~NoteContainer();

public:
      void setIsGrace(bool grace);
      bool getIsGrace() const;

      void setIsCue(bool cue);
      bool getIsCue() const;

      void setIsRest(bool rest/*or note*/);
      bool getIsRest() const;

      void setIsRaw(bool raw);
      bool getIsRaw() const;

      void setNoteType(NoteType type);
      NoteType getNoteType() const;

      void setDot(int dot);
      int getDot() const;

      void setGraceNoteType(NoteType type);
      NoteType getGraceNoteType() const;

      void setInBeam(bool in);
      bool getInBeam() const;

      void setStemUp(bool up);
      bool getStemUp(void) const;

      void setShowStem(bool show);
      bool getShowStem() const;

      void setStemLength(int line);
      int getStemLength() const;

      void setTuplet(int tuplet);
      int getTuplet() const;

      void setSpace(int space);
      int getSpace() const;

      void addNoteRest(Note* note);
      QList<Note*> getNotesRests() const;

      void addArticulation(Articulation* art);
      QList<Articulation*> getArticulations() const;

      void setNoteShift(int octave);
      int getNoteShift() const;

      int getOffsetStaff() const;

      int getDuration() const;

private:
      bool grace_;
      bool cue_;
      bool rest_;
      bool raw_;
      NoteType noteType_;
      int dot_;
      NoteType graceNoteType_;
      int tuplet_;
      int space_;
      bool inBeam_;
      bool stemUp_;
      bool showStem_;
      int stemLength_;	// line count span
      int noteShift_;

      QList<Note*> notes_;
      QList<Articulation*> articulations_;
      };

class Beam : public MusicData, public PairEnds {
public:
      Beam();
      virtual ~Beam(){}

public:
      void setIsGrace(bool grace);
      bool getIsGrace() const;

      void addLine(const MeasurePos& startMp, const MeasurePos& endMp);
      const QList<QPair<MeasurePos, MeasurePos> > getLines() const;

private:
      bool grace_;
      QList<QPair<MeasurePos, MeasurePos> > lines_;
      };

class Tie : public MusicData, public PairEnds {
public:
      Tie();
      virtual ~Tie(){}

public:
      void setShowOnTop(bool top);
      bool getShowOnTop() const;

      void setNote(int note);// note value tie point to
      int getNote() const;

      void setHeight(int height);
      int getHeight() const;

private:
      bool showOnTop_;
      int note_;
      int height_;
      };

class Glissando : public MusicData, public PairEnds {
public:
      Glissando();
      virtual ~Glissando(){}

public:
      void setStraightWavy(bool straight);
      bool getStraightWavy() const;

      void setText(const QString& text);
      QString getText() const;

      void setLineThick(int thick);
      int getLineThick() const;

private:
      bool straight_;
      QString text_;
      int lineThick_;
      };

class Decorator : public MusicData {
public:
      Decorator();
      virtual ~Decorator(){}

public:
      enum class Type : char {
            Dotted_Barline = 0,
            Articulation
            };
      void setDecoratorType(Type type);
      Type getDecoratorType() const;

      void setArticulationType(ArticulationType type);
      ArticulationType getArticulationType() const;

private:
      Type decoratorType_;
      ArticulationType artType_;
      };

class MeasureRepeat : public MusicData {
public:
      MeasureRepeat();
      virtual ~MeasureRepeat(){}

public:
      void setSingleRepeat(bool single); // false : double
      bool getSingleRepeat() const;

private:
      bool singleRepeat_;
      };

class Tuplet : public MusicData, public PairEnds {
public:
      Tuplet();
      virtual ~Tuplet();

public:
      void setTuplet(int tuplet=3);
      int getTuplet() const;

      void setSpace(int space=2);
      int getSpace() const;

      void setHeight(int height);
      int getHeight() const;

      void setNoteType(NoteType type);
      NoteType getNoteType() const;

      OffsetElement* getMarkHandle() const;

private:
      int tuplet_;
      int space_;
      int height_;
      NoteType noteType_;
      OffsetElement* mark_;
      };

class Harmony : public MusicData, public LengthElement {
public:
      Harmony();
      virtual ~Harmony(){}

public:
      void setHarmonyType(HarmonyType type);
      HarmonyType getHarmonyType() const;

      void setRoot(int root=0);//C
      int getRoot() const;

      void setBass(int bass);
      int getBass() const;

      void setBassOnBottom(bool on);
      bool getBassOnBottom() const;

      void setAngle(int angle);
      int getAngle() const;

private:
      HarmonyType harmonyType_;
      int root_;
      int bass_;
      bool bassOnBottom_;
      int angle_;
      };

class Clef : public MusicData, public LineElement {
public:
      Clef();
      virtual ~Clef(){}

public:
      void setClefType(int type);	// ClefType
      ClefType getClefType() const;

private:
      ClefType clefType_;
      };

class Lyric : public MusicData {
public:
      Lyric();
      virtual ~Lyric(){}

public:
      void setLyric(const QString& lyricText);
      QString getLyric() const;

      void setVerse(int verse);
      int getVerse() const;

private:
      QString lyric_;
      int verse_;
      };

class Slur: public MusicData, public PairEnds {
public:
      Slur();
      virtual ~Slur();

public:
      void setContainerCount(int count); // span
      int getContainerCount() const;

      void setShowOnTop(bool top);
      bool getShowOnTop() const;

      OffsetElement* getHandle2() const;
      OffsetElement* getHandle3() const;

      void setNoteTimePercent(int percent); // 50% ~ 200%
      int getNoteTimePercent() const;

private:
      int containerCount_;
      bool showOnTop_;
      int noteTimePercent_;
      OffsetElement* handle_2_;
      OffsetElement* handle_3_;
      };

class Dynamics: public MusicData {
public:
      Dynamics();
      virtual ~Dynamics() {}

public:
      void setDynamicsType(int type);//DynamicsType
      DynamicsType getDynamicsType() const;

      void setIsPlayback(bool play);
      bool getIsPlayback() const;

      void setVelocity(int vel);
      int getVelocity() const;

private:
      DynamicsType dynamicsType_;
      bool playback_;
      int velocity_;
      };

class WedgeEndPoint: public MusicData {
public:
      WedgeEndPoint();
      virtual ~WedgeEndPoint() {}

public:
      void setWedgeType(WedgeType type);
      WedgeType getWedgeType() const;

      void setHeight(int height);
      int getHeight() const;

      void setWedgeStart(bool wedgeStart);
      bool getWedgeStart() const;

private:
      int height_;
      WedgeType wedgeType_;
      bool wedgeStart_;
      };

class Wedge: public MusicData {
public:
      Wedge();
      virtual ~Wedge() {}

public:
      void setWedgeType(WedgeType type);
      WedgeType getWedgeType() const;

      void setHeight(int height);
      int getHeight() const;

private:
      int height_;
      WedgeType wedgeType_;
      };

class Pedal: public MusicData, public PairEnds {
public:
      Pedal();
      virtual ~Pedal();

public:
      void setHalf(bool half);
      bool getHalf() const;

      void setIsPlayback(bool playback);
      bool getIsPlayback() const;

      void setPlayOffset(int offset); // -127~127
      int getPlayOffset() const;

      OffsetElement* getPedalHandle() const; //only on half pedal

private:
      bool half_;
      bool playback_;
      int playOffset_;
      OffsetElement* pedalHandle_;
      };

class KuoHao: public MusicData, public PairEnds {
public:
      KuoHao();
      virtual ~KuoHao() {}

public:
      void setHeight(int height);
      int getHeight() const;

      void setKuohaoType(int type);// KuoHaoType
      KuoHaoType getKuohaoType() const;

private:
      int height_;
      KuoHaoType kuohaoType_;
      };

class Expressions: public MusicData {
public:
      Expressions();
      virtual ~Expressions() {}

public:
      void setText(const QString& str);
      QString getText() const;

private:
      QString text_;
      };

class HarpPedal: public MusicData {
public:
      HarpPedal();
      virtual ~HarpPedal() {}

public:
      void setShowType(int type);//0:graph, 1:char, 2:char cut, 3:change
      int getShowType() const;

      void setShowCharFlag(int flag);//each bit is a bool, total 7 bools
      int getShowCharFlag() const;

private:
      int showType_;
      int showCharFlag_;
      };

class OctaveShift: public MusicData, public LengthElement {
public:
      OctaveShift();
      virtual ~OctaveShift() {}

public:
      void setOctaveShiftType(OctaveShiftType type);
      OctaveShiftType getOctaveShiftType() const;

      void setOctaveShiftPosition(OctaveShiftPosition position);
      OctaveShiftPosition getOctaveShiftPosition() const;

      int getNoteShift() const;

      void setEndTick(int tick);
      int getEndTick() const;

private:
      OctaveShiftType octaveShiftType_;
      OctaveShiftPosition octaveShiftPosition_;
      int endTick_;
      };

class OctaveShiftEndPoint: public MusicData, public LengthElement {
public:
      OctaveShiftEndPoint();
      virtual ~OctaveShiftEndPoint() {}

public:
      void setOctaveShiftType(OctaveShiftType type);
      OctaveShiftType getOctaveShiftType() const;

      void setOctaveShiftPosition(OctaveShiftPosition position);
      OctaveShiftPosition getOctaveShiftPosition() const;

      void setEndTick(int tick);
      int getEndTick() const;

private:
      OctaveShiftType octaveShiftType_;
      OctaveShiftPosition octaveShiftPosition_;
      int endTick_;
      };

class MultiMeasureRest: public MusicData {
public:
      MultiMeasureRest();
      virtual ~MultiMeasureRest() {}

public:
      void setMeasureCount(int count);
      int getMeasureCount() const;

private:
      int measureCount_;
      };

class Tempo: public MusicData {
public:
      Tempo();
      virtual ~Tempo() {}

public:
      void setLeftNoteType(int type);//NoteType
      NoteType getLeftNoteType() const;

      void setShowMark(bool show);
      bool getShowMark() const;

      void setShowBeforeText(bool show);
      bool getShowBeforeText() const;

      void setShowParenthesis(bool show);
      bool getShowParenthesis() const;

      void setTypeTempo(double tempo); //0x2580 = 96.00
      double getTypeTempo() const;
      double getQuarterTempo() const;

      void setLeftText(const QString& str);// string at left of the mark
      QString getLeftText() const;

      void setRightText(const QString& str);
      QString getRightText() const;

      void setSwingEighth(bool swing);
      bool getSwingEighth() const;

      void setRightNoteType(int type);
      NoteType getRightNoteType() const;

      void setLeftNoteDot(bool showDot);
      bool getLeftNoteDot() const;

      void setRightNoteDot(bool showDot);
      bool getRightNoteDot() const;

      void setRightSideType(int type);
      int getRightSideType() const;

private:
      int leftNoteType_;
      bool showMark_;
      bool showText_;
      bool showParenthesis_;
      double typeTempo_;
      QString leftText_;
      QString rightText_;
      bool swingEighth_;
      int rightNoteType_;
      bool leftNoteDot_;
      bool rightNoteDot_;
      int rightSideType_;
      };

class Text: public MusicData, public LengthElement {
public:
      Text();
      virtual ~Text() {}

public:
      enum class Type : char {
            Rehearsal,
            SystemText,
            MeasureText
            };

      void setTextType(Type type);
      Type getTextType() const;

      void setHorizontalMargin(int margin);
      int getHorizontalMargin() const;

      void setVerticalMargin(int margin);
      int getVerticalMargin() const;

      void setLineThick(int thick);
      int getLineThick() const;

      void setText(const QString& text);
      QString getText() const;

      void setWidth(int width);
      int getWidth() const;

      void setHeight(int height);
      int getHeight() const;

private:
      Type textType_;
      int horiMargin_;
      int vertMargin_;
      int lineThick_;
      QString text_;
      int width_;
      int height_;
      };

///////////////////////////////////////////////////////////////////////////////

class TimeSignature: public MusicData {
public:
      TimeSignature();
      virtual ~TimeSignature() {}

public:
      void setNumerator(int numerator);
      int getNumerator() const;

      void setDenominator(int denominator);
      int getDenominator() const;

      void setIsSymbol(bool symbol); //4/4:common, 2/2:cut
      bool getIsSymbol() const;

      void setBeatLength(int length); // tick
      int getBeatLength() const;

      void setBarLength(int length); // tick
      int getBarLength() const;

      void addBeat(int startUnit, int lengthUnit, int startTick);
      void endAddBeat();
      int getUnits() const;

      void setReplaceFont(bool replace);
      bool getReplaceFont() const;

      void setShowBeatGroup(bool show);
      bool getShowBeatGroup() const;

      void setGroupNumerator1(int numerator);
      void setGroupNumerator2(int numerator);
      void setGroupNumerator3(int numerator);
      void setGroupDenominator1(int denominator);
      void setGroupDenominator2(int denominator);
      void setGroupDenominator3(int denominator);

      void setBeamGroup1(int count);
      void setBeamGroup2(int count);
      void setBeamGroup3(int count);
      void setBeamGroup4(int count);

      void set16thBeamCount(int count);
      void set32thBeamCount(int count);

private:
      int numerator_;
      int denominator_;
      bool isSymbol_;
      int beatLength_;
      int barLength_;

      struct BeatNode {
            int startUnit_;
            int lengthUnit_;
            int startTick_;

            BeatNode() :
                  startUnit_(0),
                  lengthUnit_(0),
                  startTick_(0) {
                  }
            };
      QList<BeatNode> beats_;
      int barLengthUnits_;

      bool replaceFont_;
      bool showBeatGroup_;

      int groupNumerator1_;
      int groupNumerator2_;
      int groupNumerator3_;
      int groupDenominator1_;
      int groupDenominator2_;
      int groupDenominator3_;

      int beamGroup1_;
      int beamGroup2_;
      int beamGroup3_;
      int beamGroup4_;

      int beamCount16th_;
      int beamCount32th_;
      };

class Key: public MusicData {
public:
      Key();
      virtual ~Key() {}

public:
      void setKey(int key); //C=0x0, G=0x8, C#=0xE, F=0x1, Db=0x7
      int getKey() const;
      bool getSetKey() const;

      void setPreviousKey(int key);
      int getPreviousKey() const;

      void setSymbolCount(int count);
      int getSymbolCount() const;

private:
      int key_;
      bool set_;
      int previousKey_;
      int symbolCount_;
      };

class RepeatSymbol: public MusicData {
public:
      RepeatSymbol();
      virtual ~RepeatSymbol() {}

public:
      void setText(const QString& text);
      QString getText() const;

      void setRepeatType(int repeatType);
      RepeatType getRepeatType() const;

private:
      QString text_;
      RepeatType repeatType_;
      };

class NumericEnding: public MusicData, public PairEnds {
public:
      NumericEnding();
      virtual ~NumericEnding();

public:
      OffsetElement* getNumericHandle() const;

      void setHeight(int height);
      int getHeight() const;

      void setText(const QString& text);
      QString getText() const;
      QList<int> getNumbers() const;
      int getJumpCount() const;

private:
      int height_;
      QString text_;
      OffsetElement* numericHandle_;
      };

class BarNumber: public MusicData {
public:
      BarNumber();
      virtual ~BarNumber() {}

public:
      void setIndex(int index);
      int getIndex() const;

      void setShowOnParagraphStart(bool show);
      bool getShowOnParagraphStart() const;

      void setAlign(int align);// 0:left, 1:center, 2:right
      int getAlign() const;

      void setShowFlag(int flag); // 0:page, 1:staff, 2:bar, 3:none
      int getShowFlag() const;

      void setShowEveryBarCount(int count);
      int getShowEveryBarCount() const;

      void setPrefix(const QString& str);
      QString getPrefix() const;

private:
      int index_;
      bool showOnParagraphStart_;
      int align_;
      int showFlag_;
      int barRange_;
      QString prefix_;
      };

///////////////////////////////////////////////////////////////////////////////
// MIDI
class MidiController: public MidiData {
public:
      MidiController();
      virtual ~MidiController() {}

public:
      void setController(int number);
      int getController() const;

      void setValue(int value);
      int getValue() const;

private:
      int controller_;
      int value_;
      };

class MidiProgramChange: public MidiData {
public:
      MidiProgramChange();
      virtual ~MidiProgramChange() {}

public:
      void setPatch(int patch);
      int getPatch() const;

private:
      int patch_;
      };

class MidiChannelPressure: public MidiData {
public:
      MidiChannelPressure();
      virtual ~MidiChannelPressure() {}

public:
      void setPressure(int pressure);
      int getPressure() const;

private:
      int pressure_;
      };

class MidiPitchWheel: public MidiData {
public:
      MidiPitchWheel();
      virtual ~MidiPitchWheel() {}

public:
      void setValue(int value);
      int getValue() const;

private:
      int value_;
      };

///////////////////////////////////////////////////////////////////////////////
class Measure: public LengthElement {
public:
      Measure(int index = 0);
      virtual ~Measure();

private:
      Measure();

public:
      BarNumber* getBarNumber() const;
      TimeSignature* getTime() const;

      void setLeftBarline(int barline/*in BarLineType*/);
      BarLineType getLeftBarline() const;

      void setRightBarline(int barline/*in BarLineType*/);
      BarLineType getRightBarline() const;

      // set when rightBarline == Baline_Backward
      void setBackwardRepeatCount(int repeatCount);
      int getBackwardRepeatCount() const;

      void setTypeTempo(double tempo);
      double getTypeTempo() const;

      void setIsPickup(bool pickup);
      bool getIsPickup() const;

      void setIsMultiMeasureRest(bool rest);
      bool getIsMultiMeasureRest() const;

      void setMultiMeasureRestCount(int count);
      int getMultiMeasureRestCount() const;

private:
      void clear();

      BarNumber* barNumber_;
      TimeSignature* time_;

      BarLineType leftBarline_;
      BarLineType rightBarline_;
      int repeatCount_;
      double typeTempo_; // based on some type
      bool pickup_;
      bool multiMeasureRest_;
      int multiMeasureRestCount_;
      };

class MeasureData {
public:
      MeasureData();
      ~MeasureData();

public:
      Clef* getClef() const;
      Key* getKey() const;

      void addNoteContainer(NoteContainer* ptr);
      QList<NoteContainer*> getNoteContainers() const;

      // put Tempo, Text, RepeatSymbol to MeasureData at part=0 && staff=0
      void addMusicData(MusicData* ptr);
      // if type==MusicData_None, return all
      QList<MusicData*> getMusicDatas(MusicDataType type);//MusicXml: note|direction|harmony

      // put NumericEnding to MeasureData at part=0 && staff=0
      void addCrossMeasureElement(MusicData* ptr, bool start);
      enum class PairType : char {
            Start,
            Stop,
            All
            };
      QList<MusicData*> getCrossMeasureElements(MusicDataType type, PairType pairType);

      // for midi
      void addMidiData(MidiData* ptr);
      QList<MidiData*> getMidiDatas(MidiType type);

private:
      Key* key_;
      Clef* clef_;
      QList<MusicData*> musicDatas_;
      QList<NoteContainer*> noteContainers_;
      QList<QPair<MusicData*, bool> > crossMeasureElements_;
      QList<MidiData*> midiDatas_;
      };

// StreamHandle
class StreamHandle {
public:
      StreamHandle(unsigned char* p, int size);
      virtual ~StreamHandle();

private:
      StreamHandle();

public:
      virtual bool read(char* buff, int size);
      virtual bool write(char* buff, int size);

private:
      int size_;
      int curPos_;
      unsigned char* point_;
      };

// Block.h
// base block, or resizable block in ove to store data
class Block {
public:
      Block();
      explicit Block(unsigned int size);
      virtual ~Block() {
            }

public:
      // size > 0, check this in use code
      virtual void resize(unsigned int count);

      const unsigned char* data() const;
      unsigned char* data();
      int size() const;

      bool operator ==(const Block& block) const;
      bool operator !=(const Block& block) const;

      bool toBoolean() const;
      unsigned int toUnsignedInt() const;
      int toInt() const;
      QByteArray toStrByteArray() const;					// string
      QByteArray fixedSizeBufferToStrByteArray() const;	// string

private:
      void doResize(unsigned int count);

private:
      // char [-128, 127], unsigned char [0, 255]
      QList<unsigned char> data_;
      };

class FixedBlock: public Block {
public:
      explicit FixedBlock(unsigned int count);
      virtual ~FixedBlock() {
            }

private:
      FixedBlock();

private:
      // can't resize
      virtual void resize(unsigned int count);
      };

///////////////////////////////////////////////////////////////////////////////
// 4 byte block in ove to store size
class SizeBlock: public FixedBlock {
public:
      SizeBlock();
      virtual ~SizeBlock() {
            }

public:
      //	void fromUnsignedInt(unsigned int count) ;

      unsigned int toSize() const;
      };

// 4 bytes block in ove to store name
class NameBlock: public FixedBlock {
public:
      NameBlock();
      virtual ~NameBlock() {
            }

public:
      // ingore data more than 4 bytes
      bool isEqual(const QString& name) const;
      };

// 2 bytes block in ove to store count
class CountBlock: public FixedBlock {
public:
      CountBlock();
      virtual ~CountBlock() {
            }

public:
      //	void setValue(unsigned short count) ;

      unsigned short toCount() const;
      };

// Chunk.h
// content : name
class Chunk {
public:
      Chunk();
      virtual ~Chunk() {
            }

public:
      const static QString TrackName;
      const static QString PageName;
      const static QString LineName;
      const static QString StaffName;
      const static QString MeasureName;
      const static QString ConductName;
      const static QString BdatName;

      NameBlock getName() const;

protected:
      NameBlock nameBlock_;
      };

// content : name / size / data
class SizeChunk: public Chunk {
public:
      SizeChunk();
      virtual ~SizeChunk();

public:
      SizeBlock* getSizeBlock() const;
      Block* getDataBlock() const;

      const static unsigned int version3TrackSize;

protected:
      SizeBlock* sizeBlock_;
      Block* dataBlock_;
      };

// content : name / count
class GroupChunk: public Chunk {
public:
      GroupChunk();
      virtual ~GroupChunk();

public:
      CountBlock* getCountBlock() const;

protected:
      CountBlock* childCount_;
      };

// ChunkParse.h
class BasicParse {
public:
      BasicParse(OveSong* ove);
      virtual ~BasicParse();

private:
      BasicParse();

public:
      void setNotify(IOveNotify* notify);
      virtual bool parse();

protected:
      bool readBuffer(Block& placeHolder, int size);
      bool jump(int offset);

      void messageOut(const QString& str);

protected:
      OveSong* ove_;
      StreamHandle* handle_;
      IOveNotify* notify_;
      };

///////////////////////////////////////////////////////////////////////////////

class OvscParse: public BasicParse {
public:
      OvscParse(OveSong* ove);
      virtual ~OvscParse();

public:
      void setOvsc(SizeChunk* chunk);

      virtual bool parse();

private:
      SizeChunk* chunk_;
      };

class TrackParse: public BasicParse {
public:
      TrackParse(OveSong* ove);
      virtual ~TrackParse();

public:
      void setTrack(SizeChunk* chunk);

      virtual bool parse();

private:
      SizeChunk* chunk_;
      };

class GroupParse: BasicParse {
public:
      GroupParse(OveSong* ove);
      virtual ~GroupParse();

public:
      void addSizeChunk(SizeChunk* sizeChunk);

      virtual bool parse();

private:
      QList<SizeChunk*> sizeChunks_;
      };

class PageGroupParse: public BasicParse {
public:
      PageGroupParse(OveSong* ove);
      virtual ~PageGroupParse();

public:
      void addPage(SizeChunk* chunk);

      virtual bool parse();

private:
      bool parsePage(SizeChunk* chunk, Page* page);

private:
      QList<SizeChunk*> pageChunks_;
      };

class StaffCountGetter: public BasicParse {
public:
      StaffCountGetter(OveSong* ove);
      virtual ~StaffCountGetter() {}

public:
      unsigned int getStaffCount(SizeChunk* chunk);
      };

class LineGroupParse: public BasicParse {
public:
      LineGroupParse(OveSong* ove);
      virtual ~LineGroupParse();

public:
      void setLineGroup(GroupChunk* chunk);
      void addLine(SizeChunk* chunk);
      void addStaff(SizeChunk* chunk);

      virtual bool parse();

private:
      bool parseLine(SizeChunk* chunk, Line* line);
      bool parseStaff(SizeChunk* chunk, Staff* staff);

private:
      GroupChunk* chunk_;
      QList<SizeChunk*> lineChunks_;
      QList<SizeChunk*> staffChunks_;
      };

class BarsParse: public BasicParse {
public:
      BarsParse(OveSong* ove);
      virtual ~BarsParse();

public:
      void addMeasure(SizeChunk* chunk);
      void addConduct(SizeChunk* chunk);
      void addBdat(SizeChunk* chunk);

      virtual bool parse();

private:
      bool parseMeas(Measure* measure, SizeChunk* chunk);
      bool parseCond(Measure* measure, MeasureData* measureData, SizeChunk* chunk);
      bool parseBdat(Measure* measure, MeasureData* measureData, SizeChunk* chunk);

      bool getCondElementType(unsigned int byteData, CondType& type);
      bool getBdatElementType(unsigned int byteData, BdatType& type);

      // COND
      bool parseTimeSignature(Measure* measure, int length);
      bool parseTimeSignatureParameters(Measure* measure, int length);
      bool parseRepeatSymbol(MeasureData* measureData, int length);
      bool parseNumericEndings(MeasureData* measureData, int length);
      bool parseTempo(MeasureData* measureData, int length);
      bool parseBarNumber(Measure* measure, int length);
      bool parseText(MeasureData* measureData, int length);
      bool parseBarlineParameters(Measure* measure, int length);

      // BDAT
      bool parseNoteRest(MeasureData* measureData, int length, BdatType type);
      bool parseBeam(MeasureData* measureData, int length);
      bool parseTie(MeasureData* measureData, int length);
      bool parseTuplet(MeasureData* measureData, int length);
      bool parseHarmony(MeasureData* measureData, int length);
      bool parseClef(MeasureData* measureData, int length);
      bool parseLyric(MeasureData* measureData, int length);
      bool parseSlur(MeasureData* measureData, int length);
      bool parseGlissando(MeasureData* measureData, int length);
      bool parseDecorators(MeasureData* measureData, int length);
      bool parseDynamics(MeasureData* measureData, int length);
      bool parseWedge(MeasureData* measureData, int length);
      bool parseKey(MeasureData* measureData, int length);
      bool parsePedal(MeasureData* measureData, int length);
      bool parseKuohao(MeasureData* measureData, int length);
      bool parseExpressions(MeasureData* measureData, int length);
      bool parseHarpPedal(MeasureData* measureData, int length);
      bool parseMultiMeasureRest(MeasureData* measureData, int length);
      bool parseHarmonyGuitarFrame(MeasureData* measureData, int length);
      bool parseOctaveShift(MeasureData* measureData, int length);
      bool parseMidiController(MeasureData* measureData, int length);
      bool parseMidiProgramChange(MeasureData* measureData, int length);
      bool parseMidiChannelPressure(MeasureData* measureData, int length);
      bool parseMidiPitchWheel(MeasureData* measureData, int length);

      bool parseSizeBlock(int length);
      bool parseMidiCommon(MidiData* ptr);
      bool parseCommonBlock(MusicData* ptr);
      bool parseOffsetCommonBlock(MusicData* ptr);
      bool parsePairLinesBlock(PairEnds* ptr); //size==2
      bool parseOffsetElement(OffsetElement* ptr);//size==2

private:
      QList<SizeChunk*> measureChunks_;
      QList<SizeChunk*> conductChunks_;
      QList<SizeChunk*> bdatChunks_;
      };

class LyricChunkParse: public BasicParse {
public:
      LyricChunkParse(OveSong* ove);
      virtual ~LyricChunkParse() {}

public:
      void setLyricChunk(SizeChunk* chunk);

      virtual bool parse();

private:
      struct LyricInfo {
            int track_;
            int measure_;
            int verse_;
            int voice_;
            int wordCount_;
            int lyricSize_;
            QString name_;
            QString lyric_;
            int font_;
            int fontSize_;
            int fontStyle_;

            LyricInfo() :
                  track_(0), measure_(0), verse_(0), voice_(0), wordCount_(0),
                  lyricSize_(0), name_(QString()), lyric_(QString()),
                  font_(0), fontSize_(12), fontStyle_(0) {}
            };

      void processLyricInfo(const LyricInfo& info);

private:
      SizeChunk* chunk_;
      };

class TitleChunkParse: public BasicParse {
public:
      TitleChunkParse(OveSong* ove);
      virtual ~TitleChunkParse() {}

public:
      void setTitleChunk(SizeChunk* chunk);

      virtual bool parse();

private:
      void addToOve(const QString& str, unsigned int titleType);

private:
      unsigned int titleType_;
      unsigned int annotateType_;
      unsigned int writerType_;
      unsigned int copyrightType_;
      unsigned int headerType_;
      unsigned int footerType_;

      SizeChunk* chunk_;
      };

// OveOrganizer.h
class OveOrganizer {
public:
      OveOrganizer(OveSong* ove) ;
      virtual ~OveOrganizer(){}

public:
      void organize() ;

private:
      void organizeAttributes() ;
      void organizeTracks() ;
      void organizeMeasures() ;
      void organizeMeasure(int part, int track, Measure* measure, MeasureData* measureData) ;

      void organizeContainers(int part, int track, Measure* measure, MeasureData* measureData) ;
      void organizeMusicDatas(int part, int track, Measure* measure, MeasureData* measureData) ;
      void organizeCrossMeasureElements(int part, int track, Measure* measure, MeasureData* measureData) ;

      void organizePairElement(MusicData* data, int part, int track, Measure* measure, MeasureData* measureData) ;
      void organizeOctaveShift(OctaveShift* octave, Measure* measure, MeasureData* measureData) ;
      void organizeWedge(Wedge* wedge, int part, int track, Measure* measure, MeasureData* measureData) ;

private:
      OveSong* ove_ ;
      };

// OveSerialize.h
class StreamHandle;
class Block;
class NameBlock;
class Chunk;
class SizeChunk;
class GroupChunk;

class OveSerialize: public IOVEStreamLoader {
public:
      OveSerialize();
      virtual ~OveSerialize();

public:
      virtual void setOve(OveSong* ove);
      virtual void setFileStream(unsigned char* buffer, unsigned int size);
      virtual void setNotify(IOveNotify* notify);
      virtual bool load(void);

      virtual void release();

private:
      bool readNameBlock(NameBlock& nameBlock);
      bool readChunkName(Chunk* chunk, const QString& name);
      bool readSizeChunk(SizeChunk* sizeChunk); // contains a SizeChunk and data buffer
      bool readDataChunk(Block* block, unsigned int size);
      bool readGroupChunk(GroupChunk* groupChunk);

      bool readHeader();
      bool readHeadData(SizeChunk* ovscChunk);
      bool readTracksData();
      bool readPagesData();
      bool readLinesData();
      bool readBarsData();
      bool readOveEnd();

      void messageOutError();
      void messageOut(const QString& str);

private:
      OveSong* ove_;
      StreamHandle* streamHandle_;
      IOveNotify* notify_;
      };

}

#endif