Ejemplo n.º 1
0
 def set_base_color(self, liveRGBcolor):
     rgbColor = _liveOsTools.colorsys.hex2rgb(liveRGBcolor)
     hsvColor = _liveOsTools.colorsys.rgb_to_hsv(rgbColor[0] / 255.0, rgbColor[1] / 255.0, rgbColor[2] / 255.0)
     log(__name__, "new base color: rgb=" + str(rgbColor) + ", hsv=" + str(hsvColor))
     self.hsv_fader.set_base_color(hsvColor[0], hsvColor[1], hsvColor[2])
     self.send_base_color()
     
     
Ejemplo n.º 2
0
 def set_base_color(self, liveRGBcolor):
     rgbColor = _liveOsTools.colorsys.hex2rgb(liveRGBcolor)
     hsvColor = _liveOsTools.colorsys.rgb_to_hsv(rgbColor[0] / 255.0,
                                                 rgbColor[1] / 255.0,
                                                 rgbColor[2] / 255.0)
     log(__name__,
         "new base color: rgb=" + str(rgbColor) + ", hsv=" + str(hsvColor))
     self.hsv_fader.set_base_color(hsvColor[0], hsvColor[1], hsvColor[2])
     self.send_base_color()
Ejemplo n.º 3
0
 def update_positions(self):
     # TODO some smoothing here
     beatTime = self.song().get_current_beats_song_time()
     play_position = (beatTime.bars - 1) * 16 + (beatTime.beats - 1) * 4 + (
         beatTime.sub_division - 1)
     new_step_position = int(play_position * self.quantization) % self.steps
     if self.step_position != new_step_position:
         self.on_step_position_changed(new_step_position)
         log(
             __name__, "play_position in beats: " + str(play_position) +
             "..... calculated :gridIndex(" + str(self.step_position) + ")")
Ejemplo n.º 4
0
 def setPeer(self, msg, source):
     """
     Reconfigure the client side to the address and port indicated
     as the argument.  The first argument is a string with the host
     address or an empty string if the IP address of the sender of
     the reconfiguration message should be used as peer.  The
     second argument is the integer port number of the peer.
     """
     host = msg[2]
     if host == '':
         host = source[0]
     port = msg[3]
     log('reconfigure to send to ' + host + ':' + str(port))
     self.remoteAddr = (host, port)
Ejemplo n.º 5
0
 def setPeer(self, msg, source):
     """
     Reconfigure the client side to the address and port indicated
     as the argument.  The first argument is a string with the host
     address or an empty string if the IP address of the sender of
     the reconfiguration message should be used as peer.  The
     second argument is the integer port number of the peer.
     """
     host = msg[2]
     if host == '':
         host = source[0]
     port = msg[3]
     log('reconfigure to send to ' + host + ':' + str(port))
     self.remoteAddr = (host, port)
Ejemplo n.º 6
0
 def __init__(self, is_momentary, msg_type, identifier, hsvChannels, controlChannel, rgbColor, name):
     log(True, __name__)                
     ButtonElement.__init__(self, is_momentary, msg_type, controlChannel, identifier) 
     self.name = name + " Control"
     # create 3 buttons for HSV
     self.hueButton = ButtonElement(is_momentary, msg_type, hsvChannels[0], identifier)
     self.satButton = ButtonElement(is_momentary, msg_type, hsvChannels[1], identifier)
     self.valButton = ButtonElement(is_momentary, msg_type, hsvChannels[2], identifier)
     self.id = identifier
     # color
     self.hsv_fader = None
     rgbColor = _liveOsTools.colorsys.hex2rgb(rgbColor)
     hsvColor = _liveOsTools.colorsys.rgb_to_hsv(rgbColor[0] / 255.0, rgbColor[1] / 255.0, rgbColor[2] / 255.0)
     self.hsv_fader = HSVFader(hsvColor[0], hsvColor[1], hsvColor[2])
     self.send_current_color()
     log(False, __name__)
