1
# This file is part of the Frescobaldi project, http://www.frescobaldi.org/
3
# Copyright (c) 2008, 2009, 2010 by Wilbert Berendsen
5
# This program is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU General Public License
7
# as published by the Free Software Foundation; either version 2
8
# of the License, or (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
# See http://www.gnu.org/licenses/ for more information.
20
from __future__ import unicode_literals
22
""" Basic LilyPond information and utility functions """
25
# Exceptions used by modules in this package
26
class NoMusicExpressionFound(Exception):
28
Raised if no music expression could be found in abs->rel.
33
class QuarterToneAlterationNotAvailable(Exception):
35
Raised when there is no pitch name in the target languate
36
when translating pitch names.
42
'Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight',
43
'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen',
44
'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen')
47
'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty',
52
Returns a textual representation of a number (e.g. 1 -> "One"), for use
53
in LilyPond identifiers (that do not support digits).
54
Supports numbers 0 to 109.
58
d, r = divmod(num, 10)
65
# Thanks: http://billmill.org/python_roman.html
66
_roman_numerals = (("M", 1000), ("CM", 900), ("D", 500), ("CD", 400),
67
("C", 100),("XC", 90),("L", 50),("XL", 40), ("X", 10), ("IX", 9), ("V", 5),
72
for ltr, num in _roman_numerals:
78
def headers(i18nFunc=None):
79
i18n = i18nFunc or (lambda s: s)
81
('dedication', i18n("Dedication")),
82
('title', i18n("Title")),
83
('subtitle', i18n("Subtitle")),
84
('subsubtitle', i18n("Subsubtitle")),
85
('instrument', i18n("Instrument")),
86
('composer', i18n("Composer")),
87
('arranger', i18n("Arranger")),
88
('poet', i18n("Poet")),
89
('meter', i18n("Meter")),
90
('piece', i18n("Piece")),
91
('opus', i18n("Opus")),
92
('copyright', i18n("Copyright")),
93
('tagline', i18n("Tagline")),
96
headerNames = zip(*headers())[0]
98
def modes(i18nFunc=None):
99
i18n = i18nFunc or (lambda s: s)
101
('major', i18n("Major")),
102
('minor', i18n("Minor")),
103
('ionian', i18n("Ionian")),
104
('dorian', i18n("Dorian")),
105
('phrygian', i18n("Phrygian")),
106
('lydian', i18n("Lydian")),
107
('mixolydian', i18n("Mixolydian")),
108
('aeolian', i18n("Aeolian")),
109
('locrian', i18n("Locrian")),
114
(1, -1), (1, 0), (1, 1),
117
(4, -1), (4, 0), (4, 1),
118
(5, -1), (5, 0), (5, 1),
161
'Re bemolle', 'Re', 'Re diesis',
164
'Sol bemolle', 'Sol', 'Sol diesis',
165
'La bemolle', 'La', 'La diesis',
169
'Do', 'Do sostenido',
170
'Re bemol', 'Re', 'Re sostenido',
172
'Fa', 'Fa sostenido',
173
'Sol bemol', 'Sol', 'Sol sostenido',
174
'La bemol', 'La', 'La sostenido',
179
'Re mol', 'Re', 'Re kruis',
182
'Sol mol', 'Sol', 'Sol kruis',
183
'La mol', 'La', 'La kruis',
188
keyNames['svenska'] = keyNames['norsk']
189
keyNames['suomi'] = keyNames['deutsch']
190
keyNames['catalan'] = keyNames['italiano']
191
keyNames['portugues'] = keyNames['espanol']
193
paperSizes = ['a3', 'a4', 'a5', 'a6', 'a7', 'legal', 'letter', '11x17']