def main(configfile='../default_setup.ini'): # Start the CodeKlavier #Read config and settings config = configparser.ConfigParser() config.read(configfile, encoding='utf8') try: myPort = config['midi'].getint('port') device_id = config['midi'].getint('noteon_id') except KeyError: raise LookupError('Missing key information in the config file.') if (myPort == None or device_id == None): raise LookupError('Missing key information in the config file.') codeK = Setup() tutorial = Instructions() codeK.open_port(myPort) codeK.open_port_out(myPort) # Use your favourite mapping of the keys mapping = Mapping_HelloWorld_NKK() # class to handle the midi input and map it to characters #TODO: this is ugly! Move this to the CodeKlavier module class HelloWorld(object): def __init__(self, port): self.port = port def __call__(self, event, data=None): message, deltatime = event # print(message) if message[2] > 0: #only noteOn if (message[0] == device_id): mapping.mapping(message[1]) codeK.set_callback(HelloWorld(myPort)) tutorial.do_tutorial() codeK.send_message([0x90, 108, 127]) #send enter to codespace tutorial.level_four() # Loop to program to keep listening for midi input try: timer = time.time() while True: time.sleep(0.01) except KeyboardInterrupt: print('') finally: # print("Bye-Bye :(") codeK.end()