Mercurial > hg > audiodb
changeset 147:a564e6d7a30c powertable
Add absolute and relative threshold arguments, and initialize variables
based on them.
Also initialize the power file for queries.
author | mas01cr |
---|---|
date | Wed, 31 Oct 2007 12:01:28 +0000 |
parents | c9c508be69b3 |
children | 8c1c6a5c1cc3 |
files | audioDB.cpp audioDB.h gengetopt.in |
diffstat | 3 files changed, 50 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB.cpp Wed Oct 31 10:20:09 2007 +0000 +++ b/audioDB.cpp Wed Oct 31 12:01:28 2007 +0000 @@ -310,6 +310,16 @@ usingTimes=1; } } + + if(args_info.power_given){ + powerFileName=args_info.power_arg; + if(strlen(powerFileName)>0){ + if (!(powerfd = open(powerFileName, O_RDONLY))) { + error("Could not open power file for reading", powerFileName, "open"); + } + usingPower = 1; + } + } // query type if(strncmp(args_info.QUERY_arg, "track", MAXSTR)==0) @@ -344,6 +354,18 @@ if(sequenceHop < 1 || sequenceHop > 1000) { error("seqhop out of range: 1 <= seqhop <= 1000"); } + + if (args_info.absolute_threshold_given) { + if (args_info.absolute_threshold_arg >= 0) { + error("absolute threshold out of range: should be negative"); + } + use_absolute_threshold = true; + absolute_threshold = args_info.absolute_threshold_arg; + } + if (args_info.relative_threshold_given) { + use_relative_threshold = true; + relative_threshold = args_info.relative_threshold_arg; + } return 0; } return -1; // no command found @@ -1089,6 +1111,20 @@ memcpy(db, dbH, O2_HEADERSIZE); } +bool audioDB::powers_acceptable(double p1, double p2) { + if (use_absolute_threshold) { + if ((p1 < absolute_threshold) || (p2 < absolute_threshold)) { + return false; + } + } + if (use_relative_threshold) { + if (fabs(p1-p2) > fabs(relative_threshold)) { + return false; + } + } + return true; +} + void audioDB::query(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse){ switch(queryType){
--- a/audioDB.h Wed Oct 31 10:20:09 2007 +0000 +++ b/audioDB.h Wed Oct 31 12:01:28 2007 +0000 @@ -164,6 +164,12 @@ unsigned port; double timesTol; double radius; + + bool use_absolute_threshold; + double absolute_threshold; + bool use_relative_threshold; + double relative_threshold; + // Timers struct timeval tv1; @@ -203,6 +209,7 @@ void ws_query(const char*dbName, const char *trackKey, const char* hostport); void l2norm(const char* dbName); void power_flag(const char *dbName); + bool powers_acceptable(double p1, double p2); void dump(const char* dbName); // web services @@ -250,4 +257,8 @@ isServer(0), \ port(0), \ timesTol(0.1), \ - radius(0) + radius(0), \ + use_absolute_threshold(false), \ + absolute_threshold(0.0), \ + use_relative_threshold(false), \ + relative_threshold(0.0)
--- a/gengetopt.in Wed Oct 31 10:20:09 2007 +0000 +++ b/gengetopt.in Wed Oct 31 12:01:28 2007 +0000 @@ -43,6 +43,8 @@ option "resultlength" r "maximum length of the result list." int typestr="length" default="10" optional option "sequencelength" l "length of sequences for sequence search." int typestr="length" default="16" dependon="QUERY" optional option "sequencehop" h "hop size of sequence window for sequence search." int typestr="hop" default="1" dependon="QUERY" optional +option "absolute-threshold" - "absolute power threshold for consideration of query or target sequence (in Bels)" double dependon="QUERY" optional +option "relative-threshold" - "relative power threshold between query and target sequence (in Bels)" double dependon="QUERY" optional section "Web Services" sectiondesc="These commands enable the database process to establish a connection via the internet and operate as separate client and server processes.\n" option "SERVER" s "run as standalone web service on named port." int typestr="port" default="14475" optional