Example #1
0
        def map_params_by_name(device, param_bank):
            ccs = PAGE3_CCS + PAGE4_CCS
            channel = CHANNEL_MIDI_COMMAND
            mode = Live.MidiMap.MapMode.absolute

            #	    self.log("ccs: %s" % ccs)
            for encoder in range(8):
                if (len(params) >= encoder):
                    if (param_bank[encoder] == ''):
                        continue
                    param_name = param_bank[encoder]
                    parameter = None
                    parameter = self.helper.get_parameter_by_name(
                        self.device, param_bank[encoder])
                    if parameter:
                        mode2 = mode

                        fullname = self.helper.device_name(
                            device) + "." + parameter.name
                        ParamMap.map_with_feedback(midi_map_handle, channel, \
                              ccs[encoder], parameter, \
                              mode2)
                    else:
                        self.log("Could not find parameter %s" %
                                 param_bank[encoder])
Example #2
0
 def map_params_by_name(device, param_bank):
     ccs = []
     channel = CHANNEL_SETUP2
     mode = Live.MidiMap.MapMode.relative_two_compliment
     if self.parent.is_lv1:
         ccs = LV1_FX3_CCS + LV1_FX4_CCS
         channel = TRACK_CHANNEL_SETUP2
         mode = Live.MidiMap.MapMode.absolute
     else:
         ccs = FX3_CCS + FX4_CCS
         channel = CHANNEL_SETUP2
     for encoder in range(8):
         if len(params) >= encoder:
             if param_bank[encoder] == '':
                 continue
             param_name = param_bank[encoder]
             parameter = None
             parameter = self.helper.get_parameter_by_name(self.device, param_bank[encoder])
             if parameter:
                 mode2 = mode
                 fullname = self.helper.device_name(device) + '.' + parameter.name
                 if parameter.is_quantized and not self.parent.is_lv1 and not INVERT_QUANT_PARAM.has_key(fullname):
                     mode2 = Live.MidiMap.MapMode.relative_binary_offset
                 self.logfmt('parameter %s %s to %s (quant %s)', parameter, parameter.name, ccs[encoder], parameter.is_quantized)
                 ParamMap.map_with_feedback(midi_map_handle, channel, ccs[encoder], parameter, mode2)
             else:
                 self.log('Could not find parameter %s' % param_bank[encoder])
 def map_track_params(self, script_handle, midi_map_handle):
     for idx in range(0, 4):
         tracks = self.parent.song().tracks + self.parent.song().return_tracks + (self.parent.song().master_track,)
         if (len(tracks) > idx):
             track = tracks[idx]
             mixer_device = track.mixer_device
             parameter = mixer_device.volume
             ParamMap.map_with_feedback(midi_map_handle, CHANNEL_MIDI_COMMAND, \
                                            PAGE1_CCS[idx], \
                                            parameter, Live.MidiMap.MapMode.absolute)
 def map_track_params(self, script_handle, midi_map_handle):
     for idx in range(0, 4):
         tracks = self.parent.song().tracks + self.parent.song(
         ).return_tracks + (self.parent.song().master_track, )
         if (len(tracks) > idx):
             track = tracks[idx]
             mixer_device = track.mixer_device
             parameter = mixer_device.volume
             ParamMap.map_with_feedback(midi_map_handle, CHANNEL_MIDI_KONTROL, \
                                            PAGE1_CCS[idx], \
                                            parameter, Live.MidiMap.MapMode.absolute)
	def map_params_by_number(device):
	    ccs = PAGE3_CCS + PAGE4_CCS
	    channel = CHANNEL_MIDI_COMMAND
	    mode = Live.MidiMap.MapMode.absolute
	    for encoder in range(8):
		# +1 to skip "Device on"
		if (len(device.parameters) >= encoder + 1):
		    ParamMap.map_with_feedback(midi_map_handle, channel, \
					       ccs[encoder], \
					       device.parameters[encoder + 1], \
					       mode)
Example #6
0
 def map_params_by_number(device):
     ccs = PAGE3_CCS + PAGE4_CCS
     channel = CHANNEL_MIDI_COMMAND
     mode = Live.MidiMap.MapMode.absolute
     for encoder in range(8):
         # +1 to skip "Device on"
         if (len(device.parameters) >= encoder + 1):
             ParamMap.map_with_feedback(midi_map_handle, channel, \
                   ccs[encoder], \
                   device.parameters[encoder + 1], \
                   mode)
 def realinit(self, c_instance):
     self.c_instance = c_instance
     self.helper = FaderfoxHelper(self)
     self.param_map = ParamMap(self)
     self.mixer_controller = None
     self.device_controller = None
     self.transport_controller = None
     self.components = []
     live = 'Live 6 & 7'
     if self.is_live_5():
         live = 'Live 5'
     self.show_message(self.__name__ + ' ' + self.__version__ + ' for ' +
                       live)
     self.is_lv1 = False
