X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Flilymidi.py;h=34308f07025e625ed0b0cae086ae6258cfde4edd;hb=HEAD;hp=20d13aa5082d754708d1168f89f749c7b7220d57;hpb=9b393a90c86f8fd614521d1654aee603bf1b97c0;p=lilypond.git diff --git a/scripts/lilymidi.py b/scripts/lilymidi.py index 20d13aa508..34308f0702 100644 --- a/scripts/lilymidi.py +++ b/scripts/lilymidi.py @@ -1,6 +1,6 @@ #!@TARGET_PYTHON@ -# Copyright (C) 2006--2012 Brailcom, o.p.s. +# Copyright (C) 2006--2015 Brailcom, o.p.s. # # Author: Milan Zamazal # @@ -80,11 +80,21 @@ class meta_formatter (formatter): return str (val2); class tempo_formatter (formatter): def format_vals (self, val1, val2): - return str (val2) + " msec/quarter" + return str (ord (val2[0])*65536 + ord (val2[1])*256 + ord (val2[2])) \ + + " msec/quarter" class time_signature_formatter (formatter): def format_vals (self, val1, val2 = ""): - return str (val2) # TODO + from fractions import Fraction + # if there are more notated 32nd notes per midi quarter than 8, + # we display a fraction smaller than 1 as scale factor. + r = Fraction(8, ord (val2[3])) + if r == 1: + ratio ="" + else: + ratio = " *" + str (r) + return str (ord (val2[0])) + "/" + str(1 << ord (val2[1])) + ratio \ + + ", metronome " + str (Fraction (ord (val2[2]), 96)) class key_signature_formatter (formatter): def format_vals (self, val1, val2): key_names = ['F', 'C', 'G', 'D', 'A', 'E', 'B']