示例#1
0
class OscPanelView(ui.View):
    def __init__(self):
        self.client = ThreadedClient(OSC_HOST, OSC_PORT)
        self._osc_active = False
        self.program = None

    def did_load(self):
        self.create_gui()
        self.client.start()

    def will_close(self):
        self.client.close()

    def create_gui(self):
        self.btn_osc_activity = ui.ButtonItem(
            image=ICONS["osc_inactive"], enabled=False
        )
        self.right_button_items = [self.btn_osc_activity]
        for y in range(NROWS):
            for x in range(NCOLS):
                self.add_button(x, y, self.button_activated)

    def add_button(self, x, y, handler):
        self.add_subview(OscButton(x, y, handler))

    def osc_active(self):
        if not self._osc_active:
            self._osc_active = True
            self.btn_osc_activity.image = ICONS["osc_active"]
            ui.delay(self.osc_inactive, 0.1)

    def osc_inactive(self):
        if self._osc_active:
            self._osc_active = False
            self.btn_osc_activity.image = ICONS["osc_inactive"]

    def button_activated(self, sender):
        self.osc_active()
        log.info("Program: %02i" % sender.value)

        if sender.value != self.program:
            self.program = sender.value
            try:
                self.client.send("/midi", ("m", (0, 0xC0, self.program, 0)))
            except Exception as exc:
                import traceback

                traceback.print_exc()
示例#2
0
class OscPanelView(ui.View):
    def __init__(self):
        self.client = ThreadedClient(OSC_HOST, OSC_PORT)
        self._osc_active = False
        self.program = None

    def did_load(self):
        self.create_gui()
        self.client.start()

    def will_close(self):
        self.client.close()

    def create_gui(self):
        self.btn_osc_activity = ui.ButtonItem(image=ICONS["osc_inactive"], enabled=False)
        self.right_button_items = [self.btn_osc_activity]
        for y in range(NROWS):
            for x in range(NCOLS):
                self.add_button(x, y, self.button_activated)

    def add_button(self, x, y, handler):
        self.add_subview(OscButton(x, y, handler))

    def osc_active(self):
        if not self._osc_active:
            self._osc_active = True
            self.btn_osc_activity.image = ICONS["osc_active"]
            ui.delay(self.osc_inactive, 0.1)

    def osc_inactive(self):
        if self._osc_active:
            self._osc_active = False
            self.btn_osc_activity.image = ICONS["osc_inactive"]

    def button_activated(self, sender):
        self.osc_active()
        log.info("Program: %02i" % sender.value)

        if sender.value != self.program:
            self.program = sender.value
            try:
                self.client.send("/midi", ("m", (0, 0xC0, self.program, 0)))
            except Exception as exc:
                import traceback

                traceback.print_exc()
示例#3
0
 def __init__(self):
     self.client = ThreadedClient(OSC_HOST, OSC_PORT)
     self._osc_active = False
     self.program = None
示例#4
0
 def __init__(self):
     self.client = ThreadedClient(OSC_HOST, OSC_PORT)
     self._osc_active = False
     self.program = None