ayé, on joue du musicxml :-)
authorpin <pin@fe552daf-6dbe-4428-90eb-1537e0879342>
Mon, 8 Feb 2010 11:26:53 +0000 (11:26 +0000)
committerpin <pin@fe552daf-6dbe-4428-90eb-1537e0879342>
Mon, 8 Feb 2010 11:26:53 +0000 (11:26 +0000)
git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@13 fe552daf-6dbe-4428-90eb-1537e0879342

12 files changed:
src/dataTools/__init__.pyc
src/dataTools/odict.pyc
src/gui/PGUConfiguration.py
src/gui/SongPlayingScreen.py
src/mxmMidi/DataTypeConverters.pyc
src/mxmMidi/EventDispatcher.pyc
src/mxmMidi/MidiFileParser.pyc
src/mxmMidi/MidiInFile.pyc
src/mxmMidi/MidiOutStream.pyc
src/mxmMidi/RawInstreamFile.pyc
src/mxmMidi/constants.pyc
src/songs/musicxmltosong.py

index 759cc27..8d2ef12 100644 (file)
Binary files a/src/dataTools/__init__.pyc and b/src/dataTools/__init__.pyc differ
index b9e213b..1d56861 100644 (file)
Binary files a/src/dataTools/odict.pyc and b/src/dataTools/odict.pyc differ
index 214a347..5e9f7e7 100644 (file)
@@ -246,7 +246,7 @@ class PGUConfiguration(pguGui.Desktop):
                 self.easyMode = False\r
                 \r
             choice = InstrumentChoice(instruments, wiimotes, self.window, screen, clock, joys, portOffset,self.activeWiimotes, scaleFactor = songScaleFactor)\r
                 self.easyMode = False\r
                 \r
             choice = InstrumentChoice(instruments, wiimotes, self.window, screen, clock, joys, portOffset,self.activeWiimotes, scaleFactor = songScaleFactor)\r
-            play = SongPlayingScreen(choice, self.song,self.cascade, self.extendedScale,self.easyMode,self.alwaysDown)\r
+            play = SongPlayingScreen(choice, self)# self.song,self.cascade, self.extendedScale,self.easyMode,self.alwaysDown)\r
         \r
         else:\r
             \r
         \r
         else:\r
             \r
@@ -264,7 +264,7 @@ class PGUConfiguration(pguGui.Desktop):
                 self.cascade = True\r
                 \r
             choice = InstrumentChoice(instruments, wiimotes, self.window, screen, clock, joys, portOffset,self.activeWiimotes)\r
                 self.cascade = True\r
                 \r
             choice = InstrumentChoice(instruments, wiimotes, self.window, screen, clock, joys, portOffset,self.activeWiimotes)\r
-            play = PlayingScreen(choice, None,self.cascade, self.extendedScale)            \r
+            play = PlayingScreen(choice, self)#None,self.cascade, self.extendedScale)            \r
                 \r
         while play.backToInstrumentChoice == True :\r
             \r
                 \r
         while play.backToInstrumentChoice == True :\r
             \r
index a06e831..5ddd67a 100644 (file)
@@ -10,6 +10,8 @@ import colorsys
 import constants\r
 from gradients import gradients\r
 from logging.PickleableEvent import PickleableEvent\r
 import constants\r
 from gradients import gradients\r
 from logging.PickleableEvent import PickleableEvent\r
+from songs.Song import Song\r
+from songs.musicxmltosong import Part\r
 \r
 \r
 class SongPlayingScreen:\r
 \r
 \r
 class SongPlayingScreen:\r
@@ -44,160 +46,323 @@ class SongPlayingScreen:
     \r
     \r
     \r
     \r
     \r
     \r
-    def __init__(self, instrumentChoice, song, cascade=False, extendedScale=False, easyMode = False, alwaysDown = False, eventLog = None, replay = None, defaultInstrumentChannel = 16, defaultNote = 60):\r
+    def __init__(self, instrumentChoice, pguconf):# song, cascade=False, extendedScale=False, easyMode = False, alwaysDown = False, eventLog = None, replay = None, defaultInstrumentChannel = 16, defaultNote = 60):\r
         '''\r
         Constructor\r
         '''\r
         Constructor\r
