def setup_osc(): osc.init() OSCConfig.oscid = osc.listen(port=OSCConfig.app_port) Clock.schedule_interval( lambda *x: osc.readQueue(thread_id=OSCConfig.oscid), .5) Logger.info('coordinator: setup osc at ' + str(OSCConfig.app_port)) Logger.info('coordinator: osc id: ' + OSCConfig.oscid)
def build(self): Window.size = (1366, 768) Window.borderless = True Window.fullscreen = True scat = Scatter() # Starts OSC oscAPI.init() # Instanciates OSC listener oscid = oscAPI.listen(ipAddr=self.ip, port=self.port) # listens for osc messages every screen refresh Clock.schedule_interval(lambda *x: oscAPI.readQueue(oscid), 0) # binds messages - this listens to messages if prefix /1/tok oscAPI.bind(oscid, self.token_on, '0') # add a label to the screen root = FloatLayout(size=(2950, 1650), orientation='vertical') #self.label = Label(text="This is our vertical sceen!", font_size='50sp') #root.add_widget(self.label) root_image = Image(source='PauseScreen.png', size_hint_x=None, width=1366, size_hint_y=None, height=768, allow_stretch=True, keep_ratio=True) root.add_widget(root_image) # console message - ready! print "Ready to receive!" #self.receivedegrees(0,0) #self.receivedegrees(90,1) # self.receivedegrees(180) # self.receivedegrees(270) # return root return root
def initialise_osc(self): oscAPI.init() oscid = oscAPI.listen(ipAddr='127.0.0.1', port=osc_listen_port) oscAPI.bind(oscid, self.poem_position_changed, osc_poem_position) oscAPI.bind(oscid, self.rhythm_position_changed, osc_rhythm_position) self.osc_poll = Clock.schedule_interval(lambda *x: oscAPI.readQueue(oscid), 0.01) send_osc_message('/osc/respond_to', [osc_listen_port]) send_osc_message(osc_poem_position, [0.0001], typehint=1.0) send_osc_message(osc_rhythm_position, [0.0001], typehint=1.0)
def listen_osc(self, oscid): while True: osc.readQueue(thread_id=oscid) sleep(.5)