Example #8
0
 def map_params_by_number(device):
     ccs = []
     channel = CHANNEL_SETUP2
     mode = Live.MidiMap.MapMode.relative_two_compliment
     if self.parent.is_lv1:
         ccs = LV1_FX3_CCS + LV1_FX4_CCS
         channel = TRACK_CHANNEL_SETUP2
         mode = Live.MidiMap.MapMode.absolute
     else:
         ccs = FX3_CCS + FX4_CCS
         channel = CHANNEL_SETUP2
     for encoder in range(8):
         if len(device.parameters) >= encoder + 1:
             ParamMap.map_with_feedback(midi_map_handle, channel, ccs[encoder], device.parameters[encoder + 1], mode)
    def build_midi_map(self, script_handle, midi_map_handle):
        def forward_note(chan, note):
            Live.MidiMap.forward_midi_note(script_handle, midi_map_handle,
                                           chan, note)

        def forward_cc(chan, cc):
            Live.MidiMap.forward_midi_cc(script_handle, midi_map_handle, chan,
                                         cc)

        for note in FX3_NOTES:
            forward_note(CHANNEL_SETUP2, note)

        for note in FX4_NOTES:
            forward_note(CHANNEL_SETUP2, note)

        self.log('midi rebuild map')
        tracks = tuple(self.parent.song().tracks) + tuple(
            self.parent.song().return_tracks)
        for idx in range(0, 16):
            if len(tracks) > idx:
                track = tracks[idx]
                eq = self.helper.track_find_last_eq(track)
                self.log('found eq %s on track %s' % (eq, track))
                if eq:
                    params = self.helper.eq_params(eq)
                    for i in range(0, 4):
                        if params[i] != None:
                            self.log('map %s to %s' %
                                     (EQ_CCS[idx][i], params[i]))
                            ParamMap.map_with_feedback(
                                midi_map_handle, AUX_CHANNEL_SETUP2,
                                EQ_CCS[idx][i], params[i],
                                Live.MidiMap.MapMode.absolute)

            master_eq = self.helper.track_find_last_eq(
                self.parent.song().master_track)
            if master_eq:
                params = self.helper.eq_params(master_eq)
                for i in range(0, 4):
                    if params[i] != None:
                        ParamMap.map_with_feedback(
                            midi_map_handle, AUX_CHANNEL_SETUP2,
                            MASTER_EQ_CCS[i], params[i],
                            Live.MidiMap.MapMode.absolute)

        self.map_device_params(script_handle, midi_map_handle)
        forward_cc(CHANNEL_SETUP2, CLIP_TRANSPOSE_CC)
        return
Example #10
0
    def realinit(self, c_instance):
	if self.__myDebug__:
            if sys.platform == "win32":
                self.file = open("C:/MidiCommand" + self.suffix + ".txt", "a")
                self.commandfile = "C:/MidiCommand-cmd" + self.suffix + ".txt"
            else:
                self.file = open("/tmp/MidiCommand" + self.suffix, "a")
                self.commandfile = ("/tmp/MidiCommand-cmd" + self.suffix)
	    self.log("MidiCommand")
	    self.log("command file %s" % self.commandfile)
            if (self.is_live_5()):
                self.log("live 5")
            else:
                self.log("live 6")
	    
	self.c_instance = c_instance
	self.helper = MidiCommandHelper(self)
	self.param_map = ParamMap(self)
	self.mixer_controller = None
	self.device_controller = None
	self.transport_controller = None
	self.components = []
        live = "Live 6 & 7"
        if self.is_live_5():
            live = "Live 5"
        self.show_message(self.__name__ + " " + self.__version__ + " for " + live)
    def build_midi_map(self, script_handle, midi_map_handle):

        def forward_note(chan, note):
            Live.MidiMap.forward_midi_note(script_handle, midi_map_handle, chan, note)



        def forward_cc(chan, cc):
            Live.MidiMap.forward_midi_cc(script_handle, midi_map_handle, chan, cc)


        for note in FX3_NOTES:
            forward_note(CHANNEL_SETUP2, note)

        for note in FX4_NOTES:
            forward_note(CHANNEL_SETUP2, note)

        self.log('midi rebuild map')
        tracks = (self.parent.song().tracks + self.parent.song().return_tracks)
        for idx in range(0, 16):
            if (len(tracks) > idx):
                track = tracks[idx]
                eq = self.helper.track_find_last_eq(track)
                self.log(('found eq %s on track %s' % (eq,
                 track)))
                if eq:
                    params = self.helper.eq_params(eq)
                    for i in range(0, 4):
                        if (params[i] != None):
                            self.log(('map %s to %s' % (EQ_CCS[idx][i],
                             params[i])))
                            ParamMap.map_with_feedback(midi_map_handle, AUX_CHANNEL_SETUP2, EQ_CCS[idx][i], params[i], Live.MidiMap.MapMode.absolute)

            master_eq = self.helper.track_find_last_eq(self.parent.song().master_track)
            if master_eq:
                params = self.helper.eq_params(master_eq)
                for i in range(0, 4):
                    if (params[i] != None):
                        ParamMap.map_with_feedback(midi_map_handle, AUX_CHANNEL_SETUP2, MASTER_EQ_CCS[i], params[i], Live.MidiMap.MapMode.absolute)


        self.map_device_params(script_handle, midi_map_handle)
        forward_cc(CHANNEL_SETUP2, CLIP_TRANSPOSE_CC)
 def realinit(self, c_instance):
     self.c_instance = c_instance
     self.helper = FaderfoxHelper(self)
     self.param_map = ParamMap(self)
     self.mixer_controller = None
     self.device_controller = None
     self.transport_controller = None
     self.components = []
     live = 'Live 6 & 7'
     if self.is_live_5():
         live = 'Live 5'
     self.show_message(self.__name__ + ' ' + self.__version__ + ' for ' + live)
     self.is_lv1 = False
	def map_params_by_name(device, param_bank):
	    ccs = PAGE3_CCS + PAGE4_CCS
	    channel = CHANNEL_MIDI_COMMAND
	    mode = Live.MidiMap.MapMode.absolute
		