-        '''        \r
-        self.songDurations = []\r
-        self.totalDuration = None\r
-        self.clicks = [0]\r
-        self.clicksIn = [0]\r
-        self.clicksPerMinute = [0]\r
-        self.clicksInPerMinute = [0]\r
-        self.meanTimeBetweenNotes = []\r
-        self.firstClick = None\r
-        self.firstClickIn = None\r
-        \r
-        self.blinkLength = 200\r
-        self.minimalVelocity = 90\r
-        self.shortScaleSize = 8\r
-        self.longScaleSize = 11\r
-        if not extendedScale:\r
-            self.offset = self.longScaleSize - self.shortScaleSize\r
-        else:\r
-            self.offset = 0\r
-        self.borderSize = 5\r
-        self.highlightedNote = 0\r
-        self.highlightedNoteNumber = 0\r
-        self.syllabus = None\r
-        self.savedHighlightedNote = 0\r
-        self.alwaysDown = alwaysDown\r
-        self.nextLevel = None\r
-        \r
-        self.wiimotes = instrumentChoice.wiimotes\r
-        self.activeWiimotes = instrumentChoice.activeWiimotes\r
-        self.window = instrumentChoice.window\r
-        self.screen = instrumentChoice.screen\r
-        self.blitOrigin = instrumentChoice.blitOrigin\r
-        self.clock = instrumentChoice.clock\r
-        self.width = instrumentChoice.width\r
-        self.height = instrumentChoice.height\r
-        self.cursorPositions = instrumentChoice.cursorPositions\r
-        self.savedScreen = instrumentChoice.savedScreen\r
-        self.playerScreen = instrumentChoice.playerScreen\r
-        self.extendedScale = extendedScale\r
-        self.cascade = cascade\r
-        self.joys = instrumentChoice.joys\r
-        self.portOffset = instrumentChoice.portOffset\r
-        if eventLog == None :\r
-            self.eventLog = instrumentChoice.eventLog\r
-        else :\r
-            self.eventLog = eventLog\r
-        self.cursorPositions = instrumentChoice.cursorPositions\r
-        self.song = song\r
-        self.songIterator = self.song.getSongIterator()\r
-        self.midiNoteNumbers = self.song.scale\r
-        if replay == None :\r
-            self.replay = instrumentChoice.replay\r
-        else :\r
-            self.replay = replay\r
-        self.quarterNoteLength = song.quarterNoteLength\r
-        self.cascadeLockLengthMultiplier = 1\r
-        self.nextCascadeLockLengthMultiplier = 1\r
-        self.cascadeLockLength = self.quarterNoteLength * self.cascadeLockLengthMultiplier\r
-        \r
-        self.defaultInstrumentChannel = defaultInstrumentChannel\r
-        self.defaultNote = defaultNote\r
-        \r
-        self.done = False\r
-        self.backToInstrumentChoice = False\r
-        self.easyMode = easyMode\r
-        \r
-        #Initializes the highlightedNote and highlightedNoteNumber etc...\r
-        self.moveToNextNote()\r
-        self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier\r
-        \r
-        self.blinkOn = False\r
-        self.savedBlinkOn = False\r
-        ##Will prevent the song to move on if two consecutive notes are identical and the buttons have not been released in between the two\r
-        ##i.e. it guarantees that there will be an attack between two identical consecutive notes\r
-        self.highlightIsFree = True\r
-        \r
-        self.noteRects = []\r
-        self.boundingRect = None\r
-        self.notes = []\r
-        \r
-        self.buttonDown = []\r
-        self.velocityLock = []\r
-        \r
-        self._blinkOffset = 0\r
-        self._cascadeLockTimer = 0\r
-        self.cascadeIsFree = True\r
-        \r
-        self.font = pygame.font.Font(None,80)\r
-        self.renderedNoteNames = [self.font.render(constants.noteNumberToName(note),False,(0,0,0)) for note in self.midiNoteNumbers]\r
-        \r
-        self.drawBackground()\r
-        self.initializeWiimotes()\r
-        \r
-        self.songStartTime = self.eventLog.getCurrentTime()\r
-        \r
-        #The main loop\r
-        while not self.done :\r
+        '''\r
+        song = pguconf.song\r
+        cascade = pguconf.cascade\r
+        extendedScale = song.requiresExtendedScale\r
+        easyMode = pguconf.easyMode\r
+        alwaysDown = pguconf.alwaysDown\r
+        eventLog = instrumentChoice.eventLog\r
+        replay = instrumentChoice.replay\r
+        defaultInstrumentChannel = 16\r
+        defaultNote = 60\r
+\r
+        if isinstance(song, Song) :\r
+            self.songDurations = []\r
+            self.totalDuration = None\r
+            self.clicks = [0]\r
+            self.clicksIn = [0]\r
+            self.clicksPerMinute = [0]\r
+            self.clicksInPerMinute = [0]\r
+            self.meanTimeBetweenNotes = []\r
+            self.firstClick = None\r
+            self.firstClickIn = None\r
             \r
             \r
