>From 14f91d65ff507e21c383eedabf809e19c9932758 Mon Sep 17 00:00:00 2001 From: Johan Vromans Date: Wed, 17 Aug 2016 20:51:09 +0200 Subject: [PATCH] Eliminate accidental power chords in musicxml2ly. --- python/musicexp.py | 11 ++++++++++- scripts/musicxml2ly.py | 12 ++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/python/musicexp.py b/python/musicexp.py index e8cbcb0..cee7705 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -1597,10 +1597,19 @@ class ChordNameEvent (Event): value += self.duration.ly_expression () if self.kind: value = self.kind.format(value) + # If there are modifications, we need a ":". This will not be + # the case for plain major chords. + if self.modifications and not ":" in value: + value += ":" # First print all additions/changes, and only afterwards all subtractions for m in self.modifications: if m.type == 1: - value += m.ly_expression () + # Additions start with ".", but that requires a trailing + # digit. If none, omit the ".". + if re.search(r'\d$', value): + value += m.ly_expression () + else: + value += m.ly_expression () [1:] for m in self.modifications: if m.type == -1: value += m.ly_expression () diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 766214b..f2874fe 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -1601,10 +1601,10 @@ def musicxml_chordpitch_to_lily(mxl_cpitch): return r chordkind_dict = { - 'major': r'{}:5', - 'minor': r'{}:m5', - 'augmented': r'{}:aug5', - 'diminished': r'{}:dim5', + 'major': r'{}', + 'minor': r'{}:m', + 'augmented': r'{}:aug', + 'diminished': r'{}:dim', # Sevenths: 'dominant': r'{}:7', 'dominant-seventh': r'{}:7', @@ -1612,8 +1612,8 @@ chordkind_dict = { 'minor-seventh': r'{}:m7', 'diminished-seventh': r'{}:dim7', 'augmented-seventh': r'{}:aug7', - 'half-diminished': r'{}:dim5m7', - 'major-minor': r'{}:maj7m5', + 'half-diminished': r'{}:m7.5-', + 'major-minor': r'{}:maj7m', # Sixths: 'major-sixth': r'{}:6', 'minor-sixth': r'{}:m6', -- 2.5.5