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_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])
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)
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
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 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])
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 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
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})
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 })