import re, sys def emitnote(note, octave, inst, length): rows = 64 / length if note == '.': print "|^^^........" else: print "|%s%d%02d%s" % (note, octave, inst, "...D0F"); for x in range(1,rows): print "|..........." def play(playstr): global length, octave, tempo tokenre = re.compile(r'[><]|[abcdefg][-+]?|[otln]\d+') commands = tokenre.findall(playstr.lower()) for c in commands: if c[0] == 'l': length = int(c[1:]) elif c[0] == '>': octave += 1 elif c[0] == '<': octave -= 1 elif c[0] == 'o': octave = int(c[1:]) + 2 elif c[0] == 't': tempo = int(c[1:]) elif c == 'n0': emitnote('.', octave, 1, length) elif len(c) == 1: emitnote(c[0].upper() + '-', octave, 1, length) elif c[1] == '+': emitnote(c[0].upper() + '#', octave, 1, length) musicre = re.compile(r'\s*PLAY\s*"([^"]+)"\s*\n') print "ModPlug Tracker IT" for line in sys.stdin.readlines(): m = musicre.match(line) if m: play(m.group(1))