Ejemplo n.º 7
0
 def __init__(self, is_momentary, type, cc_values, hsv_channels, control_channel, fullColor, track): #@ReservedAssignment
     log(True, __name__)
     # basic init                
     ControlSurfaceComponent.__init__(self) 
     self.buttons = []
     self.track = track
     self.cc_values = cc_values
     # button init
     for buttonIndex in range(4):
         f1Button = F1ColorButtonElement(is_momentary, type, 
                                         self.cc_values[buttonIndex], 
                                         hsv_channels, control_channel, 
                                         fullColor, "CC-" + str(self.cc_values[buttonIndex]))
         self.buttons.append(f1Button)
     # listener
     self.remove_listener()
     self.add_listener()
     log(False, __name__)
Ejemplo n.º 8
0
 def __init__(self, is_momentary, type, cc_values, hsv_channels,
              control_channel, fullColor, track):  #@ReservedAssignment
     log(True, __name__)
     # basic init
     ControlSurfaceComponent.__init__(self)
     self.buttons = []
     self.track = track
     self.cc_values = cc_values
     # button init
     for buttonIndex in range(4):
         f1Button = F1ColorButtonElement(
             is_momentary, type, self.cc_values[buttonIndex], hsv_channels,
             control_channel, fullColor,
             "CC-" + str(self.cc_values[buttonIndex]))
         self.buttons.append(f1Button)
     # listener
     self.remove_listener()
     self.add_listener()
     log(False, __name__)
Ejemplo n.º 9
0
    def __init__(
        self,
        remoteHost='192.168.178.19',
        remotePort=8000,
        localHost='192.168.178.23',
        localPort=8000,
    ):
        """
        This is the main class we the use as a nexus point in this module.

        - remoteHost and remotePort define the address of the peer
          that we send data to by default.  It can be changed, at run
          time, using the /remix/set_peer OSC message.

        - localHost and localPort define the address that we are
          listening to for incoming OSC packets.  By default, we are
          listening on all interfaces with port 9000.
        
        By default we define and set callbacks for some utility
        addresses:
        
        /remix/echo - Echos back the string argument to the peer.
        /remix/time - Returns time.time() (time in float seconds)
        /remix/set_peer - Reconfigures the peer address which we send OSC messages to
        """

        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.socket.setblocking(0)
        self.localAddr = (localHost, localPort)
        self.socket.bind(self.localAddr)

        self.remoteAddr = (remoteHost, remotePort)

        log('OSCEndpoint starting, local address ' + str(self.localAddr) +
            ' remote address ' + str(self.remoteAddr))

        # Create our callback manager and register some utility
        # callbacks

        self.callbackManager = OSC.CallbackManager()
        self.callbackManager.add('/remix/echo', self.callbackEcho)
        self.callbackManager.add('/remix/time', self.callbackEcho)
        self.callbackManager.add('/remix/set_peer', self.setPeer)
Ejemplo n.º 10
0
 def __init__(self, steps, buttonColumns, quant_buttons):
     log(True, __name__)
     log(
         __name__, "init: steps(" + str(steps) + "), buttonColumns(" +
         str(buttonColumns) + "), " + str(quant_buttons) + ")")
     ControlSurfaceComponent.__init__(self)
     # button rows
     self.buttonCols = None
     self.set_button_cols(buttonColumns)
     # grid positions
     self.step_position = 0
     self.steps = steps
     # quantization
     self.quantization_index = 0
     self.quantization = QUANTIZATION_MAP[self.quantization_index]
     self.quantization_buttons = [None, None, None]
     self.set_quantization_buttons(quant_buttons)
     # trigger clip
     self.trigger_clip = None
     """ HACK """
     #self.trigger_clip = self.song().visible_tracks[10].clip_slots[0].clip
     #self.trigger_clip.add_playing_position_listener(self.clip_pos)
     #log("CLIP: " + str(self.trigger_clip.name))
     """ HACK END """
     #self.find_trigger_slot(TRIGGER_CLIPNAME)
     log(False, __name__)
