From 55fc862ddb0c20e92bbd88621f92525131b5b215 Mon Sep 17 00:00:00 2001 From: pin Date: Mon, 8 Mar 2010 09:38:50 +0000 Subject: [PATCH] =?utf8?q?impl=C3=A9mentation=20de=20l'attribut=20distinct?= =?utf8?q?Notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@71 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/app/musicxml.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/musicxml.py b/src/app/musicxml.py index 7eedf53..36a65bc 100755 --- a/src/app/musicxml.py +++ b/src/app/musicxml.py @@ -47,15 +47,12 @@ FR_NOTES = {'C' : u'Do', _marker = [] class Part(object) : - - requiresExtendedScale = False - scale = [55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72] - quarterNoteLength = 400 - + def __init__(self, node, autoDetectChorus=True) : self.node = node self.notes = [] self.repeats = [] + self.distinctNotes = [] self._parseMusic() self.verses = [[]] self.chorus = [] @@ -66,6 +63,7 @@ class Part(object) : def _parseMusic(self) : divisions = 0 previous = None + distinctNotesDict = {} for measureNode in self.node.getElementsByTagName('measure') : measureNotes = [] @@ -83,7 +81,13 @@ class Part(object) : previous.addDuration(note) continue previous = note + self.notes.extend(measureNotes) + + for note in measureNotes : + if not distinctNotesDict.has_key(note.midi) : + distinctNotesDict[note.midi] = True + self.distinctNotes.append(note) # barres de reprises try : @@ -94,6 +98,9 @@ class Part(object) : barline = Barline(barlineNode, measureNotes) if barline.repeat : self.repeats.append(barline) + + self.distinctNotes.sort(lambda a, b : cmp(a.midi, b.midi)) + def _findChorus(self): """ le refrain correspond aux notes pour lesquelles -- 2.20.1