#	    self.log("ccs: %s" % ccs)
	    for encoder in range(8):
		if (len(params) >= encoder):
		    if (param_bank[encoder] == ''):
			continue
                    param_name = param_bank[encoder]
                    parameter = None
                    parameter = self.helper.get_parameter_by_name(self.device, param_bank[encoder])
		    if parameter:
			mode2 = mode

                        fullname = self.helper.device_name(device) + "." + parameter.name
			ParamMap.map_with_feedback(midi_map_handle, channel, \
						   ccs[encoder], parameter, \
						   mode2)
		    else:
			self.log("Could not find parameter %s" % param_bank[encoder])
class FaderfoxScript:
    __filter_funcs__ = ['update_display', 'log', 'song']
    __module__ = __name__
    __doc__ = 'Automap script for Faderfox controllers'
    __version__ = 'V1.1'
    __name__ = 'Generic Faderfox Script'

    def __init__(self, c_instance):
        self.suffix = ''
        self.is_lv1 = False
        FaderfoxScript.realinit(self, c_instance)

    def realinit(self, c_instance):
        self.c_instance = c_instance
        self.helper = FaderfoxHelper(self)
        self.param_map = ParamMap(self)
        self.mixer_controller = None
        self.device_controller = None
        self.transport_controller = None
        self.components = []
        live = 'Live 6 & 7'
        if self.is_live_5():
            live = 'Live 5'
        self.show_message(self.__name__ + ' ' + self.__version__ + ' for ' + live)
        self.is_lv1 = False

    def is_live_5(self):
        return hasattr(Live, 'is_live_5')

    def log(self, string):
        pass

    def logfmt(self, fmt, *args):
        pass

    def disconnect(self):
        for c in self.components:
            c.disconnect()

    def application(self):
        return Live.Application.get_application()

    def song(self):
        return self.c_instance.song()

    def suggest_input_port(self):
        return str('')

    def suggest_output_port(self):
        return str('')

    def can_lock_to_devices(self):
        return True

    def lock_to_device(self, device):
        if self.device_controller:
            self.device_controller.lock_to_device(device)

    def unlock_to_device(self, device):
        if self.device_controller:
            self.device_controller.unlock_from_device(device)

    def set_appointed_device(self, device):
        if self.device_controller:
            self.device_controller.set_appointed_device(device)

    def toggle_lock(self):
        self.c_instance.toggle_lock()

    def suggest_map_mode(self, cc_no, channel):
        return Live.MidiMap.MapMode.absolute

    def restore_bank(self, bank):
        pass

    def show_message(self, message):
        if hasattr(self.c_instance, 'show_message'):
            self.c_instance.show_message(message)

    def instance_identifier(self):
        return self.c_instance.instance_identifier()

    def connect_script_instances(self, instanciated_scripts):
        pass

    def request_rebuild_midi_map(self):
        self.c_instance.request_rebuild_midi_map()

    def send_midi(self, midi_event_bytes):
        self.c_instance.send_midi(midi_event_bytes)

    def refresh_state(self):
        for c in self.components:
            c.refresh_state()

    def build_midi_map(self, midi_map_handle):
        self.log('script build midi map')
        script_handle = self.c_instance.handle()
        self.param_map.remove_mappings()
        for c in self.components:
            self.log('build midi map on %s' % c)
            c.build_midi_map(script_handle, midi_map_handle)

    def update_display(self):
        for c in self.components:
            c.update_display()

    def receive_midi(self, midi_bytes):
        channel = midi_bytes[0] & CHAN_MASK
        status = midi_bytes[0] & STATUS_MASK
        if status == CC_STATUS:
            cc_no = midi_bytes[1]
            cc_value = midi_bytes[2]
            for c in self.components:
                c.receive_midi_cc(channel, cc_no, cc_value)

            self.param_map.receive_midi_cc(channel, cc_no, cc_value)
        elif status == NOTEON_STATUS or status == NOTEOFF_STATUS:
            note_no = midi_bytes[1]
            note_vel = midi_bytes[2]
            for c in self.components:
                c.receive_midi_note(channel, status, note_no, note_vel)

            self.param_map.receive_midi_note(channel, status, note_no, note_vel)
        else:
            raise False or AssertionError, 'Unknown MIDI message %s' % str(midi_bytes)
