Exemplo n.º 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 value_to_index(value, parameter_values):
        values_len = len(parameter_values)
        value_index = floor(value * values_len)

        # If the value is 1.00 we don't want an off by one error
        value_index = value_index - 1 if value_index == values_len else value_index

        log.debug("Input value: " + str(value) + ", output index: " + str(value_index))

        return value_index
Exemplo n.º 3
0
    def value_to_index(value, parameter_values):
        values_len = len(parameter_values)
        value_index = floor(value * values_len)

        # If the value is 1.00 we don't want an off by one error
        value_index = value_index - 1 if value_index == values_len else value_index

        log.debug("Input value: " + str(value) + ", output index: " +
                  str(value_index))

        return value_index
Exemplo n.º 4
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))
Exemplo n.º 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))
Exemplo n.º 6
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))
 def value_to_start_point_index(value, start_points):
     log.debug("start_points: " + str(start_points) + ", len: " + str(len(start_points)) + ", value: " + str(value))
     for index, start_point in enumerate(start_points):
         log.debug("index: " + str(index) + ", start_point: " + str(start_point) + ", value: " + str(value))
         if value > start_point and (index == len(start_points) - 1 or value < start_points[index + 1]):
             log.debug("Input value: " + str(value) + ", output index: " + str(index) + " with custom start points")
             return index
Exemplo n.º 8
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))
Exemplo n.º 9
0
 def value_to_start_point_index(value, start_points):
     log.debug("start_points: " + str(start_points) + ", len: " +
               str(len(start_points)) + ", value: " + str(value))
     for index, start_point in enumerate(start_points):
         log.debug("index: " + str(index) + ", start_point: " +
                   str(start_point) + ", value: " + str(value))
         if value > start_point and (index == len(start_points) - 1
                                     or value < start_points[index + 1]):
             log.debug("Input value: " + str(value) + ", output index: " +
                       str(index) + " with custom start points")
             return index