From f3c7ce6115ca54c1bc5db03ce03a873ee379edcf Mon Sep 17 00:00:00 2001 From: pin Date: Mon, 8 Feb 2010 11:26:53 +0000 Subject: [PATCH] =?utf8?q?ay=C3=A9,=20on=20joue=20du=20musicxml=20:-)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@13 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/dataTools/__init__.pyc | Bin 175 -> 169 bytes src/dataTools/odict.pyc | Bin 57964 -> 57160 bytes src/gui/PGUConfiguration.py | 4 +- src/gui/SongPlayingScreen.py | 458 ++++++++++++++++++++--------- src/mxmMidi/DataTypeConverters.pyc | Bin 5803 -> 5737 bytes src/mxmMidi/EventDispatcher.pyc | Bin 7056 -> 6978 bytes src/mxmMidi/MidiFileParser.pyc | Bin 4233 -> 4197 bytes src/mxmMidi/MidiInFile.pyc | Bin 2252 -> 2222 bytes src/mxmMidi/MidiOutStream.pyc | Bin 15350 -> 15044 bytes src/mxmMidi/RawInstreamFile.pyc | Bin 4140 -> 4080 bytes src/mxmMidi/constants.pyc | Bin 3692 -> 3680 bytes src/songs/musicxmltosong.py | 22 ++ 12 files changed, 339 insertions(+), 145 deletions(-) diff --git a/src/dataTools/__init__.pyc b/src/dataTools/__init__.pyc index 759cc27736039377d49a53b95479a35ff9f1955e..8d2ef12b4b76136f2b33cf2190120d8c33d53a64 100644 GIT binary patch delta 54 zcmZ3_xRR0m;wN6N=}+<}vYRmmO|+Ahb4?B}rRE8gj;xFo?R)RFFi=Qq;mUyof}N(afcE#?jQ=cg>BOLz-JI zWtx^{M;mh)%iIEq%1{U-6K@QuM!JzK`#-7s_uN0rL^BA2l+*W7koz!XZ%3G)i;cYO`U2t?|F&x2>1p8V&M&f)#u11YB{A(nm<&g4^z2 z$18a30poV8N7CdtcX|wJ6Fum%0QR3~quUfnOVi@J-R(dpG+RTiIjcJM4&SKWqX{%a z2fD}e7cOmf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+bQ+ST{tSX*XA4XC=;5DC7R!(1fKPx8^{J+F6^-qQ)Gz zkb?S_H{8aEb_XL(cX0F1zKc~1_i*zcx`&&8`F-5{qZ)AYpZCB)Z+~**Rf>#n!dcpz z(7Z4 self.cascadeLockLengthMultiplier*self.quarterNoteLength : - self.cascadeIsFree = True - self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier + self.drawBackground() + self.initializeWiimotes() + self.songStartTime = self.eventLog.getCurrentTime() - if self._blinkOffset > self.blinkLength: - self._blinkOffset -= self.blinkLength - self.blinkOn = not self.blinkOn + #The main loop + while not self.done : + + #Clear the cursors from the screen + if self.hasChanged(): + self.drawBackground() + self.playerScreen.blit(self.savedScreen, (0, 0)) + + # Limit frame speed to 50 FPS + # + timePassed = self.clock.tick(10000) + + self._blinkOffset += timePassed + if (self.buttonDown or self.alwaysDown) and not self.cascadeIsFree : + self._cascadeLockTimer += timePassed + if self._cascadeLockTimer > self.cascadeLockLengthMultiplier*self.quarterNoteLength : + self.cascadeIsFree = True + self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier + + + if self._blinkOffset > self.blinkLength: + self._blinkOffset -= self.blinkLength + self.blinkOn = not self.blinkOn + + if self.replay: + self.eventLog.update(timePassed) + pickledEventsToPost = self.eventLog.getPickledEvents() + for pickledEvent in pickledEventsToPost: + pygame.event.post(pickledEvent.event) + + events = pygame.event.get() - if self.replay: - self.eventLog.update(timePassed) - pickledEventsToPost = self.eventLog.getPickledEvents() - for pickledEvent in pickledEventsToPost: - pygame.event.post(pickledEvent.event) - - events = pygame.event.get() - - if not self.replay: - pickledEvents = [PickleableEvent(event.type,event.dict) for event in events] - if pickledEvents != [] : - self.eventLog.appendEventGroup(pickledEvents) - - for event in events: - self.input(event) - + if not self.replay: + pickledEvents = [PickleableEvent(event.type,event.dict) for event in events] + if pickledEvents != [] : + self.eventLog.appendEventGroup(pickledEvents) + + for event in events: + self.input(event) + + for i in range(len(self.wiimotes)): + if self.activeWiimotes[i]: + self.wiimotes[i].cursor.update(timePassed, self.cursorPositions[i]) + if self.buttonDown[i] or self.alwaysDown: + self.wiimotes[i].cursor.flash() + self.wiimotes[i].cursor.blit(self.playerScreen) + + self.screen.blit(self.playerScreen, (0,0)) + + pygame.display.flip() + for i in range(len(self.wiimotes)): if self.activeWiimotes[i]: - self.wiimotes[i].cursor.update(timePassed, self.cursorPositions[i]) - if self.buttonDown[i] or self.alwaysDown: - self.wiimotes[i].cursor.flash() - self.wiimotes[i].cursor.blit(self.playerScreen) + self.wiimotes[i].stopNoteByNoteNumber(self.midiNoteNumbers[self.notes[i]]) + if self.replay : + self.totalDuration = self.eventLog.getCurrentTime() + + elif isinstance(song, Part) : + self.songDurations = [] + self.totalDuration = None + self.clicks = [0] + self.clicksIn = [0] + self.clicksPerMinute = [0] + self.clicksInPerMinute = [0] + self.meanTimeBetweenNotes = [] + self.firstClick = None + self.firstClickIn = None - self.screen.blit(self.playerScreen, (0,0)) + self.blinkLength = 200 + self.minimalVelocity = 90 + self.shortScaleSize = 8 + self.longScaleSize = 11 + if not extendedScale: + self.offset = self.longScaleSize - self.shortScaleSize + else: + self.offset = 0 + self.borderSize = 5 + self.highlightedNote = 0 + self.highlightedNoteNumber = 0 + self.syllabus = None + self.savedHighlightedNote = 0 + self.alwaysDown = alwaysDown + self.nextLevel = None - pygame.display.flip() - - for i in range(len(self.wiimotes)): - if self.activeWiimotes[i]: - self.wiimotes[i].stopNoteByNoteNumber(self.midiNoteNumbers[self.notes[i]]) - if self.replay : - self.totalDuration = self.eventLog.getCurrentTime() + self.wiimotes = instrumentChoice.wiimotes + self.activeWiimotes = instrumentChoice.activeWiimotes + self.window = instrumentChoice.window + self.screen = instrumentChoice.screen + self.blitOrigin = instrumentChoice.blitOrigin + self.clock = instrumentChoice.clock + self.width = instrumentChoice.width + self.height = instrumentChoice.height + self.cursorPositions = instrumentChoice.cursorPositions + self.savedScreen = instrumentChoice.savedScreen + self.playerScreen = instrumentChoice.playerScreen + self.extendedScale = extendedScale + self.cascade = cascade + self.joys = instrumentChoice.joys + self.portOffset = instrumentChoice.portOffset + if eventLog == None : + self.eventLog = instrumentChoice.eventLog + else : + self.eventLog = eventLog + self.cursorPositions = instrumentChoice.cursorPositions + self.song = song + self.songIterator = self.song.iterNotes() + self.midiNoteNumbers = self.song.scale + if replay == None : + self.replay = instrumentChoice.replay + else : + self.replay = replay + self.quarterNoteLength = song.quarterNoteLength + self.cascadeLockLengthMultiplier = 1 + self.nextCascadeLockLengthMultiplier = 1 + self.cascadeLockLength = self.quarterNoteLength * self.cascadeLockLengthMultiplier + + self.defaultInstrumentChannel = defaultInstrumentChannel + self.defaultNote = defaultNote + + self.done = False + self.backToInstrumentChoice = False + self.easyMode = easyMode + + #Initializes the highlightedNote and highlightedNoteNumber etc... + self.moveToNextNote() + self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier + + self.blinkOn = False + self.savedBlinkOn = False + ##Will prevent the song to move on if two consecutive notes are identical and the buttons have not been released in between the two + ##i.e. it guarantees that there will be an attack between two identical consecutive notes + self.highlightIsFree = True + + self.noteRects = [] + self.boundingRect = None + self.notes = [] + + self.buttonDown = [] + self.velocityLock = [] + + self._blinkOffset = 0 + self._cascadeLockTimer = 0 + self.cascadeIsFree = True + + self.font = pygame.font.Font(None,80) + self.renderedNoteNames = [self.font.render(constants.noteNumberToName(note),False,(0,0,0)) for note in self.midiNoteNumbers] + + self.drawBackground() + self.initializeWiimotes() + + self.songStartTime = self.eventLog.getCurrentTime() + + #The main loop + while not self.done : + + #Clear the cursors from the screen + if self.hasChanged(): + self.drawBackground() + self.playerScreen.blit(self.savedScreen, (0, 0)) + + # Limit frame speed to 50 FPS + # + timePassed = self.clock.tick(10000) + + self._blinkOffset += timePassed + if (self.buttonDown or self.alwaysDown) and not self.cascadeIsFree : + self._cascadeLockTimer += timePassed + if self._cascadeLockTimer > self.cascadeLockLengthMultiplier*self.quarterNoteLength : + self.cascadeIsFree = True + self.cascadeLockLengthMultiplier = self.nextCascadeLockLengthMultiplier + + + if self._blinkOffset > self.blinkLength: + self._blinkOffset -= self.blinkLength + self.blinkOn = not self.blinkOn + + if self.replay: + self.eventLog.update(timePassed) + pickledEventsToPost = self.eventLog.getPickledEvents() + for pickledEvent in pickledEventsToPost: + pygame.event.post(pickledEvent.event) + + events = pygame.event.get() + + if not self.replay: + pickledEvents = [PickleableEvent(event.type,event.dict) for event in events] + if pickledEvents != [] : + self.eventLog.appendEventGroup(pickledEvents) + + for event in events: + self.input(event) + + for i in range(len(self.wiimotes)): + if self.activeWiimotes[i]: + self.wiimotes[i].cursor.update(timePassed, self.cursorPositions[i]) + if self.buttonDown[i] or self.alwaysDown: + self.wiimotes[i].cursor.flash() + self.wiimotes[i].cursor.blit(self.playerScreen) + + self.screen.blit(self.playerScreen, (0,0)) + + pygame.display.flip() + + for i in range(len(self.wiimotes)): + if self.activeWiimotes[i]: + self.wiimotes[i].stopNoteByNoteNumber(self.midiNoteNumbers[self.notes[i]]) + if self.replay : + self.totalDuration = self.eventLog.getCurrentTime() def drawBackground(self): self.savedScreen.fill((255,255,255)) @@ -560,5 +725,12 @@ class SongPlayingScreen: def moveToNextNote(self): self.savedMidiNoteNumbers = self.midiNoteNumbers[:] - self.highlightedNote, self.highlightedNoteNumber, self.syllabus, self.nextCascadeLockLengthMultiplier = self.songIterator.next() + note, lyricIndex = self.songIterator.next() + self.highlightedNote = note.column + self.highlightedNoteNumber = note.midi + self.syllabus = str(note.lyrics[lyricIndex]) + self.nextCascadeLockLengthMultiplier = note.duration self.midiNoteNumbers[self.highlightedNote] = self.highlightedNoteNumber + + #self.highlightedNote, self.highlightedNoteNumber, self.syllabus, self.nextCascadeLockLengthMultiplier = self.songIterator.next() + #self.midiNoteNumbers[self.highlightedNote] = self.highlightedNoteNumber diff --git a/src/mxmMidi/DataTypeConverters.pyc b/src/mxmMidi/DataTypeConverters.pyc index f5ef8c80dc90cc6617a0484e53237de5375e8dee..208295a8b229b2c880e3c423b3554adb5c6cc69a 100644 GIT binary patch delta 531 zcmZ3j`%;Jf;wN6Nz9;z`*>zbMqb9EtmX&i%$<55mEG{WZEXgm5DbFv;E-pw+PL1*P z^b60-ocvx`Y4Z#g9VX&cYp};L60Lgje<9Y*?>RP;prc-ZYqJ112k|Zf+tJ7?M!X%H rfAcAjpt@c_f@syslm7_LCnb2+5v6$Zd*LrcyFqDky#VWEAF+4|^z8Z1Pq w-h79bn~^A$z)+Uo?7<&Te4K3N6zXIn+U&`nC9V;#SWD_Iv5FNYXG*IB0N={o>;M1& delta 674 zcmX?PHo=_z;wN6NyEhXzvfp81jGbJ_E2|Qmm|L2fqu`X9SC*QWSzMADQ=VUxU0jfu zoEqcn=@*`v8D>6Np7}m0%I!H6CP%THCsj);>r7I$RI!zis>O?aCuv&Nk)~W>vnQuI z3n_Z!nH46V;eAbt7GMZ(7Uqv5F%lIvpB3z6BhjA8n@3WTVUr73W#t@Gax?QXi%W_UOY)0i%JYk|iwhEyQ)7HR z{lYUdCvRkx-<-qD%tVyx%^O(**oaaIG*@eLE{`rFv8v@K|K=?xRmLQE*DlD@)DGEG|inDbFv;E-pw+ zPL1*P^b60-3^Si>$RocwjhUH=G(B3I&$Ftrk)UU@Ax}6X3F<-an*5lzoHQ+Ro44?3 Kl5CBIfGz+XHgfL( diff --git a/src/mxmMidi/MidiInFile.pyc b/src/mxmMidi/MidiInFile.pyc index 182efaa1e219ebbb979ee947f070628ed50b7942..88b3ccad9cd944091b90919dd81f6071f66ba5a4 100644 GIT binary patch delta 232 zcmX>jxK5D$;wN6N-Y5AR+3&G122Em*c{7J30FnArF8}}l delta 267 zcmZ1{ct()@;wN6Ndp8p|vfpE2jF@cCA*&Lcm|L2fqu`X9SC*QWSzMADQ=VUxU0jfu voEqcn=@*`v8D>6Nk@W^?%B3dyp|G* z8^t>1!p&N_AXh7Hk+^X;v7{8g|KNM>KhM*1e$VrqClkFM=TjfKhSk?#oL|#(J!Doy zsm(tU7!5?m!u?~xa9=bS9*Tte2L}7PI=XuU0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git a/src/mxmMidi/constants.pyc b/src/mxmMidi/constants.pyc index 0ce9fecea7b9f08d07346880b3a90cdaf0ccaee6..f392f8bbdeb87efd5d07592dfa4dab9e2fb262f3 100644 GIT binary patch delta 104 zcmaDO^FW6E;wN6N-Y5AR+5fUI22Pgam6dZ$$<55mEG{WZEXgm5DbFv;E-pw+PL1*P a^b60-oE*<9wK;)xFFR4HH^=kxG6Db~mnI self.scale[noteInExtendedScale] and noteInExtendedScale < len(self.scale)-1: + noteInExtendedScale += 1 + if self.midiNoteNumbers[i]