Example #15
0
    def map_device_params(self, script_handle, midi_map_handle):

        def map_params_by_number(device):
            ccs = []
            channel = CHANNEL_SETUP2
            mode = Live.MidiMap.MapMode.relative_two_compliment
            if self.parent.is_lv1:
                ccs = LV1_FX3_CCS + LV1_FX4_CCS
                channel = TRACK_CHANNEL_SETUP2
                mode = Live.MidiMap.MapMode.absolute
            else:
                ccs = FX3_CCS + FX4_CCS
                channel = CHANNEL_SETUP2
            for encoder in range(8):
                if len(device.parameters) >= encoder + 1:
                    ParamMap.map_with_feedback(midi_map_handle, channel, ccs[encoder], device.parameters[encoder + 1], mode)

        def map_params_by_name(device, param_bank):
            ccs = []
            channel = CHANNEL_SETUP2
            mode = Live.MidiMap.MapMode.relative_two_compliment
            if self.parent.is_lv1:
                ccs = LV1_FX3_CCS + LV1_FX4_CCS
                channel = TRACK_CHANNEL_SETUP2
                mode = Live.MidiMap.MapMode.absolute
            else:
                ccs = FX3_CCS + FX4_CCS
                channel = CHANNEL_SETUP2
            for encoder in range(8):
                if len(params) >= encoder:
                    if param_bank[encoder] == '':
                        continue
                    param_name = param_bank[encoder]
                    parameter = None
                    parameter = self.helper.get_parameter_by_name(self.device, param_bank[encoder])
                    if parameter:
                        mode2 = mode
                        fullname = self.helper.device_name(device) + '.' + parameter.name
                        if parameter.is_quantized and not self.parent.is_lv1 and not INVERT_QUANT_PARAM.has_key(fullname):
                            mode2 = Live.MidiMap.MapMode.relative_binary_offset
                        self.logfmt('parameter %s %s to %s (quant %s)', parameter, parameter.name, ccs[encoder], parameter.is_quantized)
                        ParamMap.map_with_feedback(midi_map_handle, channel, ccs[encoder], parameter, mode2)
                    else:
                        self.log('Could not find parameter %s' % param_bank[encoder])

        self.log('map device params %s' % self.device)
        if self.device:
            params = self.device.parameters
            device_bank = 0
            param_bank = 0
            device_name = self.helper.device_name(self.device)
            self.log("device name '%s'" % device_name)
            if device_name in XY_DEVICE_DICT.keys():
                xys = XY_DEVICE_DICT[device_name]
                if len(xys) > 0:
                    param1 = self.helper.get_parameter_by_name(self.device, xys[0][0])
                    param2 = self.helper.get_parameter_by_name(self.device, xys[0][1])
                    ccx = FX1_JOY_X_CC
                    ccy = FX1_JOY_Y_CC
                    channel = CHANNEL_SETUP2
                    if self.parent.is_lv1:
                        ccx = LV1_FX1_JOY_X_CC
                        ccy = LV1_FX1_JOY_Y_CC
                        channel = TRACK_CHANNEL_SETUP2
                    if param1:
                        ParamMap.map_with_feedback(midi_map_handle, channel, ccx, param1, Live.MidiMap.MapMode.absolute)
                    if param2:
                        ParamMap.map_with_feedback(midi_map_handle, channel, ccy, param2, Live.MidiMap.MapMode.absolute)
                if len(xys) > 1:
                    param1 = self.helper.get_parameter_by_name(self.device, xys[1][0])
                    param2 = self.helper.get_parameter_by_name(self.device, xys[1][1])
                    ccx = FX2_JOY_X_CC
                    ccy = FX2_JOY_Y_CC
                    channel = CHANNEL_SETUP2
                    if self.parent.is_lv1:
                        ccx = LV1_FX2_JOY_X_CC
                        ccy = LV1_FX2_JOY_Y_CC
                        channel = TRACK_CHANNEL_SETUP2
                    ParamMap.map_with_feedback(midi_map_handle, channel, ccx, param1, Live.MidiMap.MapMode.absolute)
                    ParamMap.map_with_feedback(midi_map_handle, channel, ccy, param2, Live.MidiMap.MapMode.absolute)
            if device_name in DEVICE_BOB_DICT.keys():
                param_bank = DEVICE_BOB_DICT[device_name]
                if device_name == 'Compressor2' and self.helper.get_parameter_by_name(self.device, 'Ext. In Gain'):
                    param_bank = CP2_BANK1_LIVE7
                self.log('class %s bank: %s' % (device_name, param_bank))
                self.show_bank_select('Best of parameters')
                map_params_by_name(self.device, param_bank)
            elif self.helper.device_is_plugin(self.device):
                self.show_bank_select('First eight parameters')
                map_params_by_number(self.device)
            else:
                self.log('Could not find %s in %s' % (device_name, DEVICE_BOB_DICT.keys()))
                return
