+# Extract the settings for tuplets from the <notations><tuplet> and the
+# <time-modification> elements of the note:
+def musicxml_tuplet_to_lily (tuplet_elt, time_modification):
+ tsm = musicexp.TimeScaledMusic ()
+ fraction = (1,1)
+ if time_modification:
+ fraction = time_modification.get_fraction ()
+ tsm.numerator = fraction[0]
+ tsm.denominator = fraction[1]
+
+
+ normal_type = tuplet_elt.get_normal_type ()
+ if not normal_type and time_modification:
+ normal_type = time_modification.get_normal_type ()
+ if not normal_type and time_modification:
+ note = time_modification.get_parent ()
+ if note:
+ normal_type = note.get_duration_info ()
+ if normal_type:
+ normal_note = musicexp.Duration ()
+ (normal_note.duration_log, normal_note.dots) = normal_type
+ tsm.normal_type = normal_note
+
+ actual_type = tuplet_elt.get_actual_type ()
+ if actual_type:
+ actual_note = musicexp.Duration ()
+ (actual_note.duration_log, actual_note.dots) = normal_type
+ tsm.actual_type = actual_note
+
+ # Obtain non-default nrs of notes from the tuplet object!
+ tsm.display_numerator = tuplet_elt.get_normal_nr ()
+ tsm.display_denominator = tuplet_elt.get_actual_nr ()
+
+
+ if hasattr (tuplet_elt, 'bracket') and tuplet_elt.bracket == "no":
+ tsm.display_bracket = None
+ elif hasattr (tuplet_elt, 'line-shape') and getattr (tuplet_elt, 'line-shape') == "curved":
+ tsm.display_bracket = "curved"
+ else:
+ tsm.display_bracket = "bracket"
+
+ display_values = {"none": None, "actual": "actual", "both": "both"}
+ if hasattr (tuplet_elt, "show-number"):
+ tsm.display_number = display_values.get (getattr (tuplet_elt, "show-number"), "actual")
+ if tsm.display_number == "actual" and tsm.display_denominator:
+ needed_additional_definitions.append ("tuplet-non-default-denominator")
+ elif tsm.display_number == "both" and (tsm.display_numerator or tsm.display_denominator):
+ needed_additional_definitions.append ("tuplet-non-default-fraction")
+
+ if hasattr (tuplet_elt, "show-type"):
+ if getattr (tuplet_elt, "show-type") == "actual":
+ needed_additional_definitions.append ("tuplet-note-wrapper")
+ tsm.display_type = display_values.get (getattr (tuplet_elt, "show-type"), None)
+
+ return tsm
+