+
+ @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
+
+
+
+class Note(Tone) :
+ scale = [55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72]
+
+ def __init__(self, node, divisions, previous) :
+ self.node = node
+ self.isRest = False
+ self.step = _getNodeValue(node, 'pitch/step', None)
+ if self.step is not None :
+ self.octave = int(_getNodeValue(node, 'pitch/octave'))
+ self.alter = int(_getNodeValue(node, 'pitch/alter', 0))
+ elif self.node.getElementsByTagName('rest') :
+ self.isRest = True
+ else :
+ NotImplementedError(self.node.toxml('utf-8'))
+
+ self._duration = float(_getNodeValue(node, 'duration'))
+ self.lyrics = []
+ for ly in node.getElementsByTagName('lyric') :
+ self.lyrics.append(Lyric(ly))
+
+ self.divisions = divisions
+ self.previous = previous
+ self.next = None
+
+ def __str__(self) :
+ return (u'%5s %2s %2d %4s' % (self.nom, self.name, self.midi, round(self.duration, 2))).encode('utf-8')
+
+ def __repr__(self) :
+ return self.name.encode('utf-8')
+
+ def addDuration(self, note) :
+ 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)
+
+
+class Lyric(object) :
+
+ _syllabicModifiers = {
+ 'single' : '%s',
+ 'begin' : '%s -',
+ 'middle' : '- %s -',
+ 'end' : '- %s'
+ }
+
+ def __init__(self, node) :
+ self.node = node
+ self.syllabic = _getNodeValue(node, 'syllabic', 'single')
+ self.text = _getNodeValue(node, 'text')
+
+ def syllabus(self, encoding='utf-8'):
+ text = self._syllabicModifiers[self.syllabic] % self.text
+ return text.encode(encoding)
+
+ def __str__(self) :
+ return self.syllabus()
+ __repr__ = __str__