From e18d10cda43e9c2d477a4ac224c1f07980b0efff Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Mon, 22 Feb 2010 13:53:00 +0100 Subject: [PATCH] MusicXML: overriding part-name by part-name-display in score-part definition --- .../musicxml/41i-PartNameDisplay-Override.xml | 88 +++++++++++++++++++ scripts/musicxml2ly.py | 23 ++++- 2 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 input/regression/musicxml/41i-PartNameDisplay-Override.xml diff --git a/input/regression/musicxml/41i-PartNameDisplay-Override.xml b/input/regression/musicxml/41i-PartNameDisplay-Override.xml new file mode 100644 index 0000000000..bcc8963030 --- /dev/null +++ b/input/regression/musicxml/41i-PartNameDisplay-Override.xml @@ -0,0 +1,88 @@ + + + + + + MusicXML allows part-name and + part-name-display in the score-part element. If part-name-display + is given, it overrides the part-name for display. + + The first staff uses only part-name, while the second one (same + part-name) overrides it with a custom text. Similar for the + part-abbreviation used in subsequent staves. + + + + + + Part name + abbrv. + + + Part name + Overridden Part Name + abbrv. + Overr.abbrv. + + + + + + + 1 + + + + C + 4 + + 4 + 1 + whole + + + + + + + C + 4 + + 4 + 1 + whole + + + + + + + + 1 + + + + C + 4 + + 4 + 1 + whole + + + + + + + C + 4 + + 4 + 1 + whole + + + + + diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 8649094fa7..e89c94811e 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -439,9 +439,20 @@ def extract_score_structure (part_list, staffinfo): # Finale gives unnamed parts the name "MusicXML Part" automatically! if partname and partname.get_text() != "MusicXML Part": staff.instrument_name = partname.get_text () - if el.get_maybe_exist_named_child ('part-abbreviation'): - staff.short_instrument_name = el.get_maybe_exist_named_child ('part-abbreviation').get_text () + # part-name-display overrides part-name! + partname = el.get_maybe_exist_named_child ("part-name-display") + if partname: + staff.instrument_name = extract_display_text (partname) + + partdisplay = el.get_maybe_exist_named_child ('part-abbreviation') + if partdisplay: + staff.short_instrument_name = partdisplay.get_text () + # part-abbreviation-display overrides part-abbreviation! + partdisplay = el.get_maybe_exist_named_child ("part-abbreviation-display") + if partdisplay: + staff.short_instrument_name = extract_display_text (partdisplay) # TODO: Read in the MIDI device / instrument + return staff def read_score_group (el): @@ -933,6 +944,14 @@ def musicxml_attributes_to_lily (attrs): return elts +def extract_display_text (el): + child = el.get_maybe_exist_named_child ("display-text") + if child: + return child.get_text () + else: + return False + + def musicxml_print_to_lily (el): # TODO: Implement other print attributes #