Ejemplo n.º 11
0
 def __init__(self, is_momentary, msg_type, identifier, hsvChannels,
              controlChannel, rgbColor, name):
     log(True, __name__)
     ButtonElement.__init__(self, is_momentary, msg_type, controlChannel,
                            identifier)
     self.name = name + " Control"
     # create 3 buttons for HSV
     self.hueButton = ButtonElement(is_momentary, msg_type, hsvChannels[0],
                                    identifier)
     self.satButton = ButtonElement(is_momentary, msg_type, hsvChannels[1],
                                    identifier)
     self.valButton = ButtonElement(is_momentary, msg_type, hsvChannels[2],
                                    identifier)
     self.id = identifier
     # color
     self.hsv_fader = None
     rgbColor = _liveOsTools.colorsys.hex2rgb(rgbColor)
     hsvColor = _liveOsTools.colorsys.rgb_to_hsv(rgbColor[0] / 255.0,
                                                 rgbColor[1] / 255.0,
                                                 rgbColor[2] / 255.0)
     self.hsv_fader = HSVFader(hsvColor[0], hsvColor[1], hsvColor[2])
     self.send_current_color()
     log(False, __name__)
Ejemplo n.º 12
0
    def __init__(self, remoteHost='192.168.178.19', remotePort=8000, localHost='192.168.178.23', localPort=8000,):    
        """
        This is the main class we the use as a nexus point in this module.

        - remoteHost and remotePort define the address of the peer
          that we send data to by default.  It can be changed, at run
          time, using the /remix/set_peer OSC message.

        - localHost and localPort define the address that we are
          listening to for incoming OSC packets.  By default, we are
          listening on all interfaces with port 9000.
        
        By default we define and set callbacks for some utility
        addresses:
        
        /remix/echo - Echos back the string argument to the peer.
        /remix/time - Returns time.time() (time in float seconds)
        /remix/set_peer - Reconfigures the peer address which we send OSC messages to
        """

        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.socket.setblocking(0)
        self.localAddr = (localHost, localPort)
        self.socket.bind(self.localAddr)

        self.remoteAddr = (remoteHost, remotePort)

        log('OSCEndpoint starting, local address ' + str(self.localAddr) + ' remote address ' + str(self.remoteAddr))
        
        # Create our callback manager and register some utility
        # callbacks
        
        self.callbackManager = OSC.CallbackManager()
        self.callbackManager.add('/remix/echo', self.callbackEcho)
        self.callbackManager.add('/remix/time', self.callbackEcho)
        self.callbackManager.add('/remix/set_peer', self.setPeer)
Ejemplo n.º 13
0
    def update_display(self):
        """
        This function is run every 100ms, so we use it to initiate our Song.current_song_time
        listener to allow us to process incoming OSC commands as quickly as possible under
        the current listener scheme.
        """
        ######################################################
        # START OSC LISTENER SETUP

        if self.basicAPI == 0:
            # By default we have set basicAPI to 0 so that we can assign it after
            # initialization. We try to get the current song and if we can we'll
            # connect our basicAPI callbacks to the listener allowing us to
            # respond to incoming OSC every 60ms.
            #
            # Since this method is called every 100ms regardless of the song time
            # changing, we use both methods for processing incoming UDP requests
            # so that from a resting state you can initiate play/clip triggering.

            try:
                doc = self.song()
            except:
                log('could not get song handle')
                return
            try:
                self.basicAPI = LiveOSCCallbacks.LiveOSCCallbacks(
                    self._LiveOSC__c_instance, self.oscEndpoint)
                # Commented for stability
                self.time = 0
                doc.add_current_song_time_listener(
                    self.current_song_time_changed)
            except:
                self.oscEndpoint.send('/remix/echo',
                                      'setting up basicAPI failed')
                log('setting up basicAPI failed')
                return

            # If our OSC server is listening, try processing incoming requests.
            # Any 'play' initiation will trigger the current_song_time listener
            # and bump updates from 100ms to 60ms.

        if self.oscEndpoint:
            try:
                self.oscEndpoint.processIncomingUDP()
            except:
                log('error processing incoming UDP packets:', sys.exc_info())
