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 ''
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 :
@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)
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
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)
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
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