X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fmusicxml_generate_timesignatures.py;h=c4cc78a103f951e4c8a0791acbf0ed0aac6f14c7;hb=bb0d59f189f8bf99a7ee3e3a147d9d52081812f5;hp=9844f3d0f68346b43563136a38f3e86839bf026f;hpb=914d9b5ee4988b86e6bc143677897173f8d7c75e;p=lilypond.git diff --git a/buildscripts/musicxml_generate_timesignatures.py b/buildscripts/musicxml_generate_timesignatures.py old mode 100755 new mode 100644 index 9844f3d0f6..c4cc78a103 --- a/buildscripts/musicxml_generate_timesignatures.py +++ b/buildscripts/musicxml_generate_timesignatures.py @@ -3,35 +3,76 @@ notes = "CDEFGAB" alterations = [-1, 0, 1] -def print_measure (nr, beats, type, params = "", attr = "", barline = ""): +dot_xml = """ +""" +tie_xml = """ +""" +tie_notation_xml = """ +""" + + +def generate_note (duration, end_tie = False): + if duration < 2: + (notetype, dur) = ("8th", 1) + elif duration < 4: + (notetype, dur) = ("quarter", 2) + elif duration < 8: + (notetype, dur) = ("half", 4) + else: + (notetype, dur) = ("whole", 8) + dur_processed = dur + dot = "" + if (duration - dur_processed >= dur/2): + dot = dot_xml + dur_processed += dur/2 + if (duration - dur_processed >= max(dur/4, 1)): + dot += dot_xml + dur_processed += dur/4 + tie = "" + tie_notation = "" + if end_tie: + tie += tie_xml % "stop" + tie_notation += tie_notation_xml % "stop" + second_note = None + if duration - dur_processed > 0: + second_note = generate_note (duration-dur_processed, True) + tie += tie_xml % "start" + tie_notation += tie_notation_xml % "start" + note = """ + + C + 5 + + %s +%s 1 + %s +%s%s """ % (dur_processed, tie, notetype, dot, tie_notation) + if second_note: + return "%s\n%s" % (note, second_note) + else: + return note + +def print_measure (nr, beats, type, params = "", attr = "", attr2 = "", barline = ""): + duration = 8*beats/type + note = generate_note (duration) + print """ -%s - - - - C - 5 - - 1 - 1 - quarter - -%s """ % (nr, attr, params, beats, type, barline) +%s +%s +%s """ % (nr, attr, params, beats, type, attr2, note, barline) -first_atts = """ 1 +first_key = """ 2 0 major - - +""" +first_clef = """ G 2 @@ -46,19 +87,24 @@ print """ - Different time signatures + + + Various time signatures: 2/2 + (alla breve), 4/4 (C), 2/2, 3/2, 2/4, 3/4, 4/4, 5/4, 3/8, 6/8, + 12/8 + + MusicXML Part - -""" + """ measure = 1 -print_measure (measure, 2, 2, " symbol=\"common\"", first_atts) +print_measure (measure, 2, 2, " symbol=\"common\"", first_key, first_clef) measure += 1 print_measure (measure, 4, 4, " symbol=\"common\"") @@ -88,9 +134,8 @@ measure += 1 print_measure (measure, 6, 8) measure += 1 -print_measure (measure, 12, 8, "", "", final_barline) +print_measure (measure, 12, 8, "", "", "", final_barline) measure += 1 print """ - -""" \ No newline at end of file +"""