-            #Clear the cursors from the screen\r
-            if self.hasChanged():\r
-                self.drawBackground()\r
-            self.playerScreen.blit(self.savedScreen, (0, 0))\r
+            self.blinkLength = 200\r
+            self.minimalVelocity = 90\r
+            self.shortScaleSize = 8\r
+            self.longScaleSize = 11\r
+            if not extendedScale:\r
+                self.offset = self.longScaleSize - self.shortScaleSize\r
+            else:\r
+                self.offset = 0\r
+            self.borderSize = 5\r
+            self.highlightedNote = 0\r
+            self.highlightedNoteNumber = 0\r
+            self.syllabus = None\r
+            self.savedHighlightedNote = 0\r
+            self.alwaysDown = alwaysDown\r
+            self.nextLevel = None\r
             \r
             \r
-            # Limit frame speed to 50 FPS\r
-            #\r
-            timePassed = self.clock.tick(10000)\r
+            self.wiimotes = instrumentChoice.wiimotes\r
+            self.activeWiimotes = instrumentChoice.activeWiimotes\r
+            self.window = instrumentChoice.window\r
+            self.screen = instrumentChoice.screen\r
+            self.blitOrigin = instrumentChoice.blitOrigin\r
+            self.clock = instrumentChoice.clock\r
+            self.width = instrumentChoice.width\r
+            self.height = instrumentChoice.height\r
+            self.cursorPositions = instrumentChoice.cursorPositions\r
+            self.savedScreen = instrumentChoice.savedScreen\r
+            self.playerScreen = instrumentChoice.playerScreen\r
+            self.extendedScale = extendedScale\r
+            self.cascade = cascade\r
+            self.joys = instrumentChoice.joys\r
+            self.portOffset = instrumentChoice.portOffset\r
+            if eventLog == None :\r
+                self.eventLog = instrumentChoice.eventLog\r
+            else :\r
+                self.eventLog = eventLog\r
+            self.cursorPositions = instrumentChoice.cursorPositions\r
+            self.song = song\r
+            self.songIterator = self.song.getSongIterator()\r
+            self.midiNoteNumbers = self.song.scale\r
+            if replay == None :\r
+                self.replay = instrumentChoice.replay\r
+            else :\r
+                self.replay = replay\r
+            self.quarterNoteLength = song.quarterNoteLength\r
+            self.cascadeLockLengthMultiplier = 1\r
+            self.nextCascadeLockLengthMultiplier = 1\r
+            self.cascadeLockLength = self.quarterNoteLength * self.cascadeLockLengthMultiplier\r
+            \r
+            self.defaultInstrumentChannel = defaultInstrumentChannel\r
+            self.defaultNote = defaultNote\r
+            \r
+            self.done = False\r
+            self.backToInstrumentChoice = False\r
+            self.easyMode = easyMode\r
+            \r
+            #Initializes the highlightedNote and highlightedNoteNumber etc...\r
+            self.moveToNextNote()\r
+            self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier\r
+            \r
+            self.blinkOn = False\r
+            self.savedBlinkOn = False\r
+            ##Will prevent the song to move on if two consecutive notes are identical and the buttons have not been released in between the two\r
+            ##i.e. it guarantees that there will be an attack between two identical consecutive notes\r
+            self.highlightIsFree = True\r
+            \r
+            self.noteRects = []\r
+            self.boundingRect = None\r
+            self.notes = []\r
+            \r
+            self.buttonDown = []\r
+            self.velocityLock = []\r
+            \r
+            self._blinkOffset = 0\r
+            self._cascadeLockTimer = 0\r
+            self.cascadeIsFree = True\r
+            \r
+            self.font = pygame.font.Font(None,80)\r
+            self.renderedNoteNames = [self.font.render(constants.noteNumberToName(note),False,(0,0,0)) for note in self.midiNoteNumbers]\r
             \r
             \r