Example #16
0
    def map_track_params(self, script_handle, midi_map_handle):
        for idx in range(0, 16):
            tracks = tuple(self.parent.song().tracks) + tuple(self.parent.song().return_tracks)
            if len(tracks) > idx:
                track = tracks[idx]
                mixer_device = track.mixer_device
                parameter = mixer_device.volume
                ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, VOLUME_CCS[idx], parameter, Live.MidiMap.MapMode.absolute)
                sends = mixer_device.sends
                for send_idx in range(0, 4):
                    if len(sends) > send_idx:
                        parameter = sends[send_idx]
                        ParamMap.map_with_feedback(midi_map_handle, TRACK_CHANNEL_SETUP2, SEND_CCS[idx][send_idx], parameter, Live.MidiMap.MapMode.absolute)

                parameter = mixer_device.panning
                ParamMap.map_with_feedback(midi_map_handle, TRACK_CHANNEL_SETUP2, PAN_X_CC[idx], parameter, Live.MidiMap.MapMode.absolute)

        track = self.parent.song().master_track
        parameter = track.mixer_device.panning
        ParamMap.map_with_feedback(midi_map_handle, TRACK_CHANNEL_SETUP2, PAN_X_MASTER_CC, parameter, Live.MidiMap.MapMode.absolute)
        parameter = track.mixer_device.volume
        cc = MAIN_VOLUME_CC
        if self.parent.is_lv1:
            cc = LV1_MAIN_VOLUME_CC
        ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, cc, parameter, Live.MidiMap.MapMode.absolute)
        if hasattr(track.mixer_device, 'cue_volume'):
            parameter = track.mixer_device.cue_volume
            cc = CUE_VOLUME_CC
            if self.parent.is_lv1:
                cc = LV1_CUE_VOLUME_CC
            ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, cc, parameter, Live.MidiMap.MapMode.absolute)
        if hasattr(track.mixer_device, 'crossfader'):
            parameter = track.mixer_device.crossfader
            cc = CROSSFADER_CC
            ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, cc, parameter, Live.MidiMap.MapMode.absolute)
            if self.parent.is_lv1:
                cc = LV1_CROSSFADER_CC
                ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, cc, parameter, Live.MidiMap.MapMode.absolute)
