pygame.display.set_caption('MINWii')
WT = self.WT
pygame.display.set_caption('MINWii')
WT = self.WT
- songFile, playMode, wiimoteIndex = '', 'NORMAL', 0
+ songFile, playMode, displayNotes, wiimoteIndex = '', 'NORMAL', True, 0
while True :
WT.resume()
WT.selectWiimote(self.nwiimotes - 1) # la télécommande est la souris
self.screen = SCREEN_HOME
while True :
WT.resume()
WT.selectWiimote(self.nwiimotes - 1) # la télécommande est la souris
self.screen = SCREEN_HOME
- exit, songFile, playMode, wiimoteIndex = \
- self.selectSongAndOptions(songFile, playMode, wiimoteIndex)
+ exit, songFile, playMode, displayNotes, wiimoteIndex = \
+ self.selectSongAndOptions(songFile, playMode, displayNotes, wiimoteIndex)
self.screen = SCREEN_PLAY
WT.selectWiimote(wiimoteIndex)
self.screen = SCREEN_PLAY
WT.selectWiimote(wiimoteIndex)
- self.runPlayingScreen(songFile, playMode, instrumentDescription)
+ self.runPlayingScreen(songFile, playMode, displayNotes, instrumentDescription)
- def selectSongAndOptions(self, songFile, playMode, wiimoteIndex) :
+ def selectSongAndOptions(self, songFile, playMode, displayNotes, wiimoteIndex) :
""" lance l'écran de paramétrage et retourne un tuple comportant :
- drapeau de sortie de l'application (booléen)
- chemin du fichier de la chanson
- mode (entier)
""" lance l'écran de paramétrage et retourne un tuple comportant :
- drapeau de sortie de l'application (booléen)
- chemin du fichier de la chanson
- mode (entier)
+ - affichage des notes (booléen)
- wiimote sélectionnée (entier)
"""
home = Home(songPath=SONG_FILE_PATH,
songFile=songFile,
playMode=playMode,
- wiimote sélectionnée (entier)
"""
home = Home(songPath=SONG_FILE_PATH,
songFile=songFile,
playMode=playMode,
+ displayNotes=displayNotes,
wiimoteIndex=wiimoteIndex,
nwiimotes=self.nwiimotes)
app = self.app
wiimoteIndex=wiimoteIndex,
nwiimotes=self.nwiimotes)
app = self.app
return (home.exitApp,
home.songFile,
home.selectedPlayMode,
return (home.exitApp,
home.songFile,
home.selectedPlayMode,
home.selectedWiimoteIndex)
def selectInstrument(self) :
home.selectedWiimoteIndex)
def selectInstrument(self) :
console.info('ajustement octave : %d', instru['octave'])
return instru
console.info('ajustement octave : %d', instru['octave'])
return instru
- def runPlayingScreen(self, songFile, playMode, instrumentDescription) :
+ def runPlayingScreen(self, songFile, playMode, displayNotes, instrumentDescription) :
""" Lance l'écran de jeu principal avec la chanson 'songFile' dans le mode 'playMode'
avec l'instrument midi 'instrumentDescription'.
"""
""" Lance l'écran de jeu principal avec la chanson 'songFile' dans le mode 'playMode'
avec l'instrument midi 'instrumentDescription'.
"""
self.synth.adjust_octave(0, octave)
self.synth.program_select(0, bank, preset)
if playMode == PLAYING_MODES_DICT['IMPRO'] :
self.synth.adjust_octave(0, octave)
self.synth.program_select(0, bank, preset)
if playMode == PLAYING_MODES_DICT['IMPRO'] :
- playingScreen = PlayingScreen(self.synth)
+ playingScreen = PlayingScreen(self.synth, displayNotes=displayNotes)
else :
song = musicXml2Song(songFile)
else :
song = musicXml2Song(songFile)
- self.playingScreen = playingScreen = SongPlayingScreen(self.synth, song, mode=playMode)
+ self.playingScreen = playingScreen = SongPlayingScreen(self.synth, song, mode=playMode, displayNotes=displayNotes)
playingScreen.run()
pygame.event.clear()
EventDispatcher.reset()
playingScreen.run()
pygame.event.clear()
EventDispatcher.reset()
''' colonne utilisée pour l'affichage d'une touche du clavier de jeu.
'''
''' colonne utilisée pour l'affichage d'une touche du clavier de jeu.
'''
- def __init__(self, group, index, hue, rect, tone) :
+ def __init__(self, group, index, hue, rect, tone, displayNote=True) :
pygame.sprite.DirtySprite.__init__(self, group)
self.index = index
self.state = False
pygame.sprite.DirtySprite.__init__(self, group)
self.index = index
self.state = False
w, h = rect.w, rect.h
tw, th, = toneName.get_size()
toneRect = pygame.Rect(((w - tw) / 2, h - th), (tw, th))
w, h = rect.w, rect.h
tw, th, = toneName.get_size()
toneRect = pygame.Rect(((w - tw) / 2, h - th), (tw, th))
- sur.blit(toneName, toneRect)
+ if displayNote :
+ sur.blit(toneName, toneRect)
self.surOff = sur
self.rectOff = rect
self.surOff = sur
self.rectOff = rect
self.surOn = gradients.vertical(rectOn.size, topRgba, bottomRgba)
w, h = rectOn.w, rectOn.h
toneRect = pygame.Rect(((w - tw) / 2, h - th), (tw, th))
self.surOn = gradients.vertical(rectOn.size, topRgba, bottomRgba)
w, h = rectOn.w, rectOn.h
toneRect = pygame.Rect(((w - tw) / 2, h - th), (tw, th))
- self.surOn.blit(toneName, toneRect)
+ if displayNote :
+ self.surOn.blit(toneName, toneRect)
self.rectOn = rectOn
self.image = self.surOff
self.rectOn = rectOn
self.image = self.surOff
self.font = pygame.font.Font(None,70)
self._fill()
self.selectedPlayMode = params.get('playMode', 'NORMAL')
self.font = pygame.font.Font(None,70)
self._fill()
self.selectedPlayMode = params.get('playMode', 'NORMAL')
+ self.displayNotes = params.get('displayNotes', True)
self.selectedWiimoteIndex = params.get('wiimoteIndex', 0)
self._initLocalListeners()
self.selectedWiimoteIndex = params.get('wiimoteIndex', 0)
self._initLocalListeners()
for k, caption in PLAYING_MODES :
self.modeSelect.add(self.createLabel(caption), k)
self.td(self.modeSelect,colspan=3, style=STYLE_RIGHT_COL)
for k, caption in PLAYING_MODES :
self.modeSelect.add(self.createLabel(caption), k)
self.td(self.modeSelect,colspan=3, style=STYLE_RIGHT_COL)
+
+ # affichage / masquage des noms de notes
+ self.tr()
+ self.td(self.createLabel("Notes :"), style=STYLE_LEFT_COL)
+ self.displayNotesSelect = Select(True)
+ for k, caption in ((True, 'Oui'), (False, 'Non')) :
+ self.displayNotesSelect.add(self.createLabel(caption), k)
+ self.td(self.displayNotesSelect, style=STYLE_RIGHT_COL)
+
# choix des wiimotes
self.tr()
# choix des wiimotes
self.tr()
else :
self.playButton.disabled = False
else :
self.playButton.disabled = False
+ @property
+ def displayNotes(self) :
+ return self.displayNotesSelect.value
+
+ @displayNotes.setter
+ def displayNotes(self, value) :
+ self.displayNotesSelect.value = value
+
@property
def selectedWiimoteIndex(self) :
return self.selectedWiimote.value
@property
def selectedWiimoteIndex(self) :
return self.selectedWiimote.value
class PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) :
class PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) :
- def __init__(self, synth, distinctNotes=[]) :
+ def __init__(self, synth, distinctNotes=[], displayNotes=True) :
"""
distinctNotes : notes disctinctes présentes dans la chanson
triées du plus grave au plus aigu.
"""
distinctNotes : notes disctinctes présentes dans la chanson
triées du plus grave au plus aigu.
super(PlayingScreenBase, self).__init__()
self.synth = synth
self.distinctNotes = distinctNotes
super(PlayingScreenBase, self).__init__()
self.synth = synth
self.distinctNotes = distinctNotes
+ self.displayNotes = displayNotes
self.keyboardLength = 0
self.keyboardRects = []
self.cursor = None
self.keyboardLength = 0
self.keyboardRects = []
self.cursor = None
for i, rect in enumerate(self.keyboardRects) :
hue = FIRST_HUE - hueStep * i
tone = self.distinctNotes[i]
for i, rect in enumerate(self.keyboardRects) :
hue = FIRST_HUE - hueStep * i
tone = self.distinctNotes[i]
- c = Column(self, i, hue, rect, tone)
+ c = Column(self, i, hue, rect, tone, displayNote=self.displayNotes)
self.add(c, layer=BACKGROUND_LAYER)
self.columns[tone.midi] = c
self.add(c, layer=BACKGROUND_LAYER)
self.columns[tone.midi] = c
scale = [55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72]
scale = [55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72]
- def __init__(self, synth) :
+ def __init__(self, synth, displayNotes=True) :
distinctNotes = []
self.currentColumn = None
for midi in self.scale :
tone = Tone(midi)
distinctNotes.append(tone)
distinctNotes = []
self.currentColumn = None
for midi in self.scale :
tone = Tone(midi)
distinctNotes.append(tone)
- super(PlayingScreen, self).__init__(synth, distinctNotes)
+ super(PlayingScreen, self).__init__(synth, distinctNotes, displayNotes=displayNotes)
@event_handler(events.COLDOWN)
def noteon(self, event) :
@event_handler(events.COLDOWN)
def noteon(self, event) :
class SongPlayingScreen(PlayingScreenBase) :
class SongPlayingScreen(PlayingScreenBase) :
- def __init__(self, synth, song, mode=PLAYING_MODES_DICT['NORMAL'], tempoTrim=0) :
- super(SongPlayingScreen, self).__init__(synth, song.distinctNotes)
+ def __init__(self, synth, song, mode=PLAYING_MODES_DICT['NORMAL'], displayNotes=True, tempoTrim=0) :
+ super(SongPlayingScreen, self).__init__(synth, song.distinctNotes, displayNotes=displayNotes)
self.song = song
self.quarterNoteDuration = song.quarterNoteDuration
self.tempoTrim = tempoTrim
self.song = song
self.quarterNoteDuration = song.quarterNoteDuration
self.tempoTrim = tempoTrim