-            self._blinkOffset += timePassed\r
-            if (self.buttonDown or self.alwaysDown) and not self.cascadeIsFree :\r
-                self._cascadeLockTimer += timePassed\r
-                if self._cascadeLockTimer > self.cascadeLockLengthMultiplier*self.quarterNoteLength :\r
-                    self.cascadeIsFree = True\r
-                    self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier\r
+            self.drawBackground()\r
+            self.initializeWiimotes()\r
             \r
             \r
+            self.songStartTime = self.eventLog.getCurrentTime()\r
             \r
             \r
-            if self._blinkOffset > self.blinkLength:\r
-                self._blinkOffset -= self.blinkLength\r
-                self.blinkOn = not self.blinkOn\r
+            #The main loop\r
+            while not self.done :\r
+                \r
+                #Clear the cursors from the screen\r
+                if self.hasChanged():\r
+                    self.drawBackground()\r
+                self.playerScreen.blit(self.savedScreen, (0, 0))\r
+                \r
+                # Limit frame speed to 50 FPS\r
+                #\r
+                timePassed = self.clock.tick(10000)\r
+                \r
+                self._blinkOffset += timePassed\r
+                if (self.buttonDown or self.alwaysDown) and not self.cascadeIsFree :\r
+                    self._cascadeLockTimer += timePassed\r
+                    if self._cascadeLockTimer > self.cascadeLockLengthMultiplier*self.quarterNoteLength :\r
+                        self.cascadeIsFree = True\r
+                        self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier\r
+                \r
+                \r
+                if self._blinkOffset > self.blinkLength:\r
+                    self._blinkOffset -= self.blinkLength\r
+                    self.blinkOn = not self.blinkOn\r
+                    \r
+                if self.replay:\r
+                    self.eventLog.update(timePassed)\r
+                    pickledEventsToPost = self.eventLog.getPickledEvents() \r
+                    for pickledEvent in pickledEventsToPost:\r
+                        pygame.event.post(pickledEvent.event)\r
+                \r
+                events = pygame.event.get()\r
                 \r
                 \r
-            if self.replay:\r
-                self.eventLog.update(timePassed)\r
-                pickledEventsToPost = self.eventLog.getPickledEvents() \r
-                for pickledEvent in pickledEventsToPost:\r
-                    pygame.event.post(pickledEvent.event)\r
-            \r
-            events = pygame.event.get()\r
-            \r
-            if not self.replay:\r
-                pickledEvents = [PickleableEvent(event.type,event.dict) for event in events]\r
-                if pickledEvents != [] :\r
-                    self.eventLog.appendEventGroup(pickledEvents)\r
-            \r
-            for event in events:\r
-                self.input(event)\r
-                            \r
+                if not self.replay:\r
+                    pickledEvents = [PickleableEvent(event.type,event.dict) for event in events]\r
+                    if pickledEvents != [] :\r
+                        self.eventLog.appendEventGroup(pickledEvents)\r
+                \r
+                for event in events:\r
+                    self.input(event)\r
+                                \r
+                for i in range(len(self.wiimotes)):\r
+                    if self.activeWiimotes[i]:\r
+                        self.wiimotes[i].cursor.update(timePassed, self.cursorPositions[i])\r
+                        if self.buttonDown[i] or self.alwaysDown:\r
+                            self.wiimotes[i].cursor.flash()\r
+                        self.wiimotes[i].cursor.blit(self.playerScreen)\r
+                \r
+                self.screen.blit(self.playerScreen, (0,0))\r
+                \r
+                pygame.display.flip()\r
+            \r
             for i in range(len(self.wiimotes)):\r
                 if self.activeWiimotes[i]:\r
             for i in range(len(self.wiimotes)):\r
                 if self.activeWiimotes[i]:\r
