示例#1
0
    def preview(self, selected, contents, level):
        if self.cfg.get('enabled') == 'False' or level < 1:
            return

        # Ignore items that aren't content items
        if not (hasattr(selected, 'content') and hasattr(selected.content, 'name')):
            self._kill_player(True)
            return
        # Ignore non-audio items
        if not any(audio_format in selected.content.name for audio_format in self.cfg.get('audio_formats')):
            log.info('' + selected.content.name + ' is not a known audio format')
            self._kill_player(True)
            return

        library_top_level = str(contents[1][0].selected_item)
        # Ignore any top-level paths we don't know how to handle
        if not library_top_level in self.cfg.get('LibraryPaths'):
            log.error('path ' + library_top_level + ' not found in config')
            return

        path = []
        for parent_level in range(2, level):
            path.append(str(contents[parent_level][0].selected_item))
        path.append(selected.content.name)

        path = os.path.join(*path)
        realpath = self.cfg.get('LibraryPaths', library_top_level) + path

        if not os.path.isfile(realpath):
            log.error('file ' + realpath + ' not found')
            return

        self._kill_player()
        log.debug('playing ' + realpath)
        self.player_process = subprocess.Popen([self.cfg.get('player_bin'), realpath])
def apply_ubermap_patches():
    log.info("Applying UbermapDevices patches")

    apply_log_method_patches()
    apply_banking_util_patches()
    apply_device_component_patches()
    apply_device_parameter_bank_patches()
    apply_device_parameter_adapater_patches()
示例#3
0
def apply_ubermap_patches():
    log.info("Applying UbermapDevices patches")

    apply_log_method_patches()
    apply_banking_util_patches()
    apply_device_component_patches()
    apply_device_parameter_bank_patches()
    apply_device_parameter_adapater_patches()
示例#4
0
        def get_parameter_by_name(device, nameMapping):
            count = 0
            for i in device.parameters:
                if nameMapping[0] == str(count) + "_" + i.original_name or nameMapping[0] == i.original_name:
                    log.info("got " + nameMapping[1] + " for " + nameMapping[0])
                    i.custom_name = nameMapping[1]

                    [i.custom_parameter_values, i.custom_parameter_start_points] = get_custom_parameter_values(nameMapping[0])

                    return i
                count = count + 1
示例#5
0
    def dump_device(self, device):
        filepath = self.get_device_filename(device)
        if (self.get_device_config(device) or os.path.isfile(filepath)):
            log.debug('not dumping device: ' + self.get_device_name(device))
            return False
        log.debug('dumping device: ' + self.get_device_name(device))

        config = ConfigObj()
        config.filename = filepath

        config[self.SECTION_BANKS] = {}
        config[self.SECTION_BEST_OF] = {}
        config[self.SECTION_CONFIG] = {}
        config[self.SECTION_CONFIG]['Cache'] = False
        config[self.SECTION_CONFIG]['Ignore'] = True
        '''
        Code to dump original ableton mapping - not working

        bank_names = parameter_bank_names(device, skip = True)
        banks = parameter_banks(device, skip = True)

        count = 0
        for bank_name in bank_names:
            config[SECTION_BANKS][bank_name] = {}
            for param in banks[count]:
                if(param):
                    config[SECTION_BANKS][bank_name][param.original_name] = param.original_name
            count = count + 1
        #config[SECTION_BEST_OF]['Bank']  = best_of_parameter_bank(device, _ubermap_skip = True)
        config[SECTION_BEST_OF]['Bank']  = config[SECTION_BANKS].itervalues().next()
        '''

        count = 0
        bank = 1
        total_count = 1
        for i in device.parameters[1:]:
            if (count == 0):
                section = 'Bank ' + str(bank)
                config[self.SECTION_BANKS][section] = {}
                bank = bank + 1

            config[self.SECTION_BANKS][section][
                str(total_count) + "_" + i.original_name] = i.original_name

            count = count + 1
            total_count = total_count + 1
            if (count == self.PARAMS_PER_BANK):
                count = 0
        config[self.SECTION_BEST_OF]['Bank'] = config[
            self.SECTION_BANKS].itervalues().next()

        config.write()
        log.info('dumped device: ' + self.get_device_name(device))
