Previous topic

classifier module

Next topic

audiodb module

This Page

pyadb module

pyadb.py

public access and class structure for python audioDb api bindings.

Created by Benjamin Fields on 2009-09-22. Copyright (c) 2009 Goldsmith University of London.

class pyadb.Pyadb(path, mode='w', datasize=0, ntracks=0, datadim=0)

Pyadb class. Allows for creation, access, insertion and query of an audioDB vector matching database.

configCheck(scrub=False)
examine self.configQuery dict. For each key encouters confirm it is in the validConfigTerms list and if appropriate, type check. If scrub is False, leave unexpected keys and values alone and return False, if scrub try to correct errors (attempt type casts and remove unexpected entries) and continue. If self.configQuery only contains expected keys with correctly typed values, return True. See Pyadb.validConfigTerms for allowed keys and types. Note also that include/exclude key lists memebers or string switched are not verified here, but rather when they are converted to const char * in the C api call and if malformed, an error will be rasied from there. Valid keys and values in queryconfig: {seqLength : Int Sequence Length, seqStart : Int offset from start for key, exhaustive : boolean - True for exhaustive (false by default), falsePositives: boolean - True to keep fps (false by defaults), accumulation : [“db”|”track”|”one2one”] (“db” by default), distance : [“dot”|”eucNorm”|”euclidean”] (“dot” by default), npoints : int number of points per track, ntracks : max number of results returned in db accu mode, includeKeys : list of strings to include (use all by default), excludeKeys : list of strings to exclude (none by default), radius : double of nnRadius (1.0 default, overrides npoints if specified), absThres : double absolute power threshold (db must have power), relThres : double relative power threshold (db must have power), durRatio : double time expansion/compresion ratio, hopSize : int hopsize (1 by default)])->resultDict resFmt : [“list”|”dict”](“dict” by default)}
insert(featFile=None, powerFile=None, timesFile=None, featData=None, powerData=None, timesData=None, key=None)
Insert features into database. Can be done with data provided directly or by giving a path to a binary fftExtract style feature file. If power and/or timing is engaged in the database header, it must be provided (via the same means as the feature) or a Usage exception will be raised. Power files should be of the same binary type as features. Times files should be the ascii number length of time in seconds from the begining of the file to segment start, one per line. If providing data directly, featData should be a numpy array with shape= (number of Dimensions, number of Vectors)
liszt()
run _pyadb_liszt to get a list of database keys
query(key=None, featData=None, strictConfig=True)
query the database. Query parameters as defined in self.configQuery. For details on this consult the doc string in the configCheck method.
retrieve_datum(key, **args)
run _pyadb_retrieveDatum to retrieve data by key: features=True, to get features powers=True, to get Powers times=True, to get Times
status()
update attributes and return them as a dict
exception pyadb.Usage(msg)
error to indicate that a method has been called with incorrect args