-                    self.wiimotes[i].cursor.update(timePassed, self.cursorPositions[i])\r
-                    if self.buttonDown[i] or self.alwaysDown:\r
-                        self.wiimotes[i].cursor.flash()\r
-                    self.wiimotes[i].cursor.blit(self.playerScreen)\r
+                    self.wiimotes[i].stopNoteByNoteNumber(self.midiNoteNumbers[self.notes[i]])\r
+            if self.replay :        \r
+                self.totalDuration = self.eventLog.getCurrentTime()\r
+        \r
+        elif isinstance(song, Part) :\r
+            self.songDurations = []\r
+            self.totalDuration = None\r
+            self.clicks = [0]\r
+            self.clicksIn = [0]\r
+            self.clicksPerMinute = [0]\r
+            self.clicksInPerMinute = [0]\r
+            self.meanTimeBetweenNotes = []\r
+            self.firstClick = None\r
+            self.firstClickIn = None\r
             \r
             \r
-            self.screen.blit(self.playerScreen, (0,0))\r
+            self.blinkLength = 200\r
+            self.minimalVelocity = 90\r
+            self.shortScaleSize = 8\r
+            self.longScaleSize = 11\r
+            if not extendedScale:\r
+                self.offset = self.longScaleSize - self.shortScaleSize\r
+            else:\r
+                self.offset = 0\r
+            self.borderSize = 5\r
+            self.highlightedNote = 0\r
+            self.highlightedNoteNumber = 0\r
+            self.syllabus = None\r
+            self.savedHighlightedNote = 0\r
+            self.alwaysDown = alwaysDown\r
+            self.nextLevel = None\r
             \r
             \r
