Example #1
0
 def receive_callback(self, path, value):
     #        if (DEBUG):
     # print("[OSC]    Path: " + path + "   Value: " + str(value))
     pe_bindings.controller_to_parameter(self, path, value)
Example #2
0
    def receive_callback(self, path, value): 

        # Darken the center when gain is high!  This helps to keep
        # things "under control."
        if (pe.decay > 1.01):
            pe.darken_center = 1.0
        else:
            pe.darken_center = 0.0
        

        # -------------------------------------
        # Fixed settings for PRICELESS!!
        # -------------------------------------
    
        # RESET!!
        if (path == "/joystick0/button3" and value == 1): 
            print("Resetting to defaults!!\n>> ")
            pe.reset_all()
            pe.set_control_value('mv_a', 0.0)
            pe.set_control_value('mv_x', 36)
            pe.set_control_value('mv_y', 36)
            pe.set_control_value('mv_l', 0)
            pe.set_control_value('rot', -0.001)
            pe.set_control_value('sx',0.999)
            pe.set_control_value('wave_mode', 2)
            pe.set_control_value('wave_enabled',1.0)
            pe.set_control_value('square_a',1.0)
    
        # Waveshape Enable
        if (path == "/joystick0/button0" and value == 1):
            if (pe.wave_enabled): pe.set_control_value('wave_enabled', 0.0)
            else: pe.set_control_value('wave_enabled', 1.0)

        # Squareshape Enable
        if (path == "/joystick0/button6" and value == 1):
            if (pe.square_a): pe.set_control_value('square_a', 0.0)
            else: pe.set_control_value('square_a', 1.0)

        # Border Enable
        if (path == "/joystick0/button2" and value == 1): 
            if (pe.ib_a): pe.set_control_value('ib_a', 0.0)
            else: pe.set_control_value('ib_a', 1.0)

        # Vector Field
        if (path == "/joystick0/button1" and value == 1): 
            if (pe.mv_a): pe.set_control_value('mv_a', 0.0)
            else: pe.set_control_value('mv_a', 1.0);    

        # Kaleidoscope
        if (path == "/joystick0/button4" and value == 1): 
            if (pe.kaleidoscope): pe.set_control_value('kaleidoscope', 0.0)
            else: pe.set_control_value('kaleidoscope', 1.0)


        # Translation
        if (path == "/joystick0/hat0" and value == 2): 
            self.square_thick_coeff = 1.0
        if (path == "/joystick0/hat0" and value == 8): 
            self.square_thick_coeff = -1.0
        if (path == "/joystick0/hat0" and value == 1): 
            self.square_scale_coeff = 1.0
        if (path == "/joystick0/hat0" and value == 4): 
            self.square_scale_coeff = -1.0
        if (path == "/joystick0/hat0" and value == 0.0): 
            self.square_thick_coeff = 0.0
            self.square_scale_coeff = 0.0
            self.wave_frequency_coeff = 0.0


        # Wave Movement
        if (path == "/joystick0/button7" and value == 1.0): 
            if (pe.wave_move == 1.0):
                pe.set_control_value('wave_move', 0.0)
                pe.set_control_value('wave_x',0.5)
                pe.set_control_value('wave_y',0.5)
            else: pe.set_control_value('wave_move', 1.0)


        # Rotation
        rot_gain = 0.01
        if (path == "/joystick0/axis0"):
            delta = -(value-0.5) * rot_gain
            if (math.fabs(value-0.5) > 0.05): 
                pe.set_control_value('rot', pe.rot - delta)
                # if (pe.rot > 0.785): pe.rot = 0.785   # Turn off rotation 
                # if (pe.rot < -0.785): pe.rot = -0.785 # limits for now.

        # Zoom
        zoom_gain = 0.002
        if (path == "/joystick0/axis1"): 
            delta = (value-0.5) * zoom_gain
            if (math.fabs(value-0.5) > 0.05): 
                pe.set_control_value('zoom', pe.zoom - delta)
                if (pe.zoom > 1.16): pe.set_control_value('zoom', 1.16)
                if (pe.zoom < 0.5): pe.set_control_value('zoom', 0.5)


        # Zoomexp & Kaliedoscope_raidus share this control
        if (path == "/joystick0/axis3"):
            if (pe.kaleidoscope == 1.0):
                delta = (value-0.5)/80.0
                if (math.fabs(value-0.5) > 0.05):
                    pe.set_control_value('kaleidoscope_radius', pe.kaleidoscope_radius - delta)
                if (pe.kaleidoscope_radius < 0.0): pe.set_control_value('kaleidoscope_radius', 0.0)
                if (pe.kaleidoscope_radius > 1.0): pe.set_control_value('kaleidoscope_radius', 1.0)
            else:
                delta = (value-0.5)/80.0
                if (math.fabs(value-0.5) > 0.05):
                    pe.set_control_value('zoomexp', pe.zoomexp - delta)
                if (pe.zoomexp < 0.25): pe.set_control_value('zoomexp', 0.25)
                if (pe.zoomexp > 2.0): pe.set_control_value('zoomexp', 2.0)


        # Scaling
        if (path == "/joystick0/button20" and value == 1.0): 
            self.sx_coefficient = 1.0
        if (path == "/joystick0/button20" and value == 0.0): 
            self.sx_coefficient = 0.0
        if (path == "/joystick0/button18" and value == 1.0): 
            self.sx_coefficient = -1.0
        if (path == "/joystick0/button18" and value == 0.0): 
            self.sx_coefficient = 0.0

        if (path == "/joystick0/button21" and value == 1.0): 
            self.sy_coefficient = 1.0
        if (path == "/joystick0/button21" and value == 0.0): 
            self.sy_coefficient = 0.0
        if (path == "/joystick0/button19" and value == 1.0): 
            self.sy_coefficient = -1.0
        if (path == "/joystick0/button19" and value == 0.0): 
            self.sy_coefficient = 0.0

        # Center of rotation
        if (path == "/joystick0/button22" and value == 1.0): 
            self.dx_coefficient = -1.0
        if (path == "/joystick0/button22" and value == 0.0): 
            self.dx_coefficient = 0.0
        if (path == "/joystick0/button24" and value == 1.0): 
            self.dx_coefficient = 1.0
        if (path == "/joystick0/button24" and value == 0.0): 
            self.dx_coefficient = 0.0

        if (path == "/joystick0/button23" and value == 1.0): 
            self.dy_coefficient = 1.0
        if (path == "/joystick0/button23" and value == 0.0): 
            self.dy_coefficient = 0.0
        if (path == "/joystick0/button25" and value == 1.0): 
            self.dy_coefficient = -1.0
        if (path == "/joystick0/button25" and value == 0.0): 
            self.dy_coefficient = 0.0


        # IFS Mode
        if (path == "/joystick0/button15" and value == 1.0):
            pe.set_control_value('ifs_mode', pe.ifs_mode + 1)
            if (pe.ifs_mode > 4):
                pe.set_control_value('ifs_mode', 0)
        if (path == "/joystick0/button17" and value == 1.0): 
            pe.set_control_value('ifs_mode', pe.ifs_mode - 1)
            if (pe.ifs_mode < 0):
                pe.set_control_value('ifs_mode', 4)
        if (path == "/joystick0/button14" and value == 1.0): 
            pe.set_control_value('ifs_mode', 0)
        if (path == "/joystick0/button16" and value == 1.0): 
            pe.set_control_value('ifs_mode', 0)


        # Reset center of rotation, scaling, and zoom exponent
        if (path == "/joystick0/button5" and value == 1.0): 
            if (pe.wave_usedots): pe.set_control_value('wave_usedots', 0.0)
            else: pe.set_control_value('wave_usedots', 1.0)

