diff options
author | Jamie Bullock <jamie@postlude.co.uk> | 2007-12-27 20:37:15 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@postlude.co.uk> | 2007-12-27 20:37:15 +0000 |
commit | 0c2e564c15c583a5274271a0bbacb237b180d500 (patch) | |
tree | f821a5c3785a6c6d0354b9e2f91431c8a3c3d544 /src/delta.c | |
parent | 24f2b43e28e755423cc0c319aafcf74e7db5b61b (diff) | |
download | LibXtract-0c2e564c15c583a5274271a0bbacb237b180d500.tar.gz LibXtract-0c2e564c15c583a5274271a0bbacb237b180d500.tar.bz2 LibXtract-0c2e564c15c583a5274271a0bbacb237b180d500.zip |
Added l-norm/spectral flux
Diffstat (limited to 'src/delta.c')
-rw-r--r-- | src/delta.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/delta.c b/src/delta.c index 6ca3794..79250e2 100644 --- a/src/delta.c +++ b/src/delta.c @@ -20,12 +20,49 @@ /* xtract_delta.c: defines functions that extract a feature as a single value from more than one input vector */ +#include <math.h> + #include "xtract/libxtract.h" int xtract_flux(const float *data, const int N, const void *argv , float *result){ + return xtract_lnorm(data, N, argv, result); - return XTRACT_FEATURE_NOT_IMPLEMENTED; +} + +int xtract_lnorm(const float *data, const int N, const void *argv , float *result){ + + int feature, + n, + type; + + float order, + temp = 0.f; + + order = *(float *)argv; + type = (int)*(float *)argv+1; + + order = order > 0 ? order : 1.f; + + switch(type){ + + case XTRACT_POSITIVE_SLOPE: + for(n = 0; n < N; n++){ + temp = powf(data[n], order); + if(data[n] > 0) + *result += temp; + } + break; + default: + for(n = 0; n < N; n++) + *result += powf(data[n], order); + break; + + } + + *result = powf(*result, 1.f / order); + + return XTRACT_SUCCESS; } @@ -41,9 +78,21 @@ int xtract_decay_time(const float *data, const int N, const void *argv, float *r } -int xtract_delta_feature(const float *data, const int N, const void *argv, float *result){ +int xtract_difference_vector(const float *data, const int N, const void *argv, float *result){ - return XTRACT_FEATURE_NOT_IMPLEMENTED; + float *frame1, + *frame2; -} + int n; + n = N >> 1; + + frame1 = data; + frame2 = data + n; + + while(n--) + result[n] = frame1[n] - frame2[n]; + + return XTRACT_SUCCESS; + +} |