-            pygame.display.flip()\r
-        \r
-        for i in range(len(self.wiimotes)):\r
-            if self.activeWiimotes[i]:\r
-                self.wiimotes[i].stopNoteByNoteNumber(self.midiNoteNumbers[self.notes[i]])\r
-        if self.replay :        \r
-            self.totalDuration = self.eventLog.getCurrentTime()            \r
+            self.wiimotes = instrumentChoice.wiimotes\r
+            self.activeWiimotes = instrumentChoice.activeWiimotes\r
+            self.window = instrumentChoice.window\r
+            self.screen = instrumentChoice.screen\r
+            self.blitOrigin = instrumentChoice.blitOrigin\r
+            self.clock = instrumentChoice.clock\r
+            self.width = instrumentChoice.width\r
+            self.height = instrumentChoice.height\r
+            self.cursorPositions = instrumentChoice.cursorPositions\r
+            self.savedScreen = instrumentChoice.savedScreen\r
+            self.playerScreen = instrumentChoice.playerScreen\r
+            self.extendedScale = extendedScale\r
+            self.cascade = cascade\r
+            self.joys = instrumentChoice.joys\r
+            self.portOffset = instrumentChoice.portOffset\r
+            if eventLog == None :\r
+                self.eventLog = instrumentChoice.eventLog\r
+            else :\r
+                self.eventLog = eventLog\r
+            self.cursorPositions = instrumentChoice.cursorPositions\r
+            self.song = song\r
+            self.songIterator = self.song.iterNotes()\r
+            self.midiNoteNumbers = self.song.scale\r
+            if replay == None :\r
+                self.replay = instrumentChoice.replay\r
+            else :\r
+                self.replay = replay\r
+            self.quarterNoteLength = song.quarterNoteLength\r
+            self.cascadeLockLengthMultiplier = 1\r
+            self.nextCascadeLockLengthMultiplier = 1\r
+            self.cascadeLockLength = self.quarterNoteLength * self.cascadeLockLengthMultiplier\r
+            \r
+            self.defaultInstrumentChannel = defaultInstrumentChannel\r
+            self.defaultNote = defaultNote\r
+            \r
+            self.done = False\r
+            self.backToInstrumentChoice = False\r
+            self.easyMode = easyMode\r
+            \r
+            #Initializes the highlightedNote and highlightedNoteNumber etc...\r
+            self.moveToNextNote()\r
+            self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier\r
+            \r
+            self.blinkOn = False\r
+            self.savedBlinkOn = False\r
+            ##Will prevent the song to move on if two consecutive notes are identical and the buttons have not been released in between the two\r
+            ##i.e. it guarantees that there will be an attack between two identical consecutive notes\r
+            self.highlightIsFree = True\r
+            \r
+            self.noteRects = []\r
+            self.boundingRect = None\r
+            self.notes = []\r
+            \r
+            self.buttonDown = []\r
+            self.velocityLock = []\r
+            \r
+            self._blinkOffset = 0\r
+            self._cascadeLockTimer = 0\r
+            self.cascadeIsFree = True\r
+            \r
+            self.font = pygame.font.Font(None,80)\r
+            self.renderedNoteNames = [self.font.render(constants.noteNumberToName(note),False,(0,0,0)) for note in self.midiNoteNumbers]\r
+            \r
+            self.drawBackground()\r
+            self.initializeWiimotes()\r
+            \r
+            self.songStartTime = self.eventLog.getCurrentTime()\r
+            \r
+            #The main loop\r
+            while not self.done :\r
+                \r
+                #Clear the cursors from the screen\r
+                if self.hasChanged():\r
+                    self.drawBackground()\r
+                self.playerScreen.blit(self.savedScreen, (0, 0))\r
+                \r
+                # Limit frame speed to 50 FPS\r
+                #\r
+                timePassed = self.clock.tick(10000)\r
+                \r
+                self._blinkOffset += timePassed\r
+                if (self.buttonDown or self.alwaysDown) and not self.cascadeIsFree :\r
+                    self._cascadeLockTimer += timePassed\r
+                    if self._cascadeLockTimer > self.cascadeLockLengthMultiplier*self.quarterNoteLength :\r
+                        self.cascadeIsFree = True\r
+                        self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier\r
+                \r
+                \r
+                if self._blinkOffset > self.blinkLength:\r
+                    self._blinkOffset -= self.blinkLength\r
+                    self.blinkOn = not self.blinkOn\r
+                    \r
+                if self.replay:\r
+                    self.eventLog.update(timePassed)\r
+                    pickledEventsToPost = self.eventLog.getPickledEvents() \r
+                    for pickledEvent in pickledEventsToPost:\r
+                        pygame.event.post(pickledEvent.event)\r
+                \r
+                events = pygame.event.get()\r
+                \r
+                if not self.replay:\r
+                    pickledEvents = [PickleableEvent(event.type,event.dict) for event in events]\r
+                    if pickledEvents != [] :\r
+                        self.eventLog.appendEventGroup(pickledEvents)\r
+                \r
+                for event in events:\r
+                    self.input(event)\r
+                                \r
+                for i in range(len(self.wiimotes)):\r
+                    if self.activeWiimotes[i]:\r
+                        self.wiimotes[i].cursor.update(timePassed, self.cursorPositions[i])\r
+                        if self.buttonDown[i] or self.alwaysDown:\r
+                            self.wiimotes[i].cursor.flash()\r
+                        self.wiimotes[i].cursor.blit(self.playerScreen)\r
+                \r
+                self.screen.blit(self.playerScreen, (0,0))\r
+                \r
+                pygame.display.flip()\r
+            \r
+            for i in range(len(self.wiimotes)):\r
+                if self.activeWiimotes[i]:\r
+                    self.wiimotes[i].stopNoteByNoteNumber(self.midiNoteNumbers[self.notes[i]])\r
+            if self.replay :        \r
+                self.totalDuration = self.eventLog.getCurrentTime()\r
         \r
     def drawBackground(self):\r
         self.savedScreen.fill((255,255,255))\r
         \r
     def drawBackground(self):\r
         self.savedScreen.fill((255,255,255))\r
@@ -560,5 +725,12 @@ class SongPlayingScreen:
         \r
     def moveToNextNote(self):\r
         self.savedMidiNoteNumbers = self.midiNoteNumbers[:]\r
         \r
     def moveToNextNote(self):\r
         self.savedMidiNoteNumbers = self.midiNoteNumbers[:]\r
