Forwarded to bug-lilypond on request.

The patch is to address the issue that musicxml2ly generates improper
code for minor chords.

Begin forwarded message:

Date: Thu, 18 Aug 2016 13:38:21 +0200
From: Johan Vromans <[email protected]>
To: David Kastrup <[email protected]>
Subject: Re: [PATCH] Eliminate accidental power chords in musicxml2ly.


Hi David,

On Thu, 18 Aug 2016 07:10:45 +0200
David Kastrup <[email protected]> wrote:

> > I'll prepare a better solution, which involves changing the way
> > ChordNameEvent (musicexp.py) handles modifications, but I'm going to
> > sleep first. Stay tuned.    
> 
> The 5 probably was a "lazy fix".  You could probably replace it by 3.5
> but, well, I think I'd prefer a less ugly solution if you can reasonably
> come up with one.  

Main reason I do not want the 3.5 workaround is that I wouldn't want my
major chords to look like c4:3.5...

Attached is a new patch. It patches scripts/musicxml2ly as before, with
r'{}' for a major chord.
The solutions for the invalid combinations are provided in
python/musicexp.py. A colon is added if a colon-less chord (i.e., major)
has modifications. Adding additions checks for a trailing digit, if none,
the leading period is omitted. Note that the changes in python/musicexp.py
are harmless to an un-patched scripts/musicxml2ly.

Also attached are chords.xml, a sheet of many chords based on the chart
from NR A.1, and chords.ly, the desired output after conversion. There are
a few discrepancies between the output from chords.ly and the chart from NR
A.1, but these occur in very weird chords so I consider these harmless.

Regards,
        Johan
>From 14f91d65ff507e21c383eedabf809e19c9932758 Mon Sep 17 00:00:00 2001
From: Johan Vromans <[email protected]>
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

Attachment: chords.xml
Description: XML document

\version "2.19.47"
% automatically converted by musicxml2ly from ../../python/out/chords.xml
\pointAndClickOff

\header {
    encodingsoftware = 
    "MuseScore 2.0.3, with manual fixes by Johan Vromans"
    encodingdate =  "2016-08-18"
    }

#(set-global-staff-size 20.1587428571)
\paper {
    
    paper-width = 21.01\cm
    paper-height = 29.69\cm
    top-margin = 1.0\cm
    bottom-margin = 2.0\cm
    left-margin = 1.0\cm
    right-margin = 1.0\cm
    indent = 1.61615384615\cm
    short-indent = 1.29292307692\cm
    }
\layout {
    \context { \Score
        autoBeaming = ##f
        }
    }
PartPOneVoiceOne =  \relative c'' {
    \clef "treble" \key c \major \numericTimeSignature\time 4/4 | % 1
    c1 | % 2
    c1 | % 3
    c1 | % 4
    c1 | % 5
    c1 | % 6
    c1 | % 7
    c1 | % 8
    c1 | % 9
    c1 \break | \barNumberCheck #10
    c1 | % 11
    c1 | % 12
    c1 | % 13
    c1 | % 14
    c1 | % 15
    c1 | % 16
    c1 | % 17
    c1 \break | % 18
    c1 | % 19
    c1 | \barNumberCheck #20
    c1 | % 21
    c1 | % 22
    c1 | % 23
    c1 | % 24
    c1 | % 25
    c1 \break | % 26
    c1 | % 27
    c1 | % 28
    c1 | % 29
    c1 | \barNumberCheck #30
    c1 | % 31
    c1 | % 32
    c1 | % 33
    c1 \break | % 34
    c1 | % 35
    c1 | % 36
    c1 | % 37
    c1 | % 38
    c1 | % 39
    c1 | \barNumberCheck #40
    c1 | % 41
    c1 \break | % 42
    c1 | % 43
    c1 | % 44
    c1 | % 45
    c1 | % 46
    c1 \bar "|."
    }

PartPOneVoiceOneChords =  \chordmode {
    | % 1
    c1 | % 2
    c1:m | % 3
    c1:aug | % 4
    c1:dim | % 5
    c1:7 | % 6
    c1:m7 | % 7
    c1:maj7 | % 8
    c1:dim7 | % 9
    c1:maj7m5- | \barNumberCheck #10
    c1:7.5+ | % 11
    c1:maj7m | % 12
    c1:maj7.5+ | % 13
    c1:m7.5- | % 14
    c1:6 | % 15
    c1:m6 | % 16
    c1:9 | % 17
    c1:m9 | % 18
    c1:m13 | % 19
    c1:m11 | \barNumberCheck #20
    c1:m7.5-9 | % 21
    c1:7.9- | % 22
    c1:7.9+ | % 23
    c1:11 | % 24
    c1:7.11+ | % 25
    c1:13.11 | % 26
    c1:7.11+13- | % 27
    c1:7.5+9+ | % 28
    c1:7.9+11+ | % 29
    c1:7.13- | \barNumberCheck #30
    c1:7.9-13- | % 31
    c1:7.11+ | % 32
    c1:maj9 | % 33
    c1:7.13- | % 34
    c1:7.9-13- | % 35
    c1:7.9-13 | % 36
    c1:maj9 | % 37
    c1:maj13.11 | % 38
    c1:maj7.11+ | % 39
    c1:7.9-13 | \barNumberCheck #40
    c1:sus4 | % 41
    c1:sus4.7 | % 42
    c1:sus4.7.9 | % 43
    c1:9 | % 44
    c1:m11 | % 45
    c1:11+ | % 46
    c1:5-5+9-9+ \bar "|."
    }


% The score definition
\score {
    <<
        
        \context ChordNames = "PartPOneVoiceOneChords" { \PartPOneVoiceOneChords}
        \new Staff
        <<
            \set Staff.instrumentName = "Piano"
            \set Staff.shortInstrumentName = "Pno."
            
            \context Staff << 
                \mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
                \context Voice = "PartPOneVoiceOne" {  \PartPOneVoiceOne }
                >>
            >>
        
        >>
    \layout {}
    % To create MIDI output, uncomment the following line:
    %  \midi {\tempo 4 = 100 }
    }

_______________________________________________
bug-lilypond mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-lilypond

Reply via email to