def __init__(self, osc_writer=None, parent=None):
        self.osc_writer = osc_writer
        self.parent = parent

        if self.osc_writer == None:
            self.osc_writer = OscWriter()

        self.setup()
Example #2
0
 def setup(self):
     # clean existing mess before we start creating a mess
     self.destroy()
     # let's make a mess
     if self.manager == None:
         self.manager = Manager()
     self.writer = OscWriter(host=self.osc_host,
                             port=self.osc_port,
                             manager=self.manager)
     self.reader = JsonReader(self.json_file, manager=self.manager)
Example #3
0
class RecordingPlayer:
    def __init__(self,
                 json_file='../data/sampleRecording2.json',
                 osc_host='127.0.0.1',
                 osc_port=8080,
                 manager=None,
                 autoStart=False):
        # config
        self.json_file = json_file
        self.osc_host = osc_host
        self.osc_port = osc_port
        self.manager = manager
        self.reader = None
        self.writer = None

        if autoStart:
            self.start()

    def setup(self):
        # clean existing mess before we start creating a mess
        self.destroy()
        # let's make a mess
        if self.manager == None:
            self.manager = Manager()
        self.writer = OscWriter(host=self.osc_host,
                                port=self.osc_port,
                                manager=self.manager)
        self.reader = JsonReader(self.json_file, manager=self.manager)

    def destroy(self):
        if self.reader:
            self.reader.stop()
            self.reader = None
        if self.writer:
            self.writer.stop()
            self.writer = None
        if self.manager:
            self.manager = None

    def update(self):
        if self.reader:
            self.reader.update()

    def start(self):
        self.setup()

    def stop(self):
        self.destroy()

    def status(self):
        if self.reader != None:
            return 'playing'
        return 'stopped'
Example #4
0
class RecordingPlayer:
    def __init__(self, json_file='data/sampleRecording2.json', osc_host='127.0.0.1', osc_port=8080, manager=None, autoStart=False):
        # config
        self.json_file = json_file
        self.osc_host = osc_host
        self.osc_port = osc_port
        self.manager = manager
        self.reader = None
        self.writer = None

        if autoStart:
            self.start()

    def setup(self):
        # clean existing mess before we start creating a mess
        self.destroy()
        # let's make a mess
        if self.manager == None:
            self.manager = Manager()
        self.writer = OscWriter(host=self.osc_host, port=self.osc_port, manager=self.manager)
        self.reader = JsonReader(self.json_file, manager=self.manager)

    def destroy(self):
        if self.reader:
            self.reader.stop()
            self.reader = None
        if self.writer:
            self.writer.stop()
            self.writer = None
        if self.manager:
            self.manager = None

    def update(self):
        if self.reader:
            self.reader.update()

    def start(self):
        self.setup()

    def stop(self):
        self.destroy()

    def status(self):
        if self.reader != None:
            return 'playing'
        return 'stopped'
Example #5
0
 def setup(self):
     # clean existing mess before we start creating a mess
     self.destroy()
     # let's make a mess
     if self.manager == None:
         self.manager = Manager()
     self.writer = OscWriter(host=self.osc_host, port=self.osc_port, manager=self.manager)
     self.reader = JsonReader(self.json_file, manager=self.manager)
Example #6
0
    def __init__(self, osc_writer=None, parent=None):
        self.osc_writer = osc_writer
        self.parent = parent

        if self.osc_writer == None:
            self.osc_writer = OscWriter()

        self.setup()
