prise en charge des indications de tempo des fichiers musicxml. Si absent, le tempo...
[minwii.git] / src / app / musicxml.py
index ab6dbf9..9302118 100755 (executable)
@@ -53,6 +53,7 @@ class Part(object) :
         self.notes = []
         self.repeats = []
         self.distinctNotes = []
+        self.quarterNoteDuration = 500
         self._parseMusic()
         self.verses = [[]]
         self.chorus = []
@@ -104,6 +105,15 @@ class Part(object) :
                 self.repeats.append(barline)
         
         self.distinctNotes.sort(lambda a, b : cmp(a.midi, b.midi))
+        sounds = self.node.getElementsByTagName('sound')
+        tempo = 120
+        for sound in sounds :
+            if sound.hasAttribute('tempo') :
+                tempo = float(sound.getAttribute('tempo'))
+                break
+        
+        self.quarterNoteDuration = int(round(60000/tempo))
+        
         
 
     def _findChorus(self):
@@ -138,7 +148,6 @@ class Part(object) :
     
     def iterNotes(self, indefinitely=True) :
         "exécution de la chanson avec l'alternance couplets / refrains"
-        print 'indefinitely', indefinitely
         if indefinitely == False :
             iterable = self.verses
         else :