aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJamie Bullock <jamie@jamiebullock.com>2014-02-11 16:39:41 +0000
committerJamie Bullock <jamie@jamiebullock.com>2014-02-11 16:39:41 +0000
commit1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7 (patch)
tree053092e1da54d0736ffd2f8f96d54ecae20b6eba /examples
parent4805c96fce84b57ed44327a6e4e91a9d970ea27a (diff)
downloadLibXtract-1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7.tar.gz
LibXtract-1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7.tar.bz2
LibXtract-1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7.zip
Make xtract_lowest_value() return XTRACT_NO_RESULT if all values in the input data are below or equal to threshold value. Fixes #46
If XTRACT_NO_RESULT is returned, *result will be set to DBL_MAX
Diffstat (limited to 'examples')
-rw-r--r--examples/simpletest/simpletest.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/simpletest/simpletest.c b/examples/simpletest/simpletest.c
index 14fd6ee..443de22 100644
--- a/examples/simpletest/simpletest.c
+++ b/examples/simpletest/simpletest.c
@@ -98,6 +98,7 @@ int main(void)
double f0 = 0.0;
double flux = 0.0;
double centroid = 0.0;
+ double lowest = 0.0;
double spectrum[BLOCKSIZE] = {0};
double windowed[BLOCKSIZE] = {0};
double peaks[BLOCKSIZE] = {0};
@@ -109,6 +110,7 @@ int main(void)
double argd[4] = {0};
double samplerate = 44100.0;
int n;
+ int rv = XTRACT_SUCCESS;
xtract_mel_filter mel_filters;
fill_wavetable(344.53125f, NOISE); // 344.53125f = 128 samples @ 44100 Hz
@@ -122,6 +124,19 @@ int main(void)
xtract[XTRACT_MEAN](wavetable, BLOCKSIZE, NULL, &mean);
printf("\nInput mean = %.2f\n\n", mean); /* We expect this to be zero for a square wave */
+ /* get the lowest value in the input */
+ argd[0] = -.5;
+ rv = xtract[XTRACT_LOWEST_VALUE](wavetable, BLOCKSIZE, argd, &lowest);
+
+ if (rv == XTRACT_SUCCESS)
+ {
+ printf("\nLowest value = %.6f\n\n", lowest);
+ }
+ else
+ {
+ printf("\nUnable to get lowest value, all values below threshold?\n\n");
+ }
+ exit(0);
/* create the window function */
window = xtract_init_window(BLOCKSIZE, XTRACT_HANN);
xtract_windowed(wavetable, BLOCKSIZE, window, windowed);