--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.1 Partwise//EN"\r
+ "http://www.musicxml.org/dtds/partwise.dtd">\r
+<score-partwise version="1.1">\r
+ <movement-title>Multi-bar formatting (different time signatures)</movement-title>\r
+ <identification>\r
+ <creator type="composer">Reinhold Kainhofer</creator>\r
+ <rights>Public Domain</rights>\r
+ <encoding>\r
+ <software>Finale 2008 for Windows</software>\r
+ <software>Dolet Light for Finale 2008</software>\r
+ <encoding-date>2008-11-11</encoding-date>\r
+ </encoding>\r
+ </identification>\r
+ <part-list>\r
+ <score-part id="P1">\r
+ <part-name print-object="no">MusicXML Part</part-name>\r
+ <score-instrument id="P1-I1">\r
+ <instrument-name>Acoustic Grand Piano</instrument-name>\r
+ </score-instrument>\r
+ <midi-instrument id="P1-I1">\r
+ <midi-channel>1</midi-channel>\r
+ <midi-program>1</midi-program>\r
+ </midi-instrument>\r
+ </score-part>\r
+ </part-list>\r
+ <!--=========================================================-->\r
+ <part id="P1">\r
+ <measure number="1">\r
+ <attributes>\r
+ <divisions>1</divisions>\r
+ <key>\r
+ <fifths>0</fifths>\r
+ <mode>major</mode>\r
+ </key>\r
+ <time symbol="common">\r
+ <beats>4</beats>\r
+ <beat-type>4</beat-type>\r
+ </time>\r
+ <clef>\r
+ <sign>G</sign>\r
+ <line>2</line>\r
+ </clef>\r
+ <measure-style>\r
+ <multiple-rest>2</multiple-rest>\r
+ </measure-style>\r
+ </attributes>\r
+ <note>\r
+ <rest/>\r
+ <duration>4</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="2">\r
+ <note>\r
+ <rest/>\r
+ <duration>4</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="3">\r
+ <attributes>\r
+ <time>\r
+ <beats>3</beats>\r
+ <beat-type>4</beat-type>\r
+ </time>\r
+ <measure-style>\r
+ <multiple-rest>3</multiple-rest>\r
+ </measure-style>\r
+ </attributes>\r
+ <note>\r
+ <rest/>\r
+ <duration>3</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="4">\r
+ <note>\r
+ <rest/>\r
+ <duration>3</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="5">\r
+ <note>\r
+ <rest/>\r
+ <duration>3</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="6">\r
+ <attributes>\r
+ <time>\r
+ <beats>2</beats>\r
+ <beat-type>4</beat-type>\r
+ </time>\r
+ <measure-style>\r
+ <multiple-rest>2</multiple-rest>\r
+ </measure-style>\r
+ </attributes>\r
+ <note>\r
+ <rest/>\r
+ <duration>2</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="7">\r
+ <note>\r
+ <rest/>\r
+ <duration>2</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="8">\r
+ <attributes>\r
+ <time symbol="common">\r
+ <beats>4</beats>\r
+ <beat-type>4</beat-type>\r
+ </time>\r
+ <measure-style>\r
+ <multiple-rest>2</multiple-rest>\r
+ </measure-style>\r
+ </attributes>\r
+ <note>\r
+ <rest/>\r
+ <duration>4</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="9">\r
+ <note>\r
+ <rest/>\r
+ <duration>4</duration>\r
+ <voice>1</voice>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="10">\r
+ <note>\r
+ <pitch>\r
+ <step>C</step>\r
+ <octave>5</octave>\r
+ </pitch>\r
+ <duration>4</duration>\r
+ <voice>1</voice>\r
+ <type>whole</type>\r
+ </note>\r
+ <barline location="right">\r
+ <bar-style>light-heavy</bar-style>\r
+ </barline>\r
+ </measure>\r
+ </part>\r
+ <!--=========================================================-->\r
+</score-partwise>\r
self.pending_multibar = Rational (0)
self.ignore_skips = False
self.has_relevant_elements = False
+ self.measure_length = (4, 4)
def _insert_multibar (self):
r = musicexp.MultiMeasureRest ()
- r.duration = musicexp.Duration()
- r.duration.duration_log = 0
- r.duration.factor = self.pending_multibar
+ lenfrac = Rational (self.measure_length[0], self.measure_length[1])
+ r.duration = rational_to_lily_duration (lenfrac)
+ r.duration.factor *= self.pending_multibar / lenfrac
self.elements.append (r)
self.begin_moment = self.end_moment
self.end_moment = self.begin_moment + self.pending_multibar
self.pending_multibar = Rational (0)
-
+
+ def set_measure_length (self, mlen):
+ if (mlen != self.measure_length) and self.pending_multibar:
+ self._insert_multibar ()
+ self.measure_length = mlen
+
def add_multibar_rest (self, duration):
self.pending_multibar += duration
else:
return None
+def measure_length_from_attributes (attr, current_measure_length):
+ mxl = attr.get_named_attribute ('time')
+ if mxl:
+ return attr.get_time_signature ()
+ else:
+ return current_measure_length
+
def musicxml_voice_to_lily_voice (voice):
tuplet_events = []
modes_found = {}
voice_builder = LilyPondVoiceBuilder ()
figured_bass_builder = LilyPondVoiceBuilder ()
chordnames_builder = LilyPondVoiceBuilder ()
+ current_measure_length = (4, 4)
+ voice_builder.set_measure_length (current_measure_length)
for n in voice._elements:
if n.get_name () == 'forward':
for a in musicxml_attributes_to_lily (n):
voice_builder.add_command (a)
+ measure_length = measure_length_from_attributes (n, current_measure_length)
+ if current_measure_length != measure_length:
+ current_measure_length = measure_length
+ voice_builder.set_measure_length (current_measure_length)
continue
if isinstance (n, musicxml.Barline):