From: David Kastrup Date: Mon, 16 Sep 2013 15:58:26 +0000 (+0200) Subject: Issue 3558: lilymidi: format time signature and tempo better. X-Git-Tag: release/2.17.27-1~20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1cfb0ec2e4de3cf9cc33d92bc95f56319210e1fe;p=lilypond.git Issue 3558: lilymidi: format time signature and tempo better. If the Midi references are to be believed, our time signature's specification of the metronome click could bear improvement. --- diff --git a/scripts/lilymidi.py b/scripts/lilymidi.py index 20d13aa508..498682ef26 100644 --- a/scripts/lilymidi.py +++ b/scripts/lilymidi.py @@ -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']