utilisation directe des chaînes unicode pour l'affichage des paroles.
[minwii.git] / src / songs / synth.py
index 07a8a5a..0832b90 100755 (executable)
@@ -6,7 +6,7 @@ $Id$
 $URL$
 """
 import fluidsynth
-from musicxmltosong import musicXml2Song
+from app.musicxml import musicXml2Song
 from time import sleep
 import sys
 from optparse import OptionParser
@@ -28,7 +28,10 @@ class SongPlayer(object) :
     def play(self) :
         fs = self.fs
         for note, verseIndex in self.part.iterNotes(indefinitely=False) :
-            print note, note.lyrics[verseIndex]
+            try :
+                print note, note.lyrics[verseIndex]
+            except IndexError :
+                print note, '?'
             fs.noteon(0, note.midi, 64)
             duration = note.duration * self.quarterNoteDuration / 1000
             sleep(duration)
@@ -44,13 +47,21 @@ def main() :
     op.add_option("-i", "--part-index", dest="partIndex"
                  , default = 0
                  , help = "Index de la partie qui contient le champ.")
+
+    op.add_option("-c", '--no-chorus', dest='autoDetectChorus'
+             , action="store_false"
+             , default = True
+             , help = "désactive la détection du refrain")
+
     op.add_option("-q", "--quarter-note-duration", dest="quarterNoteDuration"
                   , type="int", default=400
                   , help="Durée de la noire [default] (en millisecondes)"
                   )
+
     op.add_option("-b", "--bank", dest="bank"
                   , type="int", default="0"
                   , help="midi bank [default]")
+
     op.add_option("-p", "--preset", dest="preset"
                 , type="int", default="0"
                 , help="midi preset [default]")
@@ -60,7 +71,9 @@ def main() :
     if len(args) != 1 :
         raise SystemExit(op.format_help())
     
-    song = musicXml2Song(args[0], partIndex=options.partIndex)
+    song = musicXml2Song(args[0],
+                         partIndex=options.partIndex,
+                         autoDetectChorus=options.autoDetectChorus)
     sp = SongPlayer(song,
                     '/Users/pinbe/dev/minwii/fluid-soundfont-3.1/FluidR3_GM.sf2',
                     quarterNoteDuration=options.quarterNoteDuration,