X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/blobdiff_plain/2afd6b2dc26dd12ecbba36d221a7cc45f19673f2..ee24fce216592a13d95977d7d4e3374692fd6924:/src/app/musicxml.py?ds=sidebyside diff --git a/src/app/musicxml.py b/src/app/musicxml.py index ab6dbf9..0ed7085 100755 --- a/src/app/musicxml.py +++ b/src/app/musicxml.py @@ -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,22 +148,21 @@ 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 : iterable = cycle(self.verses) for verse in iterable : - print "---partie---" + #print "---partie---" repeats = len(verse[0].lyrics) if repeats > 1 : for i in range(repeats) : # couplet - print "---couplet%d---" % i + #print "---couplet%d---" % i for note in verse : yield note, i # refrain - print "---refrain---" + #print "---refrain---" for note in self.chorus : yield note, 0 else : @@ -233,7 +242,7 @@ class Tone(object) : @property def name(self) : - name = '%s%d' % (self.step, self.octave) + name = u'%s%d' % (self.step, self.octave) if self.alter < 0 : alterext = 'b' else : @@ -245,10 +254,10 @@ class Tone(object) : def nom(self) : name = FR_NOTES[self.step] if self.alter < 0 : - alterext = 'b' + alterext = u'♭' else : - alterext = '#' - name = '%s%s' % (name, abs(self.alter) * alterext) + alterext = u'#' + name = u'%s%s' % (name, abs(self.alter) * alterext) return name