From da632500cfc55fcd3660f72b39c7dbcd7542f9bc Mon Sep 17 00:00:00 2001 From: Patrick Schmidt Date: Fri, 22 Jun 2012 05:45:04 -0400 Subject: [PATCH] musicxml2ly: Fix title, chord symbol and midi bugs. Fix for several musicxml2ly bugs: Titles and headers can now contain single words followed by a punctuation mark (.,!:). See issue 1983. Chord symbols are now placed above staffs instead of below. See issue 2537. musicxml2ly now includes an out-commented midi-block in every .ly-file. Docs: Added command line options -m and --midi to Usage --- Documentation/usage/external.itely | 7 +++++-- python/musicexp.py | 17 +++++++++++------ python/musicxml.py | 2 +- scripts/musicxml2ly.py | 8 +++----- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Documentation/usage/external.itely b/Documentation/usage/external.itely index 1668953b1f..eba0be3f1b 100644 --- a/Documentation/usage/external.itely +++ b/Documentation/usage/external.itely @@ -436,7 +436,10 @@ Set the output verbosity to @var{loglevel}. Possible values are @code{NONE}, @item --lxml use the lxml.etree Python package for XML-parsing; uses less memory and cpu time. -@item --nd --no-articulation-directions +@item -m, --midi +activate midi-block. + +@item -nd --no-articulation-directions do not convert directions (@code{^}, @code{_} or @code{-}) for articulations, dynamics, etc. @@ -679,7 +682,7 @@ explicit tempo markings, and the notes and durations themselves are produced in the output. The @emph{articulate} project is one attempt to get more of the -information in the score into he MIDI. It works by shortening +information in the score into MIDI. It works by shortening notes not under slurs, to @q{articulate} the notes. The amount of shortening depends on any articulation markings attached to a note: staccato halves the note value, tenuto gives a note its full diff --git a/python/musicexp.py b/python/musicexp.py index 8610f8aa44..ea2525d866 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -1807,7 +1807,18 @@ class StaffGroup: printer.dump (m) printer.dump ("}") + def print_ly_chords (self,printer): + try: + for [staff_id, voices] in self.part_information: + for [v, lyrics, figuredbass, chordnames] in voices: + if chordnames: + printer ('\context ChordNames = "%s" \\%s' % (chordnames, chordnames)) + printer.newline () + except TypeError: + return + def print_ly (self, printer): + self.print_ly_chords (printer) if self.stafftype: printer.dump ("\\new %s" % self.stafftype) self.print_ly_overrides (printer) @@ -1848,12 +1859,6 @@ class Staff (StaffGroup): sub_staff_type = self.stafftype for [staff_id, voices] in self.part_information: - # Chord names need to come before the staff itself! - for [v, lyrics, figuredbass, chordnames] in voices: - if chordnames: - printer ('\context ChordNames = "%s" \\%s' % (chordnames, chordnames)) - - # now comes the real staff definition: if staff_id: printer ('\\context %s = "%s" << ' % (sub_staff_type, staff_id)) else: diff --git a/python/musicxml.py b/python/musicxml.py index d03d116de7..6eb3b45aba 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -12,7 +12,7 @@ _ = ly._ def escape_ly_output_string (input_string): return_string = input_string - needs_quotes = not re.match (u"^[a-zA-ZäöüÜÄÖß,\.!:ñ]*$", return_string); + needs_quotes = not re.match (u"^[a-zA-ZäöüÜÄÖßñ]*$", return_string); if needs_quotes: return_string = "\"" + string.replace (return_string, "\"", "\\\"") + "\"" return return_string diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index a898e64a71..8738b2a073 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -22,7 +22,7 @@ import musicexp from rational import Rational -# Store command-line options in a global variable, so we can access them everythwere +# Store command-line options in a global variable, so we can access them everywhere options = None class Conversion_Settings: @@ -474,8 +474,6 @@ def extract_score_structure (part_list, staffinfo): group_starts.append (pos) pos += 1 - if len (staves) == 1: - return staves[0] for i in staves: structure.append_staff (i) return score @@ -533,7 +531,7 @@ def musicxml_partial_to_lily (partial_len): p.partial = rational_to_lily_duration (partial_len) return p else: - return Null + return None # Detect repeats and alternative endings in the chord event list (music_list) # and convert them to the corresponding musicexp objects, containing nested @@ -2669,7 +2667,7 @@ information.""") % 'lilypond') action = "store_true", default = False, dest = "midi", - help = _("add midi-block to .ly file")) + help = _("activate midi-block")) p.add_option_group ('', description = ( -- 2.39.5