#        if (path == "/joystick0/button5" and value == 1.0): 
#            if (pe.invert): pe.set_control_value('invert', 0.0)
#            else: pe.set_control_value('invert', 1.0)


        # Warp
        if (path == "/joystick0/button0" and value == 1.0):
            self.warp_coefficient = 1.0
        if (path == "/joystick0/button0" and value == 0.0):
            self.warp_coefficient = 0.0
        if (path == "/joystick0/button6" and value == 1.0):
            self.warp_coefficient = -1.0
        if (path == "/joystick0/button6" and value == 0.0): 
            self.warp_coefficient = 0.0


        # Wave mode
        if (path == "/joystick0/button8" and value == 1): 
            pe.set_control_value('wave_mode', 0)
            pe.set_control_value('wave_enabled', 1)
        elif (path == "/joystick0/button9" and value == 1): 
            pe.set_control_value('wave_mode', 1)
            pe.set_control_value('wave_enabled', 1)
        elif (path == "/joystick0/button10" and value == 1): 
            pe.set_control_value('wave_mode', 2)
            pe.set_control_value('wave_enabled', 1)


        # PRECIOUS UPPER SWITCH 
        if (path == "/joystick0/button11" and value == 1): 
            pe.set_control_value('wave_frequency', 0.03)
            pe.set_control_value('wave_mode', 2)
        elif (path == "/joystick0/button12" and value == 1): 
            pe.set_control_value('wave_frequency', 0.2)
            pe.set_control_value('wave_mode', 2)
        elif (path == "/joystick0/button13" and value == 1): 
            pe.set_control_value('wave_frequency', 9.0)
            pe.set_control_value('wave_mode', 2)

        # Debugging
        if (self.JOY_DEBUG and (path.find("axis") == -1)):
            print("[JOYSTICK]    Path: " + path + "   Value: " + str(value))

        # Otherwise, delegate to the bindings.
        pe_bindings.controller_to_parameter(self, path, value)