示例#6
0
    def dump_device(self, device):
        filepath = self.get_device_filename(device)
        if(self.get_device_config(device) or os.path.isfile(filepath)):
            log.debug('not dumping device: ' + self.get_device_name(device))
            return False
        log.debug('dumping device: ' + self.get_device_name(device))

        config = ConfigObj()
        config.filename = filepath

        config[self.SECTION_BANKS]   = {}
        config[self.SECTION_BEST_OF] = {}
        config[self.SECTION_CONFIG]  = {}
        config[self.SECTION_CONFIG]['Cache']  = False
        config[self.SECTION_CONFIG]['Ignore'] = True

        '''
        Code to dump original ableton mapping - not working

        bank_names = parameter_bank_names(device, skip = True)
        banks = parameter_banks(device, skip = True)

        count = 0
        for bank_name in bank_names:
            config[SECTION_BANKS][bank_name] = {}
            for param in banks[count]:
                if(param):
                    config[SECTION_BANKS][bank_name][param.original_name] = param.original_name
            count = count + 1
        #config[SECTION_BEST_OF]['Bank']  = best_of_parameter_bank(device, _ubermap_skip = True)
        config[SECTION_BEST_OF]['Bank']  = config[SECTION_BANKS].itervalues().next()
        '''

        count = 0
        bank = 1
        total_count = 1
        for i in device.parameters[1:]:
            if(count == 0):
                section = 'Bank ' + str(bank)
                config[self.SECTION_BANKS][section] = {}
                bank = bank + 1

            config[self.SECTION_BANKS][section][str(total_count) + "_" + i.original_name] = i.original_name

            count = count + 1
            total_count = total_count + 1
            if(count == self.PARAMS_PER_BANK):
                count = 0
        config[self.SECTION_BEST_OF]['Bank']  = config[self.SECTION_BANKS].itervalues().next()

        config.write()
        log.info('dumped device: ' + self.get_device_name(device))
示例#7
0
def apply_ubermap_patches(is_v1):
    # FIX END
    log.info("Applying UbermapDevices patches")

    apply_log_method_patches()
    apply_banking_util_patches()
    # FIX MULTIPLE VERSION BEING
    #    apply_device_component_patches()
    apply_device_component_patches(is_v1)
    # FIX END
    apply_device_parameter_bank_patches()
    apply_device_parameter_adapater_patches()
    apply_device_image_filename()
示例#8
0
        def get_parameter_by_name(device, nameMapping):
            count = 0
            for i in device.parameters:
                if nameMapping[0] == str(
                        count
                ) + "_" + i.original_name or nameMapping[0] == i.original_name:
                    log.info("got " + nameMapping[1] + " for " +
                             nameMapping[0])
                    i.custom_name = nameMapping[1]

                    [
                        i.custom_parameter_values,
                        i.custom_parameter_start_points
                    ] = get_custom_parameter_values(nameMapping[0])

                    return i
                count = count + 1
示例#9
0
    def dump_device(self, device):
        if not device:
            return

        filepath = self.get_device_filename(device)
        if (self.get_device_config(device) or os.path.isfile(filepath)):
            log.debug('not dumping device: ' + self.get_device_name(device))
            return False
        log.debug('dumping device: ' + self.get_device_name(device))

        config = ConfigObj()
        config.filename = filepath

        config[self.SECTION_BANKS] = {}
        config[self.SECTION_PARAMETER_VALUES] = {}
        config[self.SECTION_PARAMETER_VALUE_TYPES] = {}

        config[self.SECTION_CONFIG] = {}
        config[self.SECTION_CONFIG]['Cache'] = False
        config[self.SECTION_CONFIG]['Ignore'] = True

        count = 0
        bank = 1
        total_count = 1

        for i in device.parameters[1:]:
            if (count == 0):
                section = 'Bank ' + str(bank)
                config[self.SECTION_BANKS][section] = {}
                bank = bank + 1

            log.info('banks: ' + str(type(i)))

            config[self.SECTION_BANKS][section][
                str(total_count) + "_" + i.original_name] = i.original_name

            count = count + 1
            total_count = total_count + 1
            if (count == self.PARAMS_PER_BANK):
                count = 0

        config.write()
        log.info('dumped device: ' + self.get_device_name(device))
