Exemplo n.º 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))
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 9
0
def nextPowerTwo(arg):
    return _essentia.nextPowerTwo(_c.convertData(arg, _c.Edt.REAL))
Exemplo n.º 10
0
def lin2db(arg):
    return _essentia.lin2db( _c.convertData(arg, _c.Edt.REAL) )
Exemplo n.º 11
0
def isSilent(arg):
    return _essentia.isSilent( _c.convertData(arg, _c.Edt.VECTOR_REAL) )
Exemplo n.º 12
0
def instantPower(arg):
    return _essentia.instantPower( _c.convertData(arg, _c.Edt.VECTOR_REAL) )
Exemplo n.º 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))
Exemplo n.º 14
0
def amp2db(arg):
    return _essentia.amp2db(_c.convertData(arg, _c.Edt.REAL))
Exemplo n.º 15
0
def db2amp(arg):
    return _essentia.db2amp( _c.convertData(arg, _c.Edt.REAL) )
Exemplo n.º 16
0
def bark2hz(arg):
    return _essentia.bark2hz(_c.convertData(arg, _c.Edt.REAL))
Exemplo n.º 17
0
def derivative(array):
    return _essentia.derivative(_c.convertData(array, _c.Edt.VECTOR_REAL))
Exemplo n.º 18
0
def instantPower(arg):
    return _essentia.instantPower(_c.convertData(arg, _c.Edt.VECTOR_REAL))
Exemplo n.º 19
0
def normalize(array):
    return _essentia.normalize(_c.convertData(array, _c.Edt.VECTOR_REAL))
Exemplo n.º 20
0
def hz2mel(arg):
    return _essentia.hz2mel(_c.convertData(arg, _c.Edt.REAL))
Exemplo n.º 21
0
def mel2hz(arg):
    return _essentia.mel2hz(_c.convertData(arg, _c.Edt.REAL))
Exemplo n.º 22
0
def pow2db(arg):
    return _essentia.pow2db( _c.convertData(arg, _c.Edt.REAL) )
Exemplo n.º 23
0
def mel2hz(arg):
    return _essentia.mel2hz( _c.convertData(arg, _c.Edt.REAL) )
Exemplo n.º 24
0
def amp2db(arg):
    return _essentia.amp2db( _c.convertData(arg, _c.Edt.REAL) )
Exemplo n.º 25
0
def db2amp(arg):
    return _essentia.db2amp(_c.convertData(arg, _c.Edt.REAL))
Exemplo n.º 26
0
def bark2hz(arg):
    return _essentia.bark2hz( _c.convertData(arg, _c.Edt.REAL) )
Exemplo n.º 27
0
def derivative(array):
    return _essentia.derivative(_c.convertData(array, _c.Edt.VECTOR_REAL))
Exemplo n.º 28
0
def hz2mel(arg):
    return _essentia.hz2mel( _c.convertData(arg, _c.Edt.REAL) )
Exemplo n.º 29
0
def lin2db(arg):
    return _essentia.lin2db(_c.convertData(arg, _c.Edt.REAL))
Exemplo n.º 30
0
def normalize(array):
    return _essentia.normalize(_c.convertData(array, _c.Edt.VECTOR_REAL))
Exemplo n.º 31
0
def pow2db(arg):
    return _essentia.pow2db(_c.convertData(arg, _c.Edt.REAL))
Exemplo n.º 32
0
def isSilent(arg):
    return _essentia.isSilent(_c.convertData(arg, _c.Edt.VECTOR_REAL))
Exemplo n.º 33
0
def nextPowerTwo(arg):
    return _essentia.nextPowerTwo(_c.convertData(arg, _c.Edt.REAL))