/bmevent.py
BME_BGM = 0x01
BME_TEMPO = 0x02
BME_BGA = 0x04
BME_CHPOOR = 0x08
BME_NOTE1 = 0x10
BME_NOTE2 = 0x20
BME_HIT = 0x40
BME_STOP = 0x80
BME_LONGMEASURE = 0x100

class BMEvent:
	def __init__(self,beat,type,key=None,dataref=None):
		self.beat = beat
		self.type = type
		self.key = key
		self.dataref = dataref

	def __str__(self):
		s = "BMEvent:\n"
		s += "   beat=" + str(self.beat) + "\n"
		t = { BME_BGM:		"BGM",
		      BME_TEMPO:	"TEMPO",
		      BME_BGA:		"BGA",
		      BME_CHPOOR:	"CHANGE POOR",
		      BME_NOTE1:	"NOTE P1",
		      BME_NOTE2:	"NOTE P2"
		    }[self.type]
		s += "   type=" + t + "\n"
		if self.key:
			s += "   key=" + str(self.key) + "\n"
		if self.dataref:
			try:
				s += "   dataref=" + hex(self.dataref) + "\n"
			except TypeError:
				s += "   dataref=" + str(self.dataref) + "\n"
		return s