1 /* This file is part of the KDE project
2  * Copyright (C) 2007 Marijn Kruisselbrink <mkruisselbrink@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 #ifndef MUSIC_CORE_GLOBAL_H
20 #define MUSIC_CORE_GLOBAL_H
21 
22 #include <QString>
23 
24 namespace MusicCore {
25     /**
26      * This enum contains constants representing the lengths of various notes. The length of a 128th note is
27      * 1*2*3*4*5*7 ticks to allow n-tuples with n from 3..10. The length of the other notes are multiples of
28      * this number. All durations and time-stamps are calculated in these units.
29      */
30     enum NoteLength {
31         Note128Length = 1*2*3*4*5*7,
32         Note64Length = Note128Length * 2,
33         Note32Length = Note64Length * 2,
34         Note16Length = Note32Length * 2,
35         Note8Length = Note16Length * 2,
36         QuarterLength = Note8Length * 2,
37         HalfLength = QuarterLength * 2,
38         WholeLength = HalfLength * 2,
39         DoubleWholeLength = WholeLength * 2
40     };
41 
42     /**
43      * This enum represents the various supported durations for chords/rests.
44      */
45     enum Duration {
46         HundredTwentyEighthNote,
47         SixtyFourthNote,
48         ThirtySecondNote,
49         SixteenthNote,
50         EighthNote,
51         QuarterNote,
52         HalfNote,
53         WholeNote,
54         BreveNote
55     };
56 
57     enum StemDirection {
58         StemUp,
59         StemDown
60     };
61 
62     enum BeamType {
63         BeamStart,
64         BeamContinue,
65         BeamEnd,
66         BeamFlag,
67         BeamForwardHook,
68         BeamBackwardHook
69     };
70 
71 
72     /**
73      * Convert a duration to a number of ticks.
74      *
75      * @param duration the duration to convert to ticks
76      */
77     int durationToTicks(Duration duration);
78 
79     /**
80      * Concert a duration to a string representation as it is expected when written to a MusicXML file.
81      *
82      * @param duration the duration to convert to a string
83      */
84     QString durationToString(Duration duration);
85 
86 
87 } // namespace MusicCore
88 
89 #endif // MUSIC_CORE_GLOBAL_H
90