summaryrefslogtreecommitdiff
path: root/python/musicxml.py
diff options
context:
space:
mode:
authorJohn Gourlay <john@weathervanefarm.net>2016-04-29 15:47:40 -0400
committerJohn Gourlay <john@weathervanefarm.net>2016-04-29 15:47:40 -0400
commit0398fdb9df24ac2e22a8cbff1b3c18ca04e9f221 (patch)
treeec2ba477b4140452a4184c6c7199d021d9ffe552 /python/musicxml.py
parent1ad144eca54df3c4e5f43b555c01606e0cfd82b6 (diff)
parent7d3fa8cb4799303da8e5fd2ead35f1ac32180157 (diff)
Merge branch 'master' into philomelos
Conflicts resolved in: python/musicexp.py python/musicxml.py scripts/musicxml2ly.py
Diffstat (limited to 'python/musicxml.py')
-rw-r--r--python/musicxml.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/python/musicxml.py b/python/musicxml.py
index 48aa29450d..f0b82f1333 100644
--- a/python/musicxml.py
+++ b/python/musicxml.py
@@ -124,6 +124,7 @@ class Music_xml_node(Xml_node):
self.duration = Rational(0)
self.start = Rational(0)
self.converted = False
+ self.voice_id = None;
class Music_xml_spanner(Music_xml_node):
@@ -440,6 +441,15 @@ class Unpitched(Music_xml_node):
return p
+class Measure_element (Music_xml_node):
+ def get_voice_id (self):
+ voice = self.get_maybe_exist_named_child ('voice')
+ if voice:
+ return voice.get_text ()
+ else:
+ return self.voice_id;
+
+
class Attributes(Measure_element):
def __init__(self):
@@ -1310,7 +1320,25 @@ class Part(Music_xml_node):
measure_start_moment = now
measure_position = Rational(0)
- for n in m.get_all_children():
+ voice_id = None;
+ assign_to_next_voice = []
+ for n in m.get_all_children ():
+ # assign a voice to all measure elements
+ if (n.get_name() == 'backup'):
+ voice_id = None;
+
+ if isinstance(n, Measure_element):
+ if n.get_voice_id ():
+ voice_id = n.get_voice_id ()
+ for i in assign_to_next_voice:
+ i.voice_id = voice_id
+ assign_to_next_voice = []
+ else:
+ if voice_id:
+ n.voice_id = voice_id
+ else:
+ assign_to_next_voice.append (n)
+
# figured bass has a duration, but applies to the next note
# and should not change the current measure position!
if isinstance(n, FiguredBass):
@@ -1637,6 +1665,9 @@ class Hash_comment(Music_xml_node):
class KeyAlter(Music_xml_node):
pass
+class Direction (Measure_element):
+ pass
+
class KeyOctave(Music_xml_node):
pass