+ return res
+
+
+def musicxml_chordpitch_to_lily (mxl_cpitch):
+ r = musicexp.ChordPitch ()
+ r.alteration = mxl_cpitch.get_alteration ()
+ r.step = musicxml_step_to_lily (mxl_cpitch.get_step ())
+ return r
+
+chordkind_dict = {
+ 'major': '5',
+ 'minor': 'm5',
+ 'augmented': 'aug5',
+ 'diminished': 'dim5',
+ # Sevenths:
+ 'dominant': '7',
+ 'major-seventh': 'maj7',
+ 'minor-seventh': 'm7',
+ 'diminished-seventh': 'dim7',
+ 'augmented-seventh': 'aug7',
+ 'half-diminished': 'dim5m7',
+ 'major-minor': 'maj7m5',
+ # Sixths:
+ 'major-sixth': '6',
+ 'minor-sixth': 'm6',
+ # Ninths:
+ 'dominant-ninth': '9',
+ 'major-ninth': 'maj9',
+ 'minor-ninth': 'm9',
+ # 11ths (usually as the basis for alteration):
+ 'dominant-11th': '11',
+ 'major-11th': 'maj11',
+ 'minor-11th': 'm11',
+ # 13ths (usually as the basis for alteration):
+ 'dominant-13th': '13.11',
+ 'major-13th': 'maj13.11',
+ 'minor-13th': 'm13',
+ # Suspended:
+ 'suspended-second': 'sus2',
+ 'suspended-fourth': 'sus4',
+ # Functional sixths:
+ # TODO
+ #'Neapolitan': '???',
+ #'Italian': '???',
+ #'French': '???',
+ #'German': '???',
+ # Other:
+ #'pedal': '???',(pedal-point bass)
+ 'power': '5^3',
+ #'Tristan': '???',
+ 'other': '1',
+ 'none': None,
+}
+
+def musicxml_chordkind_to_lily (kind):
+ res = chordkind_dict.get (kind, None)
+ # Check for None, since a major chord is converted to ''
+ if res == None:
+ error_message (_ ("Unable to convert chord type %s to lilypond.") % kind)
+ return res
+
+def musicxml_harmony_to_lily_chordname (n):
+ res = []
+ root = n.get_maybe_exist_named_child ('root')
+ if root:
+ ev = musicexp.ChordNameEvent ()
+ ev.root = musicxml_chordpitch_to_lily (root)
+ kind = n.get_maybe_exist_named_child ('kind')
+ if kind:
+ ev.kind = musicxml_chordkind_to_lily (kind.get_text ())
+ if not ev.kind:
+ return res
+ bass = n.get_maybe_exist_named_child ('bass')
+ if bass:
+ ev.bass = musicxml_chordpitch_to_lily (bass)
+ inversion = n.get_maybe_exist_named_child ('inversion')
+ if inversion:
+ # TODO: Lilypond does not support inversions, does it?
+
+ # Mail from Carl Sorensen on lilypond-devel, June 11, 2008:
+ # 4. LilyPond supports the first inversion in the form of added
+ # bass notes. So the first inversion of C major would be c:/g.
+ # To get the second inversion of C major, you would need to do
+ # e:6-3-^5 or e:m6-^5. However, both of these techniques
+ # require you to know the chord and calculate either the fifth
+ # pitch (for the first inversion) or the third pitch (for the
+ # second inversion) so they may not be helpful for musicxml2ly.
+ inversion_count = string.atoi (inversion.get_text ())
+ if inversion_count == 1:
+ # TODO: Calculate the bass note for the inversion...
+ pass
+ pass
+ for deg in n.get_named_children ('degree'):
+ d = musicexp.ChordModification ()
+ d.type = deg.get_type ()
+ d.step = deg.get_value ()
+ d.alteration = deg.get_alter ()
+ ev.add_modification (d)
+ #TODO: convert the user-symbols attribute:
+ #major: a triangle, like Unicode 25B3
+ #minor: -, like Unicode 002D
+ #augmented: +, like Unicode 002B
+ #diminished: (degree), like Unicode 00B0
+ #half-diminished: (o with slash), like Unicode 00F8
+ if ev and ev.root:
+ res.append (ev)