Exemplo n.º 1
0
    def __init__(self, handler):
        Interface.__init__(self)

        self.log = logging.getLogger(__name__)

        # Setup handler
        self.log.debug("Setting up handler...")
        handler.set_interface(self)

        # Setup sender
        self.log.debug("Setting up sender...")
        GuiSender.interface = self
        self.sender = GuiSender.get_instance()

        # Setup listener
        self.log.debug("Setting up listener...")
        GuiListener.msg_handler = handler
        GuiListener.interface = self
        self.listener = GuiListener.get_instance()
    def __init__(self, handler):
        Interface.__init__(self)
        self.log = logging.getLogger(__name__)

        # Initialize Launchpad
        self.log.info("Searching for launchpad...")
        pypm.Initialize()
        dev_in, dev_out = LaunchpadInterface.find_launchpad()

        # Check if we found the LP
        if dev_in == -1 or dev_out == -1:
            self.log.error("Could not find the LaunchPad. Did you connect it?")
            sys.exit(1)

        # Setup the connection
        self.midi_in = pypm.Input(dev_in)
        self.midi_out = pypm.Output(dev_out, 0)

        # Switch to index-based layout
        self.midi_out.Write([[[0xB0, 0x00, 0x01], pypm.Time()]])

        # Reset the launchpad
        self.midi_out.Write([[[0xB0, 0x00, 0x00], pypm.Time()]])

        # Setup handler
        self.log.debug("Setting up handler...")
        handler.set_interface(self)

        # Setup sender
        LaunchpadSender.midi_out = self.midi_out
        self.sender = LaunchpadSender.get_instance()

        # Setup listener
        LaunchpadListener.midi_in = self.midi_in
        LaunchpadListener.msg_handler = handler
        LaunchpadListener.interface = self
        self.listener = LaunchpadListener.get_instance()

        self.log.info("Connected to Launchpad and ready to start.")