Ejemplo n.º 14
0
    def update_display(self):
        """
        This function is run every 100ms, so we use it to initiate our Song.current_song_time
        listener to allow us to process incoming OSC commands as quickly as possible under
        the current listener scheme.
        """
        ######################################################
        # START OSC LISTENER SETUP
              
        if self.basicAPI == 0:
            # By default we have set basicAPI to 0 so that we can assign it after
            # initialization. We try to get the current song and if we can we'll
            # connect our basicAPI callbacks to the listener allowing us to 
            # respond to incoming OSC every 60ms.
            #
            # Since this method is called every 100ms regardless of the song time
            # changing, we use both methods for processing incoming UDP requests
            # so that from a resting state you can initiate play/clip triggering.

            try:
                doc = self.song()
            except:
                log('could not get song handle')
                return
            try:
                self.basicAPI = LiveOSCCallbacks.LiveOSCCallbacks(self._LiveOSC__c_instance, self.oscEndpoint)
                # Commented for stability
                self.time = 0
                doc.add_current_song_time_listener(self.current_song_time_changed)
            except:
                self.oscEndpoint.send('/remix/echo', 'setting up basicAPI failed')
                log('setting up basicAPI failed');
                return
            
            # If our OSC server is listening, try processing incoming requests.
            # Any 'play' initiation will trigger the current_song_time listener
            # and bump updates from 100ms to 60ms.
            
        if self.oscEndpoint:
            try:
                self.oscEndpoint.processIncomingUDP()
            except:
                log('error processing incoming UDP packets:', sys.exc_info());
Ejemplo n.º 15
0
 def button_pressed(self, value, sender):
     log(
         __name__,
         "button_pressed: value(" + str(value) + "), buttonName(" +
         str(sender.name) + "), senderOBJ(" + str(sender) + ")")
Ejemplo n.º 16
0
 def update(self):
     log(__name__, "update")
Ejemplo n.º 17
0
 def disconnect(self):
     log(__name__, "disconnect")
     self.remove_listener()
     self.buttons = None
     self.track = None
Ejemplo n.º 18
0
 def __init__(self, hue, sat, val):
     log(True, __name__)
     self.current_color = [hue, sat, val]
     self.set_base_color(hue, sat, val)
     self.target_rel = []
     log(False, __name__)
Ejemplo n.º 19
0
 def process(self, frame_duration):
     log(__name__, "process")
     self.update()
     self.update_positions()
Ejemplo n.º 20
0
 def set_button_cols(self, buttonCols):
     assert (self.buttonCols == None)
     log(__name__, "set_button_cols: " + str(buttonCols))
     for col in buttonCols:
         assert isinstance(col, (F1ButtonColumn, type(None)))
     self.buttonCols = buttonCols
Ejemplo n.º 21
0
 def disconnect(self):
     log(__name__, "disconnect")
     self.hueButton = None
     self.hsvColor = None
     self.satButton = None
     self.hsv_fader = None
Ejemplo n.º 22
0
 def disconnect(self):
     log(__name__, "disconnect")
     if (self.song().current_song_time_has_listener(self.update)):
         self.song().remove_current_song_time_listener(self.update)
     self.set_quantization_buttons([None, None, None])
     self.quantization_buttons = None
Ejemplo n.º 23
0
 def __init__(self, hue, sat, val):
     log(True, __name__) 
     self.current_color = [hue, sat, val]               
     self.set_base_color(hue, sat, val)
     self.target_rel = []
     log(False, __name__)
Ejemplo n.º 24
0
 def disconnect(self):
     log(__name__, "disconnect")
     self.remove_listener()
     self.buttons = None
     self.track = None
Ejemplo n.º 25
0
 def update(self):
     log(__name__, "update")        
Ejemplo n.º 26
0
 def disconnect(self):
     log(__name__, "disconnect")
     self.hueButton = None
     self.hsvColor = None
     self.satButton = None
     self.hsv_fader = None     
Ejemplo n.º 27
0
 def button_pressed(self, value, sender):
     log(__name__, "button_pressed: value(" + str(value) + "), buttonName("+ str(sender.name) + "), senderOBJ(" + str(sender) + ")")
Ejemplo n.º 28
0
 def track_color_callback(self):
     log(__name__, "track_color_callback for row: " + str(self.cc_values))
     self.set_base_colors(self.track.color)
Ejemplo n.º 29
0
 def track_color_callback(self):
     log(__name__, "track_color_callback for row: " + str(self.cc_values))
     self.set_base_colors(self.track.color)
Ejemplo n.º 30
0
 def clip_pos(self):
     #log("clipPosChanged. position: " + str(self.trigger_clip.playing_position))
     log("CLIP: time " + str(str(int(time.time() * 4) % 4)))
Ejemplo n.º 31
0
 def process(self):
     current_time = time.time()
     log("TIMER: time " + str(int(current_time*4)%4))