Ejemplo n.º 1
0
def special_parameter_banks(device, device_dict = DEVICE_DICT):
	""" Determine the parameters to use for a device """
	if device != None:
		if device.class_name in device_dict.keys():
			def names_to_params(bank):
				return map(partial(get_parameter_by_name, device), bank)
			
			return group([i for i in flatten(map(names_to_params, device_dict[device.class_name]))], 32)
		else:
			if device.class_name in MAX_DEVICES:
				try:
					banks = device.get_bank_count()
				except:
					banks = 0
				if banks != 0:
					def _bank_parameters(bank_index):
						try:
							parameter_indices = device.get_bank_parameters(bank_index)
						except:
							parameter_indices = []
						if len(parameter_indices) != 32:
							return [ None for i in range(0, 32) ]
						else:
							return [ (device.parameters[i] if i != -1 else None) for i in parameter_indices ]
					
					return map(_bank_parameters, range(0, banks))
			return group(device_parameters_to_map(device), 32)
	return []
Ejemplo n.º 2
0
def special_parameter_bank_names(device, bank_name_dict = BANK_NAME_DICT):
	if device != None:
		if device.class_name in bank_name_dict.keys():
			ret = group(bank_name_dict[device.class_name], 4)
			ret1 = [[i for i in bank_names if not i is None] for bank_names in ret]
			return [' - '.join(i) for i in ret1]
		banks = special_number_of_parameter_banks(device)
		def _default_bank_name(bank_index):
			return 'Bank ' + str(bank_index + 1)
		
		if device.class_name in MAX_DEVICES and banks != 0:
			def _is_ascii(c):
				return ord(c) < 128
			
			def _bank_name(bank_index):
				try:
					name = device.get_bank_name(bank_index)
				except:
					name = None
				if name:
					return str(filter(_is_ascii, name))
				else:
					return _default_bank_name(bank_index)
			
			return map(_bank_name, range(0, banks))
		else:
			return map(_default_bank_name, range(0, banks))
	return []
Ejemplo n.º 3
0
def make_touch_strip_light_message(state):
    state = [TOUCHSTRIP_STATE_TO_VALUE[s] for s in state]
    group_size = 3
    bytes = [
        reduce(lambda byte, (i, state): byte | state << 2 * i,
               enumerate(state_group), 0)
        for state_group in group(state, group_size)
    ]
def make_touch_strip_light_message(state):
    state = [TOUCHSTRIP_STATE_TO_VALUE[s] for s in state]
    group_size = 3
    bytes = [
        reduce(lambda byte, idx_state: byte | idx_state[1] << 2 * idx_state[0],
               enumerate(state_group), 0)
        for state_group in group(state, group_size)
    ]
    return START + (100, 0, 8) + tuple(bytes) + (247, )
 def _build_inner_message(self, message):
     message = super(SpecialPhysicalDisplay, self)._build_inner_message(message)
     return flatten([ g[:-1] for g in group(message, DISPLAY_BLOCK_LENGTH) ])
def make_touch_strip_light_message(state):
    state = [ TOUCHSTRIP_STATE_TO_VALUE[s] for s in state ]
    group_size = 3
    bytes = [ reduce(lambda byte, (i, state): byte | state << 2 * i, enumerate(state_group), 0) for state_group in group(state, group_size) ]
Ejemplo n.º 7
0
 def _build_inner_message(self, message):
     message = super(SpecialPhysicalDisplay,
                     self)._build_inner_message(message)
     return flatten([g[:-1] for g in group(message, DISPLAY_BLOCK_LENGTH)])