self._parseMusic()
self.verses = [[]]
self.chorus = []
- if autoDetectChorus :
- self._findChorus()
- self._findVersesLoops()
+ self.songStartsWithChorus = False
+ self._findVersesLoops(autoDetectChorus)
def _parseMusic(self) :
divisions = 0
self.quarterNoteDuration = int(round(60000/tempo))
-
- def _findChorus(self):
- """ le refrain correspond aux notes pour lesquelles
- il n'existe q'une seule syllable attachée.
- """
- start = stop = None
- for i, note in enumerate(self.notes) :
- ll = len(note.lyrics)
- if start is None and ll == 1 :
- start = i
- elif start is not None and ll > 1 :
- stop = i
- break
- if not (start or stop) :
- self.chorus = []
- else :
- self.chorus = self.notes[start:stop]
-
- def _findVersesLoops(self) :
+ def _findVersesLoops(self, autoDetectChorus) :
"recherche des couplets / boucles"
verse = self.verses[0]
for note in self.notes[:-1] :
self.verses.append(verse)
verse.append(self.notes[-1])
+ if autoDetectChorus and len(self.verses) > 1 :
+ for i, verse in enumerate(self.verses) :
+ if len(verse[0].lyrics) == 1 :
+ self.chorus = self.verses.pop(i)
+ self.songStartsWithChorus = i==0
+ break
+
def iterNotes(self, indefinitely=True) :
"exécution de la chanson avec l'alternance couplets / refrains"
else :
iterable = cycle(self.verses)
for verse in iterable :
+ if self.songStartsWithChorus :
+ for note in self.chorus :
+ yield note, 0
+
#print "---partie---"
repeats = len(verse[0].lyrics)
if repeats > 1 :