class FaderfoxScript:
    __filter_funcs__ = ['update_display', 'log', 'song']
    __module__ = __name__
    __doc__ = 'Automap script for Faderfox controllers'
    __version__ = 'V1.1'
    __name__ = 'Generic Faderfox Script'

    def __init__(self, c_instance):
        self.suffix = ''
        self.is_lv1 = False
        FaderfoxScript.realinit(self, c_instance)

    def realinit(self, c_instance):
        self.c_instance = c_instance
        self.helper = FaderfoxHelper(self)
        self.param_map = ParamMap(self)
        self.mixer_controller = None
        self.device_controller = None
        self.transport_controller = None
        self.components = []
        live = 'Live 6 & 7'
        if self.is_live_5():
            live = 'Live 5'
        self.show_message(self.__name__ + ' ' + self.__version__ + ' for ' +
                          live)
        self.is_lv1 = False

    def is_live_5(self):
        return hasattr(Live, 'is_live_5')

    def log(self, string):
        pass

    def logfmt(self, fmt, *args):
        pass

    def disconnect(self):
        for c in self.components:
            c.disconnect()

    def application(self):
        return Live.Application.get_application()

    def song(self):
        return self.c_instance.song()

    def suggest_input_port(self):
        return str('')

    def suggest_output_port(self):
        return str('')

    def can_lock_to_devices(self):
        return True

    def lock_to_device(self, device):
        if self.device_controller:
            self.device_controller.lock_to_device(device)

    def unlock_to_device(self, device):
        if self.device_controller:
            self.device_controller.unlock_from_device(device)

    def set_appointed_device(self, device):
        if self.device_controller:
            self.device_controller.set_appointed_device(device)

    def toggle_lock(self):
        self.c_instance.toggle_lock()

    def suggest_map_mode(self, cc_no, channel):
        return Live.MidiMap.MapMode.absolute

    def restore_bank(self, bank):
        pass

    def show_message(self, message):
        if hasattr(self.c_instance, 'show_message'):
            self.c_instance.show_message(message)

    def instance_identifier(self):
        return self.c_instance.instance_identifier()

    def connect_script_instances(self, instanciated_scripts):
        pass

    def request_rebuild_midi_map(self):
        self.c_instance.request_rebuild_midi_map()

    def send_midi(self, midi_event_bytes):
        self.c_instance.send_midi(midi_event_bytes)

    def refresh_state(self):
        for c in self.components:
            c.refresh_state()

    def build_midi_map(self, midi_map_handle):
        self.log('script build midi map')
        script_handle = self.c_instance.handle()
        self.param_map.remove_mappings()
        for c in self.components:
            self.log('build midi map on %s' % c)
            c.build_midi_map(script_handle, midi_map_handle)

    def update_display(self):
        for c in self.components:
            c.update_display()

    def receive_midi(self, midi_bytes):
        channel = midi_bytes[0] & CHAN_MASK
        status = midi_bytes[0] & STATUS_MASK
        if status == CC_STATUS:
            cc_no = midi_bytes[1]
            cc_value = midi_bytes[2]
            for c in self.components:
                c.receive_midi_cc(channel, cc_no, cc_value)

            self.param_map.receive_midi_cc(channel, cc_no, cc_value)
        elif status == NOTEON_STATUS or status == NOTEOFF_STATUS:
            note_no = midi_bytes[1]
            note_vel = midi_bytes[2]
            for c in self.components:
                c.receive_midi_note(channel, status, note_no, note_vel)

            self.param_map.receive_midi_note(channel, status, note_no,
                                             note_vel)
        else:
            raise False or AssertionError, 'Unknown MIDI message %s' % str(
                midi_bytes)
    def build_midi_map(self, script_handle, midi_map_handle):
        def forward_note(chan, note):
            Live.MidiMap.forward_midi_note(script_handle, midi_map_handle,
                                           chan, note)

        def forward_cc(chan, cc):
            Live.MidiMap.forward_midi_cc(script_handle, midi_map_handle, chan,
                                         cc)

        idx = 0

        forward_cc(CHANNEL_MIDI_KONTROL, SCENE_SCROLL_CC)
        forward_cc(CHANNEL_MIDI_KONTROL, TRACK_SCROLL_CC)

        self.map_track_params(script_handle, midi_map_handle)

        self.on_track_selected()
        self.helper.send_page({
            'patch':
            1,
            'page':
            0,
            'type':
            0,
            'ccs':
            PAGE1_CCS,
            'channel': [CHANNEL_MIDI_KONTROL for i in range(0, 4)],
            'macros': [[128, SCENE_SCROLL_CC], [0, TRACK_SCROLL_CC], [0, 0],
                       [0, 0]],
            'names': ['LV1 ', 'LV2 ', 'LV3 ', 'LV4 ']
        })

        track = self.parent.song().view.selected_track
        names = ['', '', '', '']
        if track:
            mixer_device = track.mixer_device
            names = ["LEV"]
            parameter = mixer_device.volume
            ParamMap.map_with_feedback(midi_map_handle, CHANNEL_MIDI_KONTROL, \
                                           PAGE2_CCS[0], \
                                           parameter, Live.MidiMap.MapMode.absolute)

            sends = mixer_device.sends
            for x in range(0, 1):
                if (len(sends) > x):
                    names.append("SD%s" % (x + 1))
                    parameter = sends[x]
                    ParamMap.map_with_feedback(midi_map_handle, \
                                                   CHANNEL_MIDI_KONTROL, \
                                                   PAGE2_CCS[x + 1], \
                                                   parameter, \
                                                   Live.MidiMap.MapMode.absolute)
                else:
                    names.append("")

            eq = self.helper.track_find_last_eq(track)
            if eq:
                names += ['LP', 'HP']
                params = self.helper.eq_params(eq)
                ParamMap.map_with_feedback(midi_map_handle, \
                                               CHANNEL_MIDI_KONTROL, \
                                               PAGE2_CCS[2], \
                                               params[0],\
                                               Live.MidiMap.MapMode.absolute)
                ParamMap.map_with_feedback(midi_map_handle, \
                                               CHANNEL_MIDI_KONTROL, \
                                               PAGE2_CCS[3], \
                                               params[2],\
                                               Live.MidiMap.MapMode.absolute)
            else:
                names += ['', '']

        self.helper.send_page({
            'patch':
            1,
            'page':
            1,
            'type':
            0,
            'ccs':
            PAGE2_CCS,
            'channel': [CHANNEL_MIDI_KONTROL for i in range(0, 4)],
            'macros': [[128, SCENE_SCROLL_CC], [0, TRACK_SCROLL_CC], [0, 0],
                       [0, 0]],
            'names':
            names
        })
