From: pin Date: Fri, 16 Apr 2010 13:37:35 +0000 (+0000) Subject: implémentation des fonction de pretty-print des événements spécifiques minwii. X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/commitdiff_plain/49c528b6d2cdaa39e08e00ccfa74a60751f8640a?ds=inline implémentation des fonction de pretty-print des événements spécifiques minwii. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@146 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/app/event_pprinters.py b/src/app/event_pprinters.py index 76e468c..679924e 100755 --- a/src/app/event_pprinters.py +++ b/src/app/event_pprinters.py @@ -10,12 +10,35 @@ from events import eventNames import sys self = sys.modules[__name__] -def log_COLDOWN(e) : - tone = e.column.tone - return '%s (%s)' % (tone.midi, tone.nom) +def log_NOTEON(e): + return '' + +def log_NOTEOFF(e): + return '' + +def log_NOTEEND(e): + return '' + +def log_COLSTATECHANGE(e): + col = e.column + tone = col.tone + return u'%2d %5s %3s %3s %s' % \ + (col.index, col.state, tone.midi, tone.name, e.syllabus) + +def _log_col(e) : + """ formate l'événement + - etat + - index de colonne + - hauteur midi + - nom de la note /A-G[#b]?/ + """ + col = e.column + tone = col.tone + pos = e.pos + return u'%2d %5s %3s %3s %r' % \ + (col.index, col.state, tone.midi, tone.name, pos) -def log_COLSTATECHANGE(e) : - return u'%5s %s' % (e.state, e.syllabus) +log_COLDOWN = log_COLUP = log_COLOVER = _log_col def log_default(e) : return '' diff --git a/src/app/musicxml.py b/src/app/musicxml.py index ec3be4a..0ed7085 100755 --- a/src/app/musicxml.py +++ b/src/app/musicxml.py @@ -153,16 +153,16 @@ class Part(object) : else : iterable = cycle(self.verses) for verse in iterable : - print "---partie---" + #print "---partie---" repeats = len(verse[0].lyrics) if repeats > 1 : for i in range(repeats) : # couplet - print "---couplet%d---" % i + #print "---couplet%d---" % i for note in verse : yield note, i # refrain - print "---refrain---" + #print "---refrain---" for note in self.chorus : yield note, 0 else : @@ -242,9 +242,9 @@ class Tone(object) : @property def name(self) : - name = '%s%d' % (self.step, self.octave) + name = u'%s%d' % (self.step, self.octave) if self.alter < 0 : - alterext = '♭' + alterext = 'b' else : alterext = '#' name = '%s%s' % (name, abs(self.alter) * alterext) diff --git a/src/app/widgets/column.py b/src/app/widgets/column.py index 31266c8..d48dfde 100755 --- a/src/app/widgets/column.py +++ b/src/app/widgets/column.py @@ -24,9 +24,12 @@ import events class Column(pygame.sprite.DirtySprite) : + ''' colonne utilisée pour l'affichage d'une touche du clavier de jeu. + ''' - def __init__(self, group, hue, rect, tone) : + def __init__(self, group, index, hue, rect, tone) : pygame.sprite.DirtySprite.__init__(self, group) + self.index = index self.state = False # nom de l'intonation @@ -100,5 +103,5 @@ class Column(pygame.sprite.DirtySprite) : self.state = state self.dirty = 1 - evt = pygame.event.Event(events.COLSTATECHANGE, col=self, state=state, syllabus=syllabus) + evt = pygame.event.Event(events.COLSTATECHANGE, column=self, syllabus=syllabus) pygame.event.post(evt) diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py index ec96536..47898fa 100755 --- a/src/app/widgets/playingscreen.py +++ b/src/app/widgets/playingscreen.py @@ -76,7 +76,7 @@ class _PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : for i, rect in enumerate(self.keyboardRects) : hue = FIRST_HUE - hueStep * i tone = self.distinctNotes[i] - c = Column(self, hue, rect, tone) + c = Column(self, i, hue, rect, tone) self.add(c, layer=BACKGROUND_LAYER) self.columns[tone.midi] = c @@ -94,7 +94,7 @@ class _PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : EventDispatcher.dispatchEvents() dirty = self.draw(pygame.display.get_surface()) pygame.display.update(dirty) - clock.tick(FRAMERATE) + clock.tick()#FRAMERATE) def stop(self) : self._running = False