Ajout du mode débutant.
[minwii.git] / src / app / event_pprinters.py
1 # -*- coding: utf-8 -*-
2 """
3 formatage des événements
4
5 $Id$
6 $URL$
7 """
8
9 from events import eventNames
10 import sys
11 self = sys.modules[__name__]
12
13 def log_NOTEON(e):
14 return '%3d %3d %3d' % (e.chan, e.key, e.vel)
15
16 def log_NOTEOFF(e):
17 return '%3d %3d' % (e.chan, e.key)
18
19 def log_NOTEEND(e):
20 return ''
21
22 def log_COLSTATECHANGE(e):
23 col = e.column
24 tone = col.tone
25 return u'%2d %5s %3s %3s %s' % \
26 (col.index, e.state, tone.midi, tone.name, e.syllabus)
27
28 def _log_col(e) :
29 """ formate les événements de colonne COLDOWN, COLUP, COLOVER
30 - etat
31 - index de colonne
32 - hauteur midi
33 - nom de la note /A-G[#b]?/
34 """
35 col = e.column
36 tone = col.tone
37 pos = e.pos
38 return u'%2d %5s %3s %3s %r' % \
39 (col.index, col.state, tone.midi, tone.name, pos)
40
41 log_COLDOWN = log_COLUP = log_COLOVER = _log_col
42
43 def log_default(e) :
44 return str(e)
45
46 pprinters = {}
47 for type, name in eventNames.items() :
48 f = getattr(self, 'log_%s' % name, log_default)
49 pprinters[type] = f
50
51 __all__ = ('pprinters')