From: pin Date: Mon, 8 Mar 2010 16:03:10 +0000 (+0000) Subject: c'est bof... on va essayer autre chose. X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/commitdiff_plain/ccd80f6896303234addbb0f619335b6e59df7746 c'est bof... on va essayer autre chose. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@83 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/app/events.py b/src/app/events.py index 149c2ff..dd6ac47 100755 --- a/src/app/events.py +++ b/src/app/events.py @@ -2,3 +2,5 @@ from pygame.locals import USEREVENT TIMEOUT = USEREVENT + 1 NOTEON = USEREVENT + 2 NOTEOFF = USEREVENT + 3 +KEYDOWN = USEREVENT + 4 +KEYUP = USEREVENT + 5 diff --git a/src/app/widgets/column.py b/src/app/widgets/column.py index a5001d3..c0d8455 100755 --- a/src/app/widgets/column.py +++ b/src/app/widgets/column.py @@ -89,24 +89,33 @@ class Column(pygame.sprite.DirtySprite, EventHandlerMixin) : self.state = state self.dirty = 1 - @event_handler(pygame.MOUSEBUTTONDOWN) + #@event_handler(pygame.MOUSEBUTTONDOWN) def onMouseDown(self, event) : - if self.rect.collidepoint(*event.pos) : - self.update(True) - self.raiseNoteOn() + if self.rect.collidepoint(*event.pos) and self.state : + self.raiseKeyDown() @event_handler(pygame.MOUSEBUTTONUP) def onMouseUp(self, event) : - self.update(False) - self.raiseNoteOff() + self.raiseKeyUp() - def raiseNoteOn(self) : - evt = pygame.event.Event(events.NOTEON, tone=self.tone) + def raiseKeyDown(self) : + evt = pygame.event.Event(events.KEYDOWN, column=self) pygame.event.post(evt) + print 'down', self.tone.nom - def raiseNoteOff(self) : - evt = pygame.event.Event(events.NOTEOFF, tone=self.tone) - pygame.event.post(evt) + def raiseKeyUp(self) : + if self.state : + evt = pygame.event.Event(events.KEYUP, column=self) + pygame.event.post(evt) + print 'up', self.tone.nom + +# def raiseNoteOn(self) : +# evt = pygame.event.Event(events.NOTEON, tone=self.tone) +# pygame.event.post(evt) +# +# def raiseNoteOff(self) : +# evt = pygame.event.Event(events.NOTEOFF, tone=self.tone) +# pygame.event.post(evt) diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py index 8ded80d..9f84ee5 100755 --- a/src/app/widgets/playingscreen.py +++ b/src/app/widgets/playingscreen.py @@ -135,22 +135,27 @@ class SongPlayingScreen(_PlayingScreenBase) : def __init__(self, synth, song, mode=PLAYING_MODES['NORMAL']) : super(SongPlayingScreen, self).__init__(synth, song.distinctNotes) self.song = song + self.currentColumn = None self.noteIterator = self.song.iterNotes() - self.play() + self.displayNext() - def play(self) : + def displayNext(self) : + if self.currentColumn: + self.currentColumn.update(False) note, verseIndex = self.noteIterator.next() - syllabus = note.lyrics[verseIndex].syllabus() + syllabus = note.lyrics[verseIndex].syllabus(encoding="iso-8859-1") column = self.columns[note.midi] column.update(True, syllabus) + self.currentColumn = column + @event_handler(events.KEYDOWN) + def handleKeyDown(self, event) : + col = event.column + if col == self.currentColumn: + self.synth.noteon(0, col.tone.midi, DEFAULT_MIDI_VELOCITY) - @event_handler(events.NOTEON) - def noteon(self, evt) : - tone = evt.tone - self.synth.noteon(0, tone.midi, DEFAULT_MIDI_VELOCITY) - - @event_handler(events.NOTEOFF) - def noteoff(self, evt) : - tone = evt.tone - self.synth.noteoff(0, tone.midi) + @event_handler(events.KEYUP) + def handleKeyUp(self, event) : + self.synth.noteoff(0, self.currentColumn.tone.midi) + self.displayNext() + \ No newline at end of file