示例#1
0
    def __inner_init_default__(self):
        if self.__initialized:
            return

        sourceEdt = _c.determineEdt(self.dataref)

        if not sourceEdt.isIntermediate():
            _essentia.VectorInput.__init__(self, self.dataref, str(sourceEdt))
            self.__initialized = True
            return

        if sourceEdt == _c.Edt.LIST_EMPTY or \
           sourceEdt == _c.Edt.LIST_INTEGER or \
           sourceEdt == _c.Edt.LIST_REAL or \
           sourceEdt == _c.Edt.LIST_MIXED:
            self.dataref = _c.convertData(self.dataref, _c.Edt.VECTOR_REAL)
            _essentia.VectorInput.__init__(self, self.dataref, _c.Edt.VECTOR_REAL)
            self.__initialized = True
            return

        if sourceEdt == _c.Edt.LIST_LIST_REAL or sourceEdt == _c.Edt.LIST_LIST_INTEGER:
            self.dataref = _c.convertData(self.dataref, _c.Edt.MATRIX_REAL)
            _essentia.VectorInput.__init__(self, self.dataref, _c.Edt.MATRIX_REAL)
            self.__initialized = True
            return

        raise TypeError('Unable to initialize VectorInput because it is '+\
                        'being connected to None or a Pool, and the '+\
                        'VectorInput\'s data consists of an unsupported Pool '+\
                        'type: '+str(sourceEdt))
示例#2
0
        def compute(self, *args):
            inputNames = self.inputNames()

            if len(args) != len(inputNames):
                raise ValueError(name+'.compute requires '+str(len(inputNames))+' argument(s), '+str(len(args))+' given')

            # we have to make some exceptions for YamlOutput and PoolAggregator
            # because they expect cpp Pools
            if name in ('YamlOutput', 'PoolAggregator', 'SvmClassifier', 'PCA', 'GaiaTransform'):
                args = (args[0].cppPool,)

            # verify that all types match and do any necessary conversions
            result = []

            convertedArgs = []
            for i in range(len(inputNames)):
                goalType = _c.Edt(self.inputType(inputNames[i]))
                try:
                    convertedData = _c.convertData(args[i], goalType)
                except TypeError:
                    raise TypeError('Error cannot convert argument %s to %s' \
                          %(str(_c.determineEdt(args[i])), str(goalType)))

                convertedArgs.append(convertedData)

            results = self.__compute__(*convertedArgs)

            # we have to make an exceptional case for YamlInput, because we need
            # to wrap the Pool that it outputs w/ our python Pool from common.py
            if name in ('YamlInput', 'PoolAggregator', 'SvmClassifier', 'PCA', 'GaiaTransform', 'Extractor'):
                return _c.Pool(results)

            else:
                return results
示例#3
0
        def configure(self, **kwargs):
            # verify that all types match and do any necessary conversions
            for name, val in kwargs.iteritems():
                goalType = self.paramType(name)
                try:
                    convertedVal = _c.convertData(val, goalType)
                except TypeError, e:
                    raise TypeError('Error verifying \''+name+'\' parameter: '+str(e))

                kwargs[name] = convertedVal
示例#4
0
        def configure(self, **kwargs):
            # verify that all types match and do any necessary conversions
            for name, val in kwargs.iteritems():
                goalType = self.paramType(name)
                try:
                    convertedVal = _c.convertData(val, goalType)
                except TypeError: # as e: # catching exception as sth is only
                                          #available as from python 2.6
                    raise TypeError('Error cannot convert parameter %s to %s'\
                                    %(str(_c.determineEdt(val)),str(goalType))) #\''+name+'\' parameter: '+str(e))

                kwargs[name] = convertedVal

            self.__configure__(**kwargs)
示例#5
0
    def __inner_init__(self, sinkEdt):
        # get vector form of sinkEdt, because we'll compare to given data input
        # which is a vector of something
        sinkEdt = sinkEdt.vectorize()

        if self.__initialized:
            if self.__initializedType == sinkEdt:
                return
            raise TypeError('VectorInput was already connected to another sink with a different type, original type: '+str(self.__initializedType)+' new type: '+str(sinkEdt))

        self.dataref = _c.convertData(self.dataref, sinkEdt)
        _essentia.VectorInput.__init__(self, self.dataref, str(sinkEdt))
        self.__initializedType = sinkEdt #_c.Edt
        self.__initialized = True
示例#6
0
        def configure(self, **kwargs):
            # verify that all types match and do any necessary conversions
            for name, val in kwargs.iteritems():
                goalType = self.paramType(name)
                try:
                    convertedVal = _c.convertData(val, goalType)
                except TypeError: # as e: # catching exception as sth is only
                                          #available as from python 2.6
                    raise TypeError('Error cannot convert parameter %s to %s'\
                                    %(str(_c.determineEdt(val)),str(goalType))) #\''+name+'\' parameter: '+str(e))

                kwargs[name] = convertedVal

            self.__configure__(**kwargs)