-        self.highlightedNote, self.highlightedNoteNumber, self.syllabus, self.nextCascadeLockLengthMultiplier = self.songIterator.next()\r
+        note, lyricIndex = self.songIterator.next()\r
+        self.highlightedNote = note.column\r
+        self.highlightedNoteNumber = note.midi\r
+        self.syllabus = str(note.lyrics[lyricIndex])\r
+        self.nextCascadeLockLengthMultiplier = note.duration\r
         self.midiNoteNumbers[self.highlightedNote] = self.highlightedNoteNumber\r
         self.midiNoteNumbers[self.highlightedNote] = self.highlightedNoteNumber\r
+        \r
+        #self.highlightedNote, self.highlightedNoteNumber, self.syllabus, self.nextCascadeLockLengthMultiplier = self.songIterator.next()\r
+        #self.midiNoteNumbers[self.highlightedNote] = self.highlightedNoteNumber\r
index f5ef8c8..208295a 100644 (file)
Binary files a/src/mxmMidi/DataTypeConverters.pyc and b/src/mxmMidi/DataTypeConverters.pyc differ
index 2657b04..245af08 100644 (file)
Binary files a/src/mxmMidi/EventDispatcher.pyc and b/src/mxmMidi/EventDispatcher.pyc differ
index f6a7165..6524752 100644 (file)
Binary files a/src/mxmMidi/MidiFileParser.pyc and b/src/mxmMidi/MidiFileParser.pyc differ
index 182efaa..88b3cca 100644 (file)
Binary files a/src/mxmMidi/MidiInFile.pyc and b/src/mxmMidi/MidiInFile.pyc differ
index 53ceb24..cc51d3a 100644 (file)
Binary files a/src/mxmMidi/MidiOutStream.pyc and b/src/mxmMidi/MidiOutStream.pyc differ
index 9d05bf3..abad76a 100644 (file)
Binary files a/src/mxmMidi/RawInstreamFile.pyc and b/src/mxmMidi/RawInstreamFile.pyc differ
index 0ce9fec..f392f8b 100644 (file)
Binary files a/src/mxmMidi/constants.pyc and b/src/mxmMidi/constants.pyc differ
index 39df188..ed7dddf 100755 (executable)
@@ -33,6 +33,10 @@ _marker = []
 
 class Part(object) :
     
 
 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 = []
     def __init__(self, node, autoDetectChorus=True) :
         self.node = node
         self.notes = []
@@ -109,10 +113,24 @@ class Part(object) :
     def pprint(self) :
         for note, verseIndex in self.iterNotes() :
             print note.nom, note.name, note.midi, note.duration, note.lyrics[verseIndex]
     def pprint(self) :
         for note, verseIndex in self.iterNotes() :
             print note.nom, note.name, note.midi, note.duration, note.lyrics[verseIndex]
+
+
+    def assignNotesFromMidiNoteNumbers(self):
+        # TODO faire le mapping bande hauteur midi
+        for i in range(len(self.midiNoteNumbers)):
+            noteInExtendedScale = 0
+            while self.midiNoteNumbers[i] > self.scale[noteInExtendedScale] and noteInExtendedScale < len(self.scale)-1:
+                noteInExtendedScale += 1
+            if self.midiNoteNumbers[i]<self.scale[noteInExtendedScale]:
+                noteInExtendedScale -= 1
+            self.notes.append(noteInExtendedScale)
+
         
         
 
 class Note(object) :
         
         
 
 class Note(object) :
+    scale = [55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72]
+    
     def __init__(self, node, divisions, previous) :
         self.node = node
         self.step = _getNodeValue(node, 'pitch/step')
     def __init__(self, node, divisions, previous) :
         self.node = node
         self.step = _getNodeValue(node, 'pitch/step')
@@ -158,6 +176,10 @@ class Note(object) :
         name = '%s%s' % (name, abs(self.alter) * alterext)
         return name
     
         name = '%s%s' % (name, abs(self.alter) * alterext)
         return name
     
+    @property
+    def column(self):
+        return self.scale.index(self.midi)
+    
 
 class Lyric(object) :
     
 
 class Lyric(object) :