def run(self, options): """ Runs the application. 'options' contains the CLI options dictionary. """ # Setup logging if options.debug: Logger.set_log_level(Logger.DEBUG) # Load configuration self.config = ConfigParser.RawConfigParser() self.config.read(options.config) MidiEngine.initialize() Logger.debug("Command line options: %s" % (options)) self.setup() if options.list_devices: self.list_devies() elif options.interactive: self.interactive_mode() else: self.loop()
def __init__(self, name, input, output, channel): Logger.debug("[%s] Initializing channel: input='%s', output='%s, channel=%d" % (name, input, output, channel)) self.name = name self.input = MidiEngine.get_input_by_name(input) self.output = MidiEngine.get_output_by_name(output) self.channel = channel self.receive = None if self.input: self.input.receive = self.__receive
def __receive(self, input, msg): # Filter message if it does not belong to the configured MIDI channel if msg.getChannel() != self.channel: return Logger.debug("[%s] Received message: %s" % (self.name, MidiEngine.dump_msg(msg))) # Dispatch received message if self.receive: self.receive(self, msg)
def send(self, msg): # Override MIDI channel msg.setChannel(self.channel) Logger.debug("[%s] Sending message: %s" % (self.name, MidiEngine.dump_msg(msg))) if self.output: self.output.send(msg)