X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fabc2ly.py;h=02ff95ba9341aae986daef18528595cf0b36b382;hb=dcd2b0fb2c89f797d034252e50fcaa7dbe0c4ea5;hp=f844b7dc13e2b84ab468d7718b1f418ff9a0844c;hpb=f6045462422a7f4acb13bfd495473f0d531ac89d;p=lilypond.git diff --git a/scripts/abc2ly.py b/scripts/abc2ly.py index f844b7dc13..02ff95ba93 100644 --- a/scripts/abc2ly.py +++ b/scripts/abc2ly.py @@ -1,6 +1,23 @@ #!@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 . + # # ... # @@ -255,19 +272,17 @@ def dump_voices (outf): 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)