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))
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
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
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)
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
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
def nextPowerTwo(arg): return _essentia.nextPowerTwo(_c.convertData(arg, _c.Edt.REAL))
def lin2db(arg): return _essentia.lin2db( _c.convertData(arg, _c.Edt.REAL) )
def isSilent(arg): return _essentia.isSilent( _c.convertData(arg, _c.Edt.VECTOR_REAL) )
def instantPower(arg): return _essentia.instantPower( _c.convertData(arg, _c.Edt.VECTOR_REAL) )
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))
def amp2db(arg): return _essentia.amp2db(_c.convertData(arg, _c.Edt.REAL))
def db2amp(arg): return _essentia.db2amp( _c.convertData(arg, _c.Edt.REAL) )
def bark2hz(arg): return _essentia.bark2hz(_c.convertData(arg, _c.Edt.REAL))
def derivative(array): return _essentia.derivative(_c.convertData(array, _c.Edt.VECTOR_REAL))
def instantPower(arg): return _essentia.instantPower(_c.convertData(arg, _c.Edt.VECTOR_REAL))
def normalize(array): return _essentia.normalize(_c.convertData(array, _c.Edt.VECTOR_REAL))
def hz2mel(arg): return _essentia.hz2mel(_c.convertData(arg, _c.Edt.REAL))
def mel2hz(arg): return _essentia.mel2hz(_c.convertData(arg, _c.Edt.REAL))
def pow2db(arg): return _essentia.pow2db( _c.convertData(arg, _c.Edt.REAL) )
def mel2hz(arg): return _essentia.mel2hz( _c.convertData(arg, _c.Edt.REAL) )
def amp2db(arg): return _essentia.amp2db( _c.convertData(arg, _c.Edt.REAL) )
def db2amp(arg): return _essentia.db2amp(_c.convertData(arg, _c.Edt.REAL))
def bark2hz(arg): return _essentia.bark2hz( _c.convertData(arg, _c.Edt.REAL) )
def hz2mel(arg): return _essentia.hz2mel( _c.convertData(arg, _c.Edt.REAL) )
def lin2db(arg): return _essentia.lin2db(_c.convertData(arg, _c.Edt.REAL))
def pow2db(arg): return _essentia.pow2db(_c.convertData(arg, _c.Edt.REAL))
def isSilent(arg): return _essentia.isSilent(_c.convertData(arg, _c.Edt.VECTOR_REAL))