示例#7
0
        def compute(self, *args):
            inputNames = self.inputNames()

            if len(args) != len(inputNames):
                raise ValueError(name+'.compute requires '+str(len(inputNames))+' argument(s), '+str(len(args))+' given')

            # we have to make some exceptions for YamlOutput and PoolAggregator
            # because they expect cpp Pools
            if name in ('YamlOutput', 'PoolAggregator', 'SvmClassifier', 'PCA', 'GaiaTransform'):
                args = (args[0].cppPool,)

            # verify that all types match and do any necessary conversions
            result = []

            convertedArgs = []

            for i in range(len(inputNames)):
                arg = args[i]

                if type(args[i]).__module__ == 'numpy':
                    if not args[i].flags['C_CONTIGUOUS']:
                        arg = copy(args[i])

                goalType = _c.Edt(self.inputType(inputNames[i]))

                try:
                    convertedData = _c.convertData(arg, goalType)
                except TypeError:
                    raise TypeError('Error cannot convert argument %s to %s' \
                          %(str(_c.determineEdt(arg)), str(goalType)))

                convertedArgs.append(convertedData)

            results = self.__compute__(*convertedArgs)

            # we have to make an exceptional case for YamlInput, because we need
            # to wrap the Pool that it outputs w/ our python Pool from common.py
            if name in ('YamlInput', 'PoolAggregator', 'SvmClassifier', 'PCA', 'GaiaTransform', 'Extractor'):
                return _c.Pool(results)

            # MusicExtractor and FreesoundExtractor output two pools
            if name in ('MusicExtractor', 'FreesoundExtractor'):
                return (_c.Pool(results[0]), _c.Pool(results[1]))

            # In the case of MetadataReader, the 7th output is also a Pool
            if name in ('MetadataReader'):
                return results[:7] + (_c.Pool(results[7]),) + results[8:]

            else:
                return results
示例#8
0
    def __inner_init__(self, sinkEdt):
        # get vector form of sinkEdt, because we'll compare to given data input
        # which is a vector of something
        sinkEdt = sinkEdt.vectorize()

        if self.__initialized:
            if self.__initializedType == sinkEdt:
                return
            raise TypeError('VectorInput was already connected to another sink with a different type, original type: '+str(self.__initializedType)+' new type: '+str(sinkEdt))

        self.dataref = _c.convertData(self.dataref, sinkEdt)
        _essentia.VectorInput.__init__(self, self.dataref, str(sinkEdt))
        self.__initializedType = sinkEdt #_c.Edt
        self.__initialized = True
示例#9
0
def nextPowerTwo(arg):
    return _essentia.nextPowerTwo(_c.convertData(arg, _c.Edt.REAL))
示例#10
0
def lin2db(arg):
    return _essentia.lin2db( _c.convertData(arg, _c.Edt.REAL) )
示例#11
0
def isSilent(arg):
    return _essentia.isSilent( _c.convertData(arg, _c.Edt.VECTOR_REAL) )
示例#12
0
def instantPower(arg):
    return _essentia.instantPower( _c.convertData(arg, _c.Edt.VECTOR_REAL) )
示例#13
0
def postProcessTicks(arg1, arg2=None, arg3=None):
    if arg2 != None and arg3 != None:
        return _essentia.postProcessTicks(_c.convertData(arg1, _c.Edt.VECTOR_REAL),
                                          _c.convertData(arg2, _c.Edt.VECTOR_REAL),
                                          _c.convertData(arg3, _c.Edt.REAL))
    return _essentia.postProcessTicks(_c.convertData(arg1, _c.Edt.VECTOR_REAL))
示例#14
0
def amp2db(arg):
    return _essentia.amp2db(_c.convertData(arg, _c.Edt.REAL))
示例#15
0
def db2amp(arg):
    return _essentia.db2amp( _c.convertData(arg, _c.Edt.REAL) )
示例#16
0
def bark2hz(arg):
    return _essentia.bark2hz(_c.convertData(arg, _c.Edt.REAL))
示例#17
0
def derivative(array):
    return _essentia.derivative(_c.convertData(array, _c.Edt.VECTOR_REAL))
示例#18
0
def instantPower(arg):
    return _essentia.instantPower(_c.convertData(arg, _c.Edt.VECTOR_REAL))
示例#19
0
def normalize(array):
    return _essentia.normalize(_c.convertData(array, _c.Edt.VECTOR_REAL))
示例#20
0
def hz2mel(arg):
    return _essentia.hz2mel(_c.convertData(arg, _c.Edt.REAL))
示例#21
0
def mel2hz(arg):
    return _essentia.mel2hz(_c.convertData(arg, _c.Edt.REAL))
示例#22
0
def pow2db(arg):
    return _essentia.pow2db( _c.convertData(arg, _c.Edt.REAL) )
示例#23
0
def mel2hz(arg):
    return _essentia.mel2hz( _c.convertData(arg, _c.Edt.REAL) )
示例#24
0
def amp2db(arg):
    return _essentia.amp2db( _c.convertData(arg, _c.Edt.REAL) )
示例#25
0
def db2amp(arg):
    return _essentia.db2amp(_c.convertData(arg, _c.Edt.REAL))
示例#26
0
def bark2hz(arg):
    return _essentia.bark2hz( _c.convertData(arg, _c.Edt.REAL) )
示例#27
0
def derivative(array):
    return _essentia.derivative(_c.convertData(array, _c.Edt.VECTOR_REAL))
示例#28
0
def hz2mel(arg):
    return _essentia.hz2mel( _c.convertData(arg, _c.Edt.REAL) )
示例#29
0
def lin2db(arg):
    return _essentia.lin2db(_c.convertData(arg, _c.Edt.REAL))
示例#30
0
def normalize(array):
    return _essentia.normalize(_c.convertData(array, _c.Edt.VECTOR_REAL))
示例#31
0
def pow2db(arg):
    return _essentia.pow2db(_c.convertData(arg, _c.Edt.REAL))
示例#32
0
def isSilent(arg):
    return _essentia.isSilent(_c.convertData(arg, _c.Edt.VECTOR_REAL))
示例#33
0
def nextPowerTwo(arg):
    return _essentia.nextPowerTwo(_c.convertData(arg, _c.Edt.REAL))