Initial commit from version 1e-99
[beatscape.git] / bmevent.py
1 BME_BGM = 0x01
2 BME_TEMPO = 0x02
3 BME_BGA = 0x04
4 BME_CHPOOR = 0x08
5 BME_NOTE1 = 0x10
6 BME_NOTE2 = 0x20
7 BME_HIT = 0x40
8 BME_STOP = 0x80
9 BME_LONGMEASURE = 0x100
10
11 class BMEvent:
12         def __init__(self,beat,type,key=None,dataref=None):
13                 self.beat = beat
14                 self.type = type
15                 self.key = key
16                 self.dataref = dataref
17
18         def __str__(self):
19                 s = "BMEvent:\n"
20                 s += "   beat=" + str(self.beat) + "\n"
21                 t = { BME_BGM:          "BGM",
22                       BME_TEMPO:        "TEMPO",
23                       BME_BGA:          "BGA",
24                       BME_CHPOOR:       "CHANGE POOR",
25                       BME_NOTE1:        "NOTE P1",
26                       BME_NOTE2:        "NOTE P2"
27                     }[self.type]
28                 s += "   type=" + t + "\n"
29                 if self.key:
30                         s += "   key=" + str(self.key) + "\n"
31                 if self.dataref:
32                         try:
33                                 s += "   dataref=" + hex(self.dataref) + "\n"
34                         except TypeError:
35                                 s += "   dataref=" + str(self.dataref) + "\n"
36                 return s