-'''\r
-Created on 23 juil. 2009\r
-\r
-@author: Samuel Benveniste\r
-'''\r
-from math import floor, ceil\r
-import pygame\r
-import sys\r
-import colorsys\r
-import constants\r
-from gradients import gradients\r
-from logging.PickleableEvent import PickleableEvent\r
-\r
-\r
-class SongPlayingScreen:\r
- '''\r
- The screen on which the game is played\r
- \r
- wiimotes: \r
- The wiimotes used in this session\r
- window:\r
- The main display window\r
- screen:\r
- The main display surface\r
- clock:\r
- The clock used to animate the screen\r
- savedScreen:\r
- The background that is painted every time\r
- playerScreen:\r
- The buffer for painting everything before bliting\r
- width:\r
- The width of the window in pixels\r
- height:\r
- The height of the window in pixels\r
- extendScale :\r
- True if the scale is G to C instead of C to C\r
- cascade:\r
- True if crossing from note to note with a button pressed triggers a new note\r
- scaleSize:\r
- The size of the scale used\r
- cursorPositions:\r
- The positions of the cursors on the screen, in pixels\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
- '''\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
- #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
- if self.extendedScale :\r
- self.scaleSize = self.longScaleSize\r
- else:\r
- self.scaleSize = self.shortScaleSize\r
- \r
- self.noteRects = [pygame.Rect(i * self.width / self.scaleSize+self.blitOrigin[0], self.blitOrigin[1], self.width / self.scaleSize + 1, self.height+1) for i in range(self.scaleSize)]\r
- #inflate last noteRect to cover the far right pixels\r
- self.noteRects[-1].width = self.noteRects[-1].width + 1\r
- \r
- self.noteRects[self.highlightedNote-self.offset].inflate_ip(self.noteRects[self.highlightedNote-self.offset].width*2,0)\r
- \r
- #create bounding rect\r
- self.boundingRect = self.noteRects[0].unionall(self.noteRects)\r
- \r
- self.renderedNoteNames = [self.font.render(constants.noteNumberToName(note),False,(0,0,0)) for note in self.midiNoteNumbers]\r
- \r
- #fill the rectangles with a color gradient\r
- #We start with blue\r
- startingHue = 0.66666666666666663\r
- \r
- for rectNumber in range(self.scaleSize):\r
- colorRatio = float(rectNumber) / (self.scaleSize - 1)\r
- #hue will go from 0.6666... (blue) to 0 (red) as colorRation goes up\r
- hue = startingHue * (1 - colorRatio)\r
- if rectNumber + self.offset != self.highlightedNote:\r
- #The color of the bottom of the rectangle in hls coordinates\r
- bottomColorHls = (hue, 0.1, 1)\r
- #The color of the top of the rectangle in hls coordinates\r
- topColorHls = (hue, 0.1, 1)\r
- \r
- #convert to rgb ranging from 0 to 255\r
- bottomColorRgb = [floor(255 * i) for i in colorsys.hls_to_rgb(*bottomColorHls)]\r
- topColorRgb = [floor(255 * i) for i in colorsys.hls_to_rgb(*topColorHls)]\r
- #add transparency\r
- bottomColorRgb.append(255)\r
- topColorRgb.append(255)\r
- #convert to tuple\r
- bottomColorRgb = tuple(bottomColorRgb)\r
- topColorRgb = tuple(topColorRgb) \r
- \r
- self.savedScreen.blit(gradients.vertical(self.noteRects[rectNumber].size, topColorRgb, bottomColorRgb), self.noteRects[rectNumber])\r
- \r
- noteNameBlitPoint = (self.noteRects[rectNumber].left+(self.noteRects[rectNumber].width-self.renderedNoteNames[rectNumber+self.offset].get_width())/2,\r
- self.noteRects[rectNumber].bottom-self.renderedNoteNames[rectNumber+self.offset].get_height())\r
- \r
- self.savedScreen.blit(self.renderedNoteNames[rectNumber+self.offset], noteNameBlitPoint)\r
- \r
- pygame.draw.rect(self.savedScreen, pygame.Color(0, 0, 0, 255), self.noteRects[rectNumber], 2)\r
- \r
- colorRatio = float(self.highlightedNote-self.offset) / (self.scaleSize - 1)\r
- #hue will go from 0.6666... (blue) to 0 (red) as colorRation goes up\r
- hue = startingHue * (1 - colorRatio)\r
- #The color of the bottom of the rectangle in hls coordinates\r
- bottomColorHls = (hue, 0.6, 1)\r
- #The color of the top of the rectangle in hls coordinates\r
- topColorHls = (hue, 0.9, 1)\r
- \r
- #convert to rgb ranging from 0 to 255\r
- bottomColorRgb = [floor(255 * i) for i in colorsys.hls_to_rgb(*bottomColorHls)]\r
- topColorRgb = [floor(255 * i) for i in colorsys.hls_to_rgb(*topColorHls)]\r
- #add transparency\r
- bottomColorRgb.append(255)\r
- topColorRgb.append(255)\r
- #convert to tuple\r
- bottomColorRgb = tuple(bottomColorRgb)\r
- topColorRgb = tuple(topColorRgb) \r
- \r
- self.savedScreen.blit(gradients.vertical(self.noteRects[self.highlightedNote-self.offset].size, topColorRgb, bottomColorRgb), self.noteRects[self.highlightedNote-self.offset])\r
- \r
- noteNameBlitPoint = (self.noteRects[self.highlightedNote-self.offset].left+(self.noteRects[self.highlightedNote-self.offset].width-self.renderedNoteNames[self.highlightedNote].get_width())/2,\r
- self.noteRects[self.highlightedNote-self.offset].bottom-self.renderedNoteNames[self.highlightedNote].get_height())\r
- \r
- self.savedScreen.blit(self.renderedNoteNames[self.highlightedNote], noteNameBlitPoint)\r
- \r
- if self.syllabus :\r
- renderedSyllabus = self.font.render(self.syllabus,False,(0,0,0))\r
- \r
- syllabusBlitPoint = (self.noteRects[self.highlightedNote-self.offset].left+(self.noteRects[self.highlightedNote-self.offset].width-renderedSyllabus.get_width())/2,\r
- self.noteRects[self.highlightedNote-self.offset].centery-renderedSyllabus.get_height()/2)\r
- \r
- self.savedScreen.blit(renderedSyllabus, syllabusBlitPoint)\r
- \r
- pygame.draw.rect(self.savedScreen, pygame.Color(0, 0, 0, 255), self.noteRects[self.highlightedNote-self.offset], 2) \r
- \r
- if self.song != None and self.blinkOn:\r
- borderSize = self.borderSize\r
- pygame.draw.rect(self.savedScreen, pygame.Color(0, 0, 0, 0), self.noteRects[self.highlightedNote-self.offset].inflate(borderSize/2,borderSize/2), borderSize)\r
- \r
- def initializeWiimotes(self):\r
- for loop in self.wiimotes:\r
- if loop.port == None :\r
- loop.port = pygame.midi.Output(loop.portNumber)\r
- self.notes.append(0)\r
- self.buttonDown.append(False)\r
- self.velocityLock.append(False)\r
- \r
- def updateCursorPositionFromJoy(self, joyEvent):\r
- joyName = pygame.joystick.Joystick(joyEvent.joy).get_name()\r
- correctedJoyId = constants.joyNames.index(joyName)\r
- if correctedJoyId < len(self.cursorPositions):\r
- if joyEvent.axis == 0 :\r
- self.cursorPositions[correctedJoyId] = (int((joyEvent.value + 1) / 2 * self.screen.get_width()), self.cursorPositions[correctedJoyId][1])\r
- if joyEvent.axis == 1 :\r
- self.cursorPositions[correctedJoyId] = (self.cursorPositions[correctedJoyId][0], int((joyEvent.value + 1) / 2 * self.screen.get_height()))\r
- \r
- def heightToVelocity(self, pos, controllerNumber):\r
- if self.song != None:\r
- if self.boundingRect.collidepoint(pos) and (self.highlightedNote == self.notes[controllerNumber] or self.velocityLock[controllerNumber]):\r
- velocity = int(floor((1 - (float(pos[1])-self.blitOrigin[1]) / self.height) * (127-self.minimalVelocity))+self.minimalVelocity)\r
- else :\r
- if self.easyMode:\r
- velocity = None\r
- else:\r
- velocity = 60\r
- else:\r
- if self.boundingRect.collidepoint(pos):\r
- velocity = int(floor((1 - (float(pos[1])-self.blitOrigin[1]) / self.height) * (127-self.minimalVelocity))+self.minimalVelocity)\r
- else :\r
- velocity = self.minimalVelocity\r
- return(velocity)\r
- \r
- def widthToNote(self, pos):\r
- nn = 0\r
- try :\r
- if self.noteRects[self.highlightedNote-self.offset].collidepoint(pos) :\r
- return self.highlightedNote\r
- else :\r
- while self.noteRects[nn].collidepoint(pos) == False:\r
- nn = nn + 1\r
- return(nn + self.offset)\r
- except(IndexError):\r
- return(None)\r
- \r
- def logClick(self):\r
- self.clicks[-1] += 1\r
- if self.firstClick == None :\r
- self.firstClick = self.eventLog.getCurrentTime()\r
- minute = int(floor((self.eventLog.getCurrentTime()-self.songStartTime)/60000))\r
- if minute > len(self.clicksPerMinute)-1:\r
- self.clicksPerMinute.append(0)\r
- self.clicksPerMinute[-1] += 1\r
- \r
- def logClickIn(self):\r
- self.clicksIn[-1] += 1\r
- if self.clicksIn[-1] > len(self.song.notes)-1 :\r
- self.clicksIn.append(0)\r
- self.clicks.append(0)\r
- self.songDurations.append(self.eventLog.getCurrentTime())\r
- if self.firstClickIn == None :\r
- self.firstClickIn = self.eventLog.getCurrentTime()\r
- minute = int(floor((self.eventLog.getCurrentTime()-self.songStartTime)/60000))\r
- if minute > len(self.clicksInPerMinute)-1:\r
- self.clicksInPerMinute.append(0)\r
- self.clicksInPerMinute[-1]+=1\r
- \r
- def input(self, event): \r
- \r
- if event.type == pygame.QUIT:\r
- for loop in self.wiimotes:\r
- del loop.port\r
- pygame.midi.quit()\r
- sys.exit(0) \r
- \r
- if event.type == pygame.KEYDOWN:\r
- if event.key == pygame.K_q:\r
- self.nextLevel = None\r
- self.done = True\r
- \r
- if event.key == pygame.K_i:\r
- self.backToInstrumentChoice = True\r
- self.done = True\r
- \r
- if event.key == pygame.K_w:\r
- self.nextLevel = 0\r
- self.done = True\r
- \r
- if event.key == pygame.K_e:\r
- self.nextLevel = 1\r
- self.done = True\r
- \r
- if event.key == pygame.K_r:\r
- self.nextLevel = 2\r
- self.done = True\r
- \r
- if event.key == pygame.K_t:\r
- self.nextLevel = 3\r
- self.done = True \r
- \r
- if event.type == pygame.JOYAXISMOTION:\r
- \r
- joyName = pygame.joystick.Joystick(event.joy).get_name()\r
- correctedJoyId = constants.joyNames.index(joyName)\r
- if self.activeWiimotes[correctedJoyId]:\r
- self.updateCursorPositionFromJoy(event)\r
- wiimote = self.wiimotes[correctedJoyId]\r
- pos = self.cursorPositions[correctedJoyId]\r
- \r
- if (self.buttonDown[correctedJoyId] or self.alwaysDown):\r
- if self.notes[correctedJoyId] != None:\r
- velocity = self.heightToVelocity(pos, correctedJoyId)\r
- if velocity != None :\r
- CCHexCode = wiimote.getCCHexCode()\r
- wiimote.port.write_short(CCHexCode, 07, velocity)\r
- if self.cascade and self.cascadeIsFree :\r
- n = self.widthToNote(pos)\r
- if self.highlightedNote == n:\r
- wiimote.stopNoteByNoteNumber(self.savedMidiNoteNumbers[self.notes[correctedJoyId]])\r
- self.notes[correctedJoyId] = n\r
- velocity = self.heightToVelocity(pos, correctedJoyId)\r
- self.velocityLock[correctedJoyId] = True\r
- wiimote.playNoteByNoteNumber(self.midiNoteNumbers[self.notes[correctedJoyId]],velocity)\r
- self.moveToNextNote()\r
- self._cascadeLockTimer = 0\r
- self.cascadeIsFree = False\r
- \r
- if event.type == pygame.JOYBUTTONDOWN :\r
- \r
- joyName = pygame.joystick.Joystick(event.joy).get_name()\r
- correctedJoyId = constants.joyNames.index(joyName)\r
- if self.activeWiimotes[correctedJoyId]:\r
- wiimote = self.wiimotes[correctedJoyId]\r
- pos = self.cursorPositions[correctedJoyId]\r
- self.wiimotes[correctedJoyId].cursor.flash()\r
- if self.replay:\r
- self.logClick()\r
- \r
- if not (self.buttonDown[correctedJoyId] or self.alwaysDown):\r
- n = self.widthToNote(pos)\r
- if self.highlightedNote == n:\r
- self._cascadeLockTimer = 0\r
- self.cascadeIsFree = False\r
- if self.easyMode:\r
- wiimote.stopNoteByNoteNumber(self.savedMidiNoteNumbers[self.notes[correctedJoyId]])\r
- self.notes[correctedJoyId] = n\r
- velocity = self.heightToVelocity(pos, correctedJoyId)\r
- self.velocityLock[correctedJoyId] = True\r
- wiimote.playNoteByNoteNumber(self.midiNoteNumbers[self.notes[correctedJoyId]],velocity)\r
- if self.replay :\r
- self.logClickIn()\r
- self.moveToNextNote()\r
- else :\r
- if not self.easyMode :\r
- self._cascadeLockTimer = 0\r
- self.cascadeIsFree = False\r
- self.notes[correctedJoyId] = n\r
- velocity = self.heightToVelocity(pos, correctedJoyId) \r
- if velocity != None and self.notes[correctedJoyId] != None :\r
- wiimote.playNoteByNoteNumber(self.midiNoteNumbers[self.notes[correctedJoyId]],velocity) \r
- self.buttonDown[correctedJoyId] = True\r
- \r
- if event.type == pygame.JOYBUTTONUP:\r
- joyName = pygame.joystick.Joystick(event.joy).get_name()\r
- correctedJoyId = constants.joyNames.index(joyName)\r
- if self.activeWiimotes[correctedJoyId]:\r
- self.buttonDown[correctedJoyId] = False\r
- wiimote = self.wiimotes[correctedJoyId]\r
- if not self.easyMode:\r
- wiimote.stopNoteByNoteNumber(self.savedMidiNoteNumbers[self.notes[correctedJoyId]])\r
- self.velocityLock[correctedJoyId] = False\r
- \r
- if event.type == pygame.MOUSEMOTION:\r
- \r
- self.updateCursorPositionFromMouse(event)\r
- \r
- correctedJoyId = 0\r
- while not self.activeWiimotes[correctedJoyId] :\r
- correctedJoyId += 1\r
- wiimote = self.wiimotes[correctedJoyId]\r
- pos = self.cursorPositions[correctedJoyId]\r
-\r
- if (self.buttonDown[correctedJoyId] or self.alwaysDown):\r
- self.wiimotes[correctedJoyId].cursor.flash()\r
- if self.notes[correctedJoyId] != None:\r
- velocity = self.heightToVelocity(pos, correctedJoyId)\r
- if velocity != None :\r
- CCHexCode = wiimote.getCCHexCode()\r
- wiimote.port.write_short(CCHexCode, 07, velocity)\r
- if self.cascade and self.cascadeIsFree :\r
- n = self.widthToNote(pos)\r
- if self.highlightedNote == n:\r
- wiimote.stopNoteByNoteNumber(self.savedMidiNoteNumbers[self.notes[correctedJoyId]])\r
- self.notes[correctedJoyId] = n\r
- velocity = self.heightToVelocity(pos, correctedJoyId)\r
- self.velocityLock[correctedJoyId] = True\r
- wiimote.playNoteByNoteNumber(self.midiNoteNumbers[self.notes[correctedJoyId]],velocity)\r
- self.moveToNextNote()\r
- self._cascadeLockTimer = 0\r
- self.cascadeIsFree = False \r
- \r
- if event.type == pygame.MOUSEBUTTONDOWN:\r
- \r
- if event.button == 1:\r
- correctedJoyId = 0\r
- while not self.activeWiimotes[correctedJoyId] :\r
- correctedJoyId += 1\r
- wiimote = self.wiimotes[correctedJoyId]\r
- pos = self.cursorPositions[correctedJoyId]\r
- self.wiimotes[correctedJoyId].cursor.flash()\r
- if self.replay:\r
- self.logClick()\r
- \r
- if not (self.buttonDown[correctedJoyId] or self.alwaysDown):\r
- n = self.widthToNote(pos)\r
- if self.highlightedNote == n:\r
- self._cascadeLockTimer = 0\r
- self.cascadeIsFree = False\r
- if self.easyMode:\r
- wiimote.stopNoteByNoteNumber(self.savedMidiNoteNumbers[self.notes[correctedJoyId]])\r
- self.notes[correctedJoyId] = n\r
- velocity = self.heightToVelocity(pos, correctedJoyId)\r
- self.velocityLock[correctedJoyId] = True\r
- wiimote.playNoteByNoteNumber(self.midiNoteNumbers[self.notes[correctedJoyId]],velocity)\r
- if self.replay :\r
- self.logClickIn()\r
- self.moveToNextNote()\r
- else :\r
- if not self.easyMode :\r
- self._cascadeLockTimer = 0\r
- self.cascadeIsFree = False\r
- self.notes[correctedJoyId] = n\r
- velocity = self.heightToVelocity(pos, correctedJoyId) \r
- if velocity != None and self.notes[correctedJoyId] != None :\r
- wiimote.playNoteByNoteNumber(self.midiNoteNumbers[self.notes[correctedJoyId]],velocity) \r
- self.buttonDown[correctedJoyId] = True \r
- \r
- if event.button == 2:\r
- \r
- self.done = True\r
- \r
- if event.type == pygame.MOUSEBUTTONUP:\r
- if event.button == 1 :\r
- correctedJoyId = 0\r
- while not self.activeWiimotes[correctedJoyId] :\r
- correctedJoyId += 1\r
- wiimote = self.wiimotes[correctedJoyId]\r
- self.buttonDown[correctedJoyId] = False\r
- if not self.easyMode:\r
- if self.notes[correctedJoyId] != None :\r
- wiimote.stopNoteByNoteNumber(self.savedMidiNoteNumbers[self.notes[correctedJoyId]])\r
- self.velocityLock[correctedJoyId] = False\r
- \r
- def hasChanged(self):\r
- changed = False\r
- if self.song != None:\r
- if self.blinkOn != self.savedBlinkOn or self.highlightedNote != self.savedHighlightedNote:\r
- self.savedBlinkOn = self.blinkOn\r
- self.savedHighlightedNote = self.highlightedNote\r
- changed = True\r
- return(changed)\r
- \r
- def updateCursorPositionFromMouse(self, mouseEvent):\r
- correctedJoyId = 0\r
- while not self.activeWiimotes[correctedJoyId] :\r
- correctedJoyId += 1\r
- self.cursorPositions[correctedJoyId] = mouseEvent.pos\r
- \r
- def moveToNextNote(self):\r
- self.savedMidiNoteNumbers = self.midiNoteNumbers[:]\r
- self.highlightedNote, self.highlightedNoteNumber, self.syllabus, self.nextCascadeLockLengthMultiplier = self.songIterator.next()\r
- self.midiNoteNumbers[self.highlightedNote] = self.highlightedNoteNumber\r