class OscWriterView:
    def __init__(self, osc_writer=None, parent=None):
        self.osc_writer = osc_writer
        self.parent = parent

        if self.osc_writer == None:
            self.osc_writer = OscWriter()

        self.setup()

    def setup(self):
        # create gui-elements
        self.frame = tk.LabelFrame(self.parent,
                                   text='OSC Forwarding',
                                   padx=10,
                                   pady=10)
        self.frame.grid()

        self.host_label = tk.Label(self.frame, text="OSC Host")
        self.host_entry = tk.Entry(self.frame, width=10)
        self.port_label = tk.Label(self.frame, text="Port")
        self.port_entry = tk.Entry(self.frame, width=5)
        self.connect_button = tk.Button(self.frame,
                                        text='(re-)connect',
                                        command=self.onConnectButton)
        self.disconnect_button = tk.Button(self.frame,
                                           text='disconnect',
                                           command=self.onDisconnectButton)
        self.status_label = tk.Label(self.frame, text='')

        # position elements
        self.host_label.grid(column=0, row=0)
        self.host_entry.grid(column=1, row=0)
        self.port_label.grid(column=2, row=0)
        self.port_entry.grid(column=3, row=0)
        self.connect_button.grid(column=4, row=0)
        self.disconnect_button.grid(column=5, row=0)
        self.status_label.grid(column=0, row=1, columnspan=6)

        # initialize
        if self.osc_writer:
            self.host_entry.insert(0, self.osc_writer.host)
            self.port_entry.insert(0, self.osc_writer.port)

            self.osc_writer.connectEvent += self.onConnect
            self.osc_writer.disconnectEvent += self.onDisconnect

            self.updateStatus(self.osc_writer)

    #     self.update()
    #
    # def update(self):
    #     timeValue = str(self.json_reader.getTime())
    #     self.time_value_label.configure(text=timeValue)
    #     self.parent.after(1, self.update) # schedule next update (tkinter doesn't seem to provide a nice way to do every-iteration-updates)

    def destroy(self):
        self.frame.grid_forget()

    def onConnectButton(self):
        self.osc_writer.stop()
        self.osc_writer.configure(host=self.host_entry.get(),
                                  port=self.port_entry.get())
        self.osc_writer.start()

    def onDisconnectButton(self):
        self.osc_writer.stop()

    def onConnect(self, osc_writer):
        self.updateStatus(osc_writer)

    def onDisconnect(self, osc_writer):
        self.updateStatus(osc_writer)

    def updateStatus(self, osc_writer):
        if osc_writer.connected == True:
            self.status_label.config(text='Connected to ' +
                                     str(osc_writer.host) + '@' +
                                     str(osc_writer.port))
        else:
            self.status_label.config(text='Disconnected')
Example #8
0
class OscWriterView:
    def __init__(self, osc_writer=None, parent=None):
        self.osc_writer = osc_writer
        self.parent = parent

        if self.osc_writer == None:
            self.osc_writer = OscWriter()

        self.setup()

    def setup(self):
        # create gui-elements
        self.frame = tk.LabelFrame(self.parent, text='OSC Forwarding', padx=10, pady=10)
        self.frame.grid()

        self.host_label = tk.Label(self.frame, text="OSC Host")
        self.host_entry = tk.Entry(self.frame, width=10)
        self.port_label = tk.Label(self.frame, text="Port")
        self.port_entry = tk.Entry(self.frame, width=5)
        self.connect_button = tk.Button(self.frame, text='(re-)connect', command=self.onConnectButton)
        self.disconnect_button = tk.Button(self.frame, text='disconnect', command=self.onDisconnectButton)
        self.status_label = tk.Label(self.frame, text='')

        # position elements
        self.host_label.grid(column=0, row=0)
        self.host_entry.grid(column=1, row=0)
        self.port_label.grid(column=2, row=0)
        self.port_entry.grid(column=3, row=0)
        self.connect_button.grid(column=4, row=0)
        self.disconnect_button.grid(column=5, row=0)
        self.status_label.grid(column=0, row=1, columnspan=6)

        # initialize
        if self.osc_writer:
            self.host_entry.insert(0, self.osc_writer.host)
            self.port_entry.insert(0, self.osc_writer.port)

            self.osc_writer.connectEvent += self.onConnect
            self.osc_writer.disconnectEvent += self.onDisconnect

            self.updateStatus(self.osc_writer)

    #     self.update()
    #
    # def update(self):
    #     timeValue = str(self.json_reader.getTime())
    #     self.time_value_label.configure(text=timeValue)
    #     self.parent.after(1, self.update) # schedule next update (tkinter doesn't seem to provide a nice way to do every-iteration-updates)

    def destroy(self):
        self.frame.grid_forget()

    def onConnectButton(self):
        self.osc_writer.stop()
        self.osc_writer.configure(host=self.host_entry.get(), port=self.port_entry.get())
        self.osc_writer.start()

    def onDisconnectButton(self):
        self.osc_writer.stop()

    def onConnect(self, osc_writer):
        self.updateStatus(osc_writer)

    def onDisconnect(self, osc_writer):
        self.updateStatus(osc_writer)

    def updateStatus(self, osc_writer):
        if osc_writer.connected == True:
            self.status_label.config(text='Connected to '+str(osc_writer.host)+'@'+str(osc_writer.port))
        else:
            self.status_label.config(text='Disconnected')