Example #19
0
class FaderfoxScript:
    __module__ = __name__
    __filter_funcs__ = ["update_display", "log", "song"]
    __module__ = __name__
    __doc__ = "Automap script for Faderfox controllers"
    __version__ = "V1.1"
    __name__ = "Generic Faderfox Script"

    def __init__(self, c_instance):
        self.suffix = ""
        self.is_lv1 = False
        FaderfoxScript.realinit(self, c_instance)

    def realinit(self, c_instance):
        self.c_instance = c_instance
        self.helper = FaderfoxHelper(self)
        self.param_map = ParamMap(self)
        self.mixer_controller = None
        self.device_controller = None
        self.transport_controller = None
        self.components = []
        live = "Live 6 & 7"
        if self.is_live_5():
            live = "Live 5"
        self.show_message(((((self.__name__ + " ") + self.__version__) + " for ") + live))
        self.is_lv1 = False

    def is_live_5(self):
        return hasattr(Live, "is_live_5")

    def log(self, string):
        pass

    def logfmt(self, fmt, *args):
        pass

    def disconnect(self):
        for c in self.components:
            c.disconnect()

    def application(self):
        return Live.Application.get_application()

    def song(self):
        return self.c_instance.song()

    def suggest_input_port(self):
        return str("")

    def suggest_output_port(self):
        return str("")

    def can_lock_to_devices(self):
        return True

    def lock_to_device(self, device):
        if self.device_controller:
            self.device_controller.lock_to_device(device)

    def unlock_to_device(self, device):
        if self.device_controller:
            self.device_controller.unlock_from_device(device)

    def set_appointed_device(self, device):
        if self.device_controller:
            self.device_controller.set_appointed_device(device)

    def toggle_lock(self):
        self.c_instance.toggle_lock()

    def suggest_map_mode(self, cc_no, channel):
        return Live.MidiMap.MapMode.absolute

    def restore_bank(self, bank):
        pass

    def show_message(self, message):
        if hasattr(self.c_instance, "show_message"):
            self.c_instance.show_message(message)

    def instance_identifier(self):
        return self.c_instance.instance_identifier()

    def connect_script_instances(self, instanciated_scripts):
        pass

    def request_rebuild_midi_map(self):
        self.c_instance.request_rebuild_midi_map()

    def send_midi(self, midi_event_bytes):
        self.c_instance.send_midi(midi_event_bytes)

    def refresh_state(self):
        for c in self.components:
            c.refresh_state()

    def build_midi_map(self, midi_map_handle):
        self.log("script build midi map")
        script_handle = self.c_instance.handle()
        self.param_map.remove_mappings()
        for c in self.components:
            self.log(("build midi map on %s" % c))
            c.build_midi_map(script_handle, midi_map_handle)

    def update_display(self):
        for c in self.components:
            c.update_display()

    def receive_midi(self, midi_bytes):
        channel = midi_bytes[0] & CHAN_MASK
        status = midi_bytes[0] & STATUS_MASK
        if status == CC_STATUS:
            cc_no = midi_bytes[1]
            cc_value = midi_bytes[2]
            for c in self.components:
                c.receive_midi_cc(channel, cc_no, cc_value)

            self.param_map.receive_midi_cc(channel, cc_no, cc_value)
        elif (status == NOTEON_STATUS) or (status == NOTEOFF_STATUS):
            note_no = midi_bytes[1]
            note_vel = midi_bytes[2]
            for c in self.components:
                c.receive_midi_note(channel, status, note_no, note_vel)

            self.param_map.receive_midi_note(channel, status, note_no, note_vel)
        else:
            assert False, "Unknown MIDI message %s" % str(midi_bytes)
