#!@TARGET_PYTHON@
# -*- coding: utf-8 -*-
+
# once upon a rainy monday afternoon.
+
+# This file is part of LilyPond, the GNU music typesetter.
+#
+# LilyPond is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# LilyPond 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 LilyPond. If not, see <http://www.gnu.org/licenses/>.
+
#
# ...
#
outf.write ("\n}")
def try_parse_q(a):
- global midi_specs
- #assume that Q takes the form "Q:1/4=120"
+ #assume that Q takes the form "Q:'opt. description' 1/4=120"
#There are other possibilities, but they are deprecated
- if a.count ('/') == 1:
- array = a.split('/')
- numerator=array[0]
- if int(numerator) != 1:
- sys.stderr.write("abc2ly: Warning, unable to translate a Q specification with a numerator of %s: %s\n" % (numerator, a))
- array2 = array[1].split ('=')
- denominator=array2[0]
- perminute=array2[1]
- duration = str (int (denominator) / int (numerator))
- midi_specs = ' '.join(["\n\t\t\\context {\n\t\t \\Score tempoWholesPerMinute = #(ly:make-moment ", perminute, " ", duration, ")\n\t\t }\n"])
+ r = re.compile ('^(.*) *([0-9]+) */ *([0-9]+) *=* *([0-9]+)\s*')
+ m = r.match (a)
+ if m:
+ descr = m.group(1) # possibly empty
+ numerator = int(m.group (2))
+ denominator = int(m.group (3))
+ tempo = m.group (4)
+ dur = duration_to_lilypond_duration ((numerator,denominator), 1, 0)
+ voices_append ("\\tempo " + descr + " " + dur + "=" + tempo + "\n")
else:
sys.stderr.write("abc2ly: Warning, unable to parse Q specification: %s\n" % a)