avec l'instrument midi 'instrumentDescription'.
"""
playMode = PLAYING_MODES_DICT[playMode]
- song = musicXml2Song(songFile)
bank, preset = instrumentDescription['bank'], instrumentDescription['preset']
octave = instrumentDescription['octave']
self.synth.adjust_octave(0, octave)
self.synth.program_select(0, bank, preset)
- playingScreen = SongPlayingScreen(self.synth, song, mode=playMode)
+ if playMode == PLAYING_MODES_DICT['IMPRO'] :
+ playingScreen = PlayingScreen(self.synth)
+ else :
+ song = musicXml2Song(songFile)
+ playingScreen = SongPlayingScreen(self.synth, song, mode=playMode)
playingScreen.run()
pygame.event.clear()
EventDispatcher.reset()
('EASY' , u'Facile'),
('NORMAL' , u'Normal'),
('ADVANCED' , u'Avancé'),
- ('EXPERT' , u'Expert'))
+ ('EXPERT' , u'Expert'),
+ ('IMPRO' , u'Impro.'),)
if state :
group.change_layer(self, FOREGROUND_LAYER)
sur = self.surOn
+ rect = self.rectOn
if syllabus :
sur = sur.copy()
- rect = self.rectOn
renderedSyl = LYRICS_FONT.render(syllabus, True, FONT_COLOR)
sw, sh, = renderedSyl.get_size()
w, h = self.rectOn.w, self.rectOn.h
del st['padding_top']
self.td(self.songTitle, style = st)
- # choix du niveau
+ # choix du mode de jeu
self.tr()
- self.td(self.createLabel("Niveau :"), style=STYLE_LEFT_COL)
+ self.td(self.createLabel("Mode :"), style=STYLE_LEFT_COL)
self.modeSelect = Select('NORMAL')
for k, caption in PLAYING_MODES :
self.modeSelect.add(self.createLabel(caption), k)
self.tr()
self.quitButton = Button(self.createLabel("Quitter"))
self.td(self.quitButton, style={'padding_top' : 50})
- self.playButton = Button(self.createLabel("Jouer"), disabled=not self.songFile)
+ self.playButton = Button(self.createLabel("Jouer"))
self.td(self.playButton, style={'padding_top' : 50})
@property
@selectedPlayMode.setter
def selectedPlayMode(self, value) :
self.modeSelect.value = value
+ if self.selectedPlayMode != 'IMPRO' and \
+ not self.songFile :
+ self.playButton.disabled = True
+ else :
+ self.playButton.disabled = False
@property
def selectedWiimoteIndex(self) :
self.browseButton.connect(CLICK, self.open_file_browser)
self.quitButton.connect(CLICK, self._exitApp)
self.playButton.connect(CLICK, self._exitHome)
+ self.modeSelect.connect(CHANGE, self._changeModeCB)
+
+ def _changeModeCB(self) :
+ if self.selectedPlayMode == 'IMPRO' :
+ self.playButton.disabled = False
+ elif not self.songFile :
+ self.playButton.disabled = True
def _exitApp(self, data=None) :
self.exitApp = True
def __init__(self, synth) :
distinctNotes = []
+ self.currentColumn = None
for midi in self.scale :
tone = Tone(midi)
distinctNotes.append(tone)
super(PlayingScreen, self).__init__(synth, distinctNotes)
- @event_handler(events.NOTEON)
- def noteon(self, evt) :
- tone = evt.tone
- self.synth.noteon(0, tone.midi, 96)
-
- @event_handler(events.NOTEOFF)
- def noteoff(self, evt) :
- tone = evt.tone
- self.synth.noteoff(0, tone.midi)
+ @event_handler(events.COLDOWN)
+ def noteon(self, event) :
+ col = event.column
+ col.update(True)
+ self.currentColumn = col
+ self.playnote(col, event.pos)
+ @event_handler(events.COLUP)
+ def noteoff(self, event) :
+ if self.currentColumn :
+ self.currentColumn.update(False)
+ self.synth.noteoff(0, self.currentColumn.tone.midi)
+
class SongPlayingScreen(PlayingScreenBase) :