Example #20
0
    def map_track_params(self, script_handle, midi_map_handle):
        for idx in range(0, 16):
            tracks = tuple(self.parent.song().tracks) + tuple(
                self.parent.song().return_tracks)
            if len(tracks) > idx:
                track = tracks[idx]
                mixer_device = track.mixer_device
                parameter = mixer_device.volume
                ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2,
                                           VOLUME_CCS[idx], parameter,
                                           Live.MidiMap.MapMode.absolute)
                sends = mixer_device.sends
                for send_idx in range(0, 4):
                    if len(sends) > send_idx:
                        parameter = sends[send_idx]
                        ParamMap.map_with_feedback(
                            midi_map_handle, TRACK_CHANNEL_SETUP2,
                            SEND_CCS[idx][send_idx], parameter,
                            Live.MidiMap.MapMode.absolute)

                parameter = mixer_device.panning
                ParamMap.map_with_feedback(midi_map_handle,
                                           TRACK_CHANNEL_SETUP2, PAN_X_CC[idx],
                                           parameter,
                                           Live.MidiMap.MapMode.absolute)

        track = self.parent.song().master_track
        parameter = track.mixer_device.panning
        ParamMap.map_with_feedback(midi_map_handle, TRACK_CHANNEL_SETUP2,
                                   PAN_X_MASTER_CC, parameter,
                                   Live.MidiMap.MapMode.absolute)
        parameter = track.mixer_device.volume
        cc = MAIN_VOLUME_CC
        if self.parent.is_lv1:
            cc = LV1_MAIN_VOLUME_CC
        ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, cc,
                                   parameter, Live.MidiMap.MapMode.absolute)
        if hasattr(track.mixer_device, 'cue_volume'):
            parameter = track.mixer_device.cue_volume
            cc = CUE_VOLUME_CC
            if self.parent.is_lv1:
                cc = LV1_CUE_VOLUME_CC
            ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, cc,
                                       parameter,
                                       Live.MidiMap.MapMode.absolute)
        if hasattr(track.mixer_device, 'crossfader'):
            parameter = track.mixer_device.crossfader
            cc = CROSSFADER_CC
            ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, cc,
                                       parameter,
                                       Live.MidiMap.MapMode.absolute)
            if self.parent.is_lv1:
                cc = LV1_CROSSFADER_CC
                ParamMap.map_with_feedback(midi_map_handle, CHANNEL_SETUP2, cc,
                                           parameter,
                                           Live.MidiMap.MapMode.absolute)
    def build_midi_map(self, script_handle, midi_map_handle):
	def forward_note(chan, note):
	    Live.MidiMap.forward_midi_note(script_handle, midi_map_handle, chan, note)

	def forward_cc(chan, cc):
	    Live.MidiMap.forward_midi_cc(script_handle, midi_map_handle, chan, cc)
	idx = 0

        forward_cc(CHANNEL_MIDI_COMMAND, SCENE_SCROLL_CC)
        forward_cc(CHANNEL_MIDI_COMMAND, TRACK_SCROLL_CC)

	self.map_track_params(script_handle, midi_map_handle)
	
        self.on_track_selected()
        self.helper.send_page({'patch' : 1,
                               'page' : 0,
                               'type': 0,
                               'ccs' : PAGE1_CCS,
                               'channel' : [ CHANNEL_MIDI_COMMAND for i in range(0, 4)],
                               'macros' : [ [128, SCENE_SCROLL_CC],
                                            [0,   TRACK_SCROLL_CC],
                                            [0, 0],
                                            [0, 0]],
                               'names' : ['LV1 ', 'LV2 ', 'LV3 ', 'LV4 ']})

        track = self.parent.song().view.selected_track
        names = ['', '', '', '']
        if track:
            mixer_device = track.mixer_device
            names = ["LEV"]
            parameter = mixer_device.volume
            ParamMap.map_with_feedback(midi_map_handle, CHANNEL_MIDI_COMMAND, \
                                           PAGE2_CCS[0], \
                                           parameter, Live.MidiMap.MapMode.absolute)
            
            sends = mixer_device.sends
            for x in range(0, 1):
                if (len(sends) > x):
                    names.append("SD%s" % (x + 1))
                    parameter = sends[x]
                    ParamMap.map_with_feedback(midi_map_handle, \
                                                   CHANNEL_MIDI_COMMAND, \
                                                   PAGE2_CCS[x + 1], \
                                                   parameter, \
                                                   Live.MidiMap.MapMode.absolute)
                else:
                    names.append("")

            eq = self.helper.track_find_last_eq(track)
            if eq:
                names += ['LP', 'HP']
                params = self.helper.eq_params(eq)
                ParamMap.map_with_feedback(midi_map_handle, \
                                               CHANNEL_MIDI_COMMAND, \
                                               PAGE2_CCS[2], \
                                               params[0],\
                                               Live.MidiMap.MapMode.absolute)
                ParamMap.map_with_feedback(midi_map_handle, \
                                               CHANNEL_MIDI_COMMAND, \
                                               PAGE2_CCS[3], \
                                               params[2],\
                                               Live.MidiMap.MapMode.absolute)
            else:
                names += ['', '']
                
        self.helper.send_page({'patch' : 1,
                               'page' : 1,
                               'type': 0,
                               'ccs' : PAGE2_CCS,
                               'channel' : [ CHANNEL_MIDI_COMMAND for i in range(0, 4)],
                               'macros' : [ [128, SCENE_SCROLL_CC],
                                            [0,   TRACK_SCROLL_CC],
                                            [0, 0],
                                            [0, 0]],
                               'names': names})