def 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 map(names_to_params, device_dict[device.class_name]) 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) != 8: return [None for i in range(0, 8)] 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), 8) return []
def 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 map(names_to_params, device_dict[device.class_name]) 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) != 8: return [ None for i in range(0, 8) ] 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), 8) return []
def send_state(self, state): if not (self._behaviour.mode == TouchStripModes.CUSTOM_FREE and len(state) == self.STATE_COUNT): raise AssertionError 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 send_state(self, state): if not (self.mode == self.MODE_CUSTOM_FREE and len(state) == self.STATE_COUNT): raise AssertionError 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) ] self._send_midi(Sysex.START + (100, 0, 8) + tuple(bytes) + (247, ))
def send_state(self, state): if not (self._behaviour.mode == TouchStripModes.CUSTOM_FREE and len(state) == self.STATE_COUNT): raise AssertionError 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) ] self._send_midi(Sysex.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 _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 _translate_string(self, string): if len(string) >= 18: without_gaps = flatten([g[:-1] for g in group(string, 18)]) string = ''.join(ifilter(bool, without_gaps)) return super(SpecialPhysicalDisplay, self)._translate_string(string)
def send_state(self, state): assert(self._behaviour.mode == TouchStripModes.CUSTOM_FREE and len(state) == self.STATE_COUNT) 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 _translate_string(self, string): if len(string) >= 18: without_gaps = flatten([ g[:-1] for g in group(string, 18) ]) string = ''.join(ifilter(bool, without_gaps)) return super(SpecialPhysicalDisplay, self)._translate_string(string)