_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 = []
def _parseMusic(self) :
divisions = 0
previous = None
+ distinctNotesDict = {}
for measureNode in self.node.getElementsByTagName('measure') :
measureNotes = []
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 :
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
self._duration = self.duration + note.duration
self.divisions = 1
-# @property
-# def midi(self) :
-# mid = DIATO_SCALE[self.step]
-# mid = mid + (self.octave - OCTAVE_REF) * 12
-# mid = mid + self.alter
-# return mid
-
@property
def duration(self) :
return self._duration / self.divisions
-# @property
-# def name(self) :
-# name = '%s%d' % (self.step, self.octave)
-# if self.alter < 0 :
-# alterext = 'b'
-# else :
-# alterext = '#'
-# name = '%s%s' % (name, abs(self.alter) * alterext)
-# return name
-#
-# @property
-# def nom(self) :
-# name = FR_NOTES[self.step]
-# if self.alter < 0 :
-# alterext = 'b'
-# else :
-# alterext = '#'
-# name = '%s%s' % (name, abs(self.alter) * alterext)
-# return name
-
@property
def column(self):
return self.scale.index(self.midi)