X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=python%2Fmusicexp.py;h=862b5d8c4f70f5148c0a5b1899588b1859014c59;hb=73abdfa52f0403da92b84e248dc7454e63215005;hp=b266830d0726bd32e43b884e5ae1e6e2f795836a;hpb=a491d4e27ce2eae4cd4a3df8bd2c0dcf969a1c56;p=lilypond.git diff --git a/python/musicexp.py b/python/musicexp.py index b266830d07..862b5d8c4f 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -2,9 +2,9 @@ import inspect import sys import string import re -import lilylib +import lilylib as ly -_ = lilylib._ +_ = ly._ from rational import Rational @@ -155,8 +155,12 @@ class Duration: def ly_expression (self, factor = None): if not factor: factor = self.factor - - str = '%d%s' % (1 << self.duration_log, '.'*self.dots) + + if self.duration_log < 0: + str = {-1: "\\breve", -2: "\\longa"}.get (self.duration_log, "1") + else: + str = '%d' % (1 << self.duration_log) + str += '.'*self.dots if factor <> Rational (1,1): if factor.denominator () <> 1: @@ -669,6 +673,31 @@ class Paper: printer.dump ('}') printer.newline () +class Layout: + def __init__ (self): + self.context_dict = {} + def add_context (self, context): + if not self.context_dict.has_key (context): + self.context_dict[context] = [] + def set_context_item (self, context, item): + self.add_context (context) + if not item in self.context_dict[context]: + self.context_dict[context].append (item) + def print_ly (self, printer): + if self.context_dict.items (): + printer.dump ('\\layout {') + printer.newline () + for (context, defs) in self.context_dict.items (): + printer.dump ('\\context { \\%s' % context) + printer.newline () + for d in defs: + printer.dump (d) + printer.newline () + printer.dump ('}') + printer.newline () + printer.dump ('}') + printer.newline () + class ChordEvent (NestedMusic): def __init__ (self): @@ -835,7 +864,6 @@ class BracketSpannerEvent (SpanEvent): 1:'\\stopGroup'}.get (self.span_direction, '') -# type==-1 means octave up, type==-2 means octave down class OctaveShiftEvent (SpanEvent): def wait_for_note (self): return False