示例#10
0
    def dump_device(self, device):
        if not device:
            return

        filepath = self.get_device_filename(device)
        if(self.get_device_config(device) or os.path.isfile(filepath)):
            log.debug('not dumping device: ' + self.get_device_name(device))
            return False
        log.debug('dumping device: ' + self.get_device_name(device))

        config = ConfigObj()
        config.filename = filepath

        config[self.SECTION_BANKS] = {}
        config[self.SECTION_PARAMETER_VALUES] = {}
        config[self.SECTION_PARAMETER_VALUE_TYPES] = {}

        config[self.SECTION_CONFIG] = {}
        config[self.SECTION_CONFIG]['Cache']  = False
        config[self.SECTION_CONFIG]['Ignore'] = True

        count = 0
        bank = 1
        total_count = 1
        for i in device.parameters[1:]:
            if(count == 0):
                section = 'Bank ' + str(bank)
                config[self.SECTION_BANKS][section] = {}
                bank = bank + 1

            config[self.SECTION_BANKS][section][str(total_count) + "_" + i.original_name] = i.original_name

            count = count + 1
            total_count = total_count + 1
            if(count == self.PARAMS_PER_BANK):
                count = 0

        config.write()
        log.info('dumped device: ' + self.get_device_name(device))
示例#11
0
        def get_parameter_by_name(device, nameMapping):
            count = 0
            for i in device.parameters:
                if nameMapping[0].split("_")[0] == str(count):

                    log.info("got " + nameMapping[1] + " for " +
                             nameMapping[0])

                    # support for dynamic parameter names such as macros that change names
                    if "_".join(
                            nameMapping[0].split("_")[1:]) != i.original_name:
                        i.custom_name = i.original_name
                    else:
                        i.custom_name = nameMapping[1]

                    [
                        i.custom_parameter_values,
                        i.custom_parameter_start_points
                    ] = get_custom_parameter_values(nameMapping[0])

                    return i
                count = count + 1
示例#12
0
    def get_device_name(self, device):
        if not device:
            return ''

        name = device.class_display_name
        # BBE TEST BEGIN
        log.info('load device name=' + device.name + ' class_name=' +
                 device.class_name + ' class_display_name=' +
                 device.class_display_name)
        # BBE TEST END

        # use the default mapping if there is one (filename without a hash)
        filepath = config.get_config_path(name, 'Devices')
        if os.path.isfile(filepath):
            return name

        if self.cfg.get('use_md5') == 'True':
            params = ''
            for i in device.parameters[1:]:
                params += i.original_name
            name += '_' + hashlib.md5(params).hexdigest()

        return name
 def __getattribute__(self, name):
     returned = object.__getattribute__(self, name)
     if inspect.isfunction(returned) or inspect.ismethod(returned):
         log.info('Called ' + self.__class__.__name__ + '::' + str(returned.__name__))
     return returned
示例#14
0
 def __getattribute__(self, name):
     returned = object.__getattribute__(self, name)
     if inspect.isfunction(returned) or inspect.ismethod(returned):
         log.info('Called ' + self.__class__.__name__ + '::' +
                  str(returned.__name__))
     return returned
示例#15
0
 def __init__(self):
     self.cfg = config.load('devices')
     log.info('UbermapDevices ready')
示例#16
0
 def __init__(self):
     self.cfg = config.load('devices')
     log.info('UbermapDevices ready')