Mercurial > hg > libxtract
changeset 123:efb1c1ae2ba8
- reimplemented xtract_spectral_variance() xtract_spectral_skewness() and xtract_spectral_kurtosis() using correct maths
- removed xtract_spectral_average_deviation()
author | Jamie Bullock <jamie@postlude.co.uk> |
---|---|
date | Wed, 30 Mar 2011 10:51:39 +0000 |
parents | 571c53e87dbd |
children | fc4bc58b92da |
files | Makefile.am configure.in doc/Makefile.am src/descriptors.c src/libxtract.c src/scalar.c xtract/libxtract.h xtract/xtract_scalar.h |
diffstat | 8 files changed, 63 insertions(+), 71 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.am Wed Mar 30 10:05:07 2011 +0000 +++ b/Makefile.am Wed Mar 30 10:51:39 2011 +0000 @@ -11,4 +11,4 @@ ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = bootstrap autogen.sh README TODO +EXTRA_DIST = examples/MSP bootstrap autogen.sh README TODO
--- a/configure.in Wed Mar 30 10:05:07 2011 +0000 +++ b/configure.in Wed Mar 30 10:51:39 2011 +0000 @@ -4,18 +4,20 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 6) # Increment for fixes -m4_define(libxtract_fix_version, 1) +m4_define(libxtract_fix_version, 4) # Development status m4_define(libIntegra_dev_status, [beta]) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) - + PACKAGE=libxtract -AC_INIT(libxtract, libxtract_version, libxtract-devel@lists.sourceforge.net) +AC_INIT([libxtract], [libxtract_version], [libxtract-devel@lists.sourceforge.net]) AC_DEFINE(LIBXTRACT_VERSION, libxtract_version, [LibXtract Version]) -AM_INIT_AUTOMAKE($PACKAGE, $LIBXTRACT_VERSION) +dnl AM_INIT_AUTOMAKE($PACKAGE, $LIBXTRACT_VERSION) +AM_INIT_AUTOMAKE(1.6) AM_CONFIG_HEADER(config.h) +AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CC AC_PROG_LIBTOOL AC_PROG_INSTALL @@ -240,57 +242,57 @@ if test -z "$GCC"; then case $host in *-*-irix*) - dnl If we're on IRIX, we wanna use cc even if gcc - dnl is there (unless the user has overriden us)... - if test -z "$CC"; then - CC=cc - fi + dnl If we're on IRIX, we wanna use cc even if gcc + dnl is there (unless the user has overriden us)... + if test -z "$CC"; then + CC=cc + fi ;; sparc-sun-solaris*) - PD_CFLAGS="-xO4 -fast -w -fsimple -native -xcg92" + PD_CFLAGS="-xO4 -fast -w -fsimple -native -xcg92" ;; *) - PD_CFLAGS="-O" + PD_CFLAGS="-O" ;; esac else case $host in *86-*-linux*) - PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused" - PD_LDFLAGS="$PD_LDFLAGS -shared -export_dynamic" - dnl we could test for bad glibc here, but don't - PD_SUFFIX=pd_linux + PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused" + PD_LDFLAGS="$PD_LDFLAGS -shared" + dnl we could test for bad glibc here, but don't + PD_SUFFIX=pd_linux ;; powerpc-*-linux*) - PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes" - PD_LDFLAGS="$PD_LDFLAGS -shared" - PD_SUFFIX=pd_linux + PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes" + PD_LDFLAGS="$PD_LDFLAGS -shared" + PD_SUFFIX=pd_linux ;; *-*-linux*) - PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -fPIC" - PD_LDFLAGS="$PD_LDFLAGS -shared -export_dynamic" - PD_SUFFIX=pd_linux + PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -fPIC" + PD_LDFLAGS="$PD_LDFLAGS -shared -export_dynamic" + PD_SUFFIX=pd_linux ;; sparc-sun-*) - echo "YOU HAVE A SPARC STATION, not setting any flags, not supported yet" + echo "YOU HAVE A SPARC STATION, not setting any flags, not supported yet" ;; *86-*-darwin*) - PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes" - PD_LDFLAGS="$PD_LDFLAGS -dynamiclib -mmacosx-version-min=10.3 -undefined dynamic_lookup -single_module" - PD_SUFFIX=pd_darwin + PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes" + PD_LDFLAGS="$PD_LDFLAGS -dynamiclib -mmacosx-version-min=10.3 -undefined dynamic_lookup -single_module" + PD_SUFFIX=pd_darwin ;; *-*-darwin*) - PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes" - PD_LDFLAGS="$PD_LDFLAGS -bundle -arch ppc -undefined suppress -flat_namespace" - PD_SUFFIX=pd_darwin + PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes" + PD_LDFLAGS="$PD_LDFLAGS -bundle -arch ppc -undefined suppress -flat_namespace" + PD_SUFFIX=pd_darwin ;; *) dnl assume unix - PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1" - PD_LDFLAGS="$PD_LDFLAGS -shared" - PD_SUFFIX=pd_linux + PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1" + PD_LDFLAGS="$PD_LDFLAGS -shared" + PD_SUFFIX=pd_linux ;; esac fi
--- a/doc/Makefile.am Wed Mar 30 10:05:07 2011 +0000 +++ b/doc/Makefile.am Wed Mar 30 10:51:39 2011 +0000 @@ -6,8 +6,6 @@ DOX=documentation.doxygen -EXTRA_DIST= - INSTIMAGES=html/doxygen.png DOC_STAMPS=html-build.stamp
--- a/src/descriptors.c Wed Mar 30 10:05:07 2011 +0000 +++ b/src/descriptors.c Wed Mar 30 10:51:39 2011 +0000 @@ -62,7 +62,7 @@ case XTRACT_DIFFERENCE_VECTOR: case XTRACT_AVERAGE_DEVIATION: case XTRACT_SPECTRAL_STANDARD_DEVIATION: - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: */ case XTRACT_LOWEST_VALUE: case XTRACT_TONALITY: case XTRACT_MFCC: @@ -206,9 +206,9 @@ case XTRACT_SPECTRAL_STANDARD_DEVIATION: *argv_donor = XTRACT_SPECTRAL_VARIANCE; break; - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: *argv_donor = XTRACT_SPECTRAL_MEAN; - break; + break; */ case XTRACT_SPECTRAL_INHARMONICITY: *argv_donor = XTRACT_FAILSAFE_F0; break; @@ -300,7 +300,7 @@ case XTRACT_SPECTRAL_MEAN: case XTRACT_SPECTRAL_VARIANCE: case XTRACT_SPECTRAL_STANDARD_DEVIATION: - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: */ case XTRACT_SPECTRAL_SKEWNESS: case XTRACT_SPECTRAL_KURTOSIS: case XTRACT_SPECTRAL_CENTROID: @@ -432,7 +432,7 @@ case XTRACT_SPECTRAL_MEAN: case XTRACT_SPECTRAL_VARIANCE: case XTRACT_SPECTRAL_STANDARD_DEVIATION: - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: */ case XTRACT_SPECTRAL_SKEWNESS: case XTRACT_SPECTRAL_KURTOSIS: case XTRACT_SPECTRAL_CENTROID: @@ -530,7 +530,7 @@ "Extract the standard deviation of an audio spectrum"); strcpy(author, ""); break; - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: strcpy(name, "spectral_average_deviation"); strcpy(p_name, "Spectral Average Deviation"); strcpy(desc, @@ -539,6 +539,7 @@ "Extract the average deviation of an audio spectrum"); strcpy(author, ""); break; + */ case XTRACT_ROLLOFF: strcpy(name, "rolloff"); strcpy(p_name, "Spectral Rolloff"); @@ -963,7 +964,7 @@ case XTRACT_AVERAGE_DEVIATION: case XTRACT_SPECTRAL_VARIANCE: case XTRACT_SPECTRAL_STANDARD_DEVIATION: - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: */ case XTRACT_SPECTRAL_INHARMONICITY: case XTRACT_LOWEST_VALUE: case XTRACT_F0: @@ -1059,7 +1060,7 @@ case XTRACT_SPECTRAL_MEAN: case XTRACT_SPECTRAL_VARIANCE: case XTRACT_SPECTRAL_STANDARD_DEVIATION: - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: */ case XTRACT_SPECTRAL_SKEWNESS: case XTRACT_SPECTRAL_KURTOSIS: case XTRACT_SPECTRAL_CENTROID: @@ -1135,7 +1136,7 @@ case XTRACT_SPECTRAL_MEAN: case XTRACT_SPECTRAL_VARIANCE: case XTRACT_SPECTRAL_STANDARD_DEVIATION: - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: */ case XTRACT_SPECTRAL_SKEWNESS: case XTRACT_SPECTRAL_KURTOSIS: case XTRACT_SPECTRAL_CENTROID: @@ -1227,7 +1228,7 @@ case XTRACT_SPECTRAL_MEAN: case XTRACT_SPECTRAL_VARIANCE: case XTRACT_SPECTRAL_STANDARD_DEVIATION: - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + /* case XTRACT_SPECTRAL_AVERAGE_DEVIATION: */ case XTRACT_SPECTRAL_CENTROID: case XTRACT_SPREAD: case XTRACT_F0:
--- a/src/libxtract.c Wed Mar 30 10:05:07 2011 +0000 +++ b/src/libxtract.c Wed Mar 30 10:51:39 2011 +0000 @@ -27,7 +27,7 @@ xtract_mean, xtract_variance, xtract_standard_deviation, - xtract_average_deviation, + /* xtract_average_deviation, */ xtract_skewness, xtract_kurtosis, xtract_spectral_mean,
--- a/src/scalar.c Wed Mar 30 10:05:07 2011 +0000 +++ b/src/scalar.c Wed Mar 30 10:51:39 2011 +0000 @@ -186,11 +186,11 @@ *result = 0.f; while(m--){ - A += amps[m]; - *result += powf((freqs[m] - *(float *)argv) * amps[m], 2); + A += amps[m]; + *result += powf(freqs[m] - ((float *)argv)[0], 2) * amps[m]; } - *result = *result / (A /*- 1*/); + *result = *result / A; return XTRACT_SUCCESS; } @@ -202,7 +202,7 @@ return XTRACT_SUCCESS; } -int xtract_spectral_average_deviation(const float *data, const int N, const void *argv, float *result){ +/*int xtract_spectral_average_deviation(const float *data, const int N, const void *argv, float *result){ int m; float A = 0.f; @@ -216,19 +216,18 @@ *result = 0.f; while(m--){ - A += amps[m]; - *result += fabsf((amps[m] * freqs[m]) - *(float *)argv); + A += amps[m]; + *result += fabsf((amps[m] * freqs[m]) - *(float *)argv); } *result /= A; return XTRACT_SUCCESS; -} +}*/ int xtract_spectral_skewness(const float *data, const int N, const void *argv, float *result){ int m; - float temp, A = 0.f; const float *freqs, *amps; m = N >> 1; @@ -238,14 +237,10 @@ *result = 0.f; - while(m--){ - A += amps[m]; - temp = ((amps[m] * freqs[m]) - - ((float *)argv)[0]) / ((float *)argv)[1]; - *result += powf(temp, 3); - } + while(m--) + *result += powf(freqs[m] - ((float *)argv)[0], 3) * amps[m]; - *result /= A; + *result /= powf(((float *)argv)[1], 3); return XTRACT_SUCCESS; } @@ -253,7 +248,6 @@ int xtract_spectral_kurtosis(const float *data, const int N, const void *argv, float *result){ int m; - float temp, A = 0.f; const float *freqs, *amps; m = N >> 1; @@ -263,14 +257,10 @@ *result = 0.f; - while(m--){ - A += amps[m]; - temp = ((amps[m] * freqs[m]) - - ((float *)argv)[0]) / ((float *)argv)[1]; - *result += powf(temp, 4); - } + while(m--) + *result += powf(freqs[m] - ((float *)argv)[0], 4) * amps[m]; - *result /= A; + *result /= powf(((float *)argv)[1], 4); *result -= 3.0f; return XTRACT_SUCCESS;
--- a/xtract/libxtract.h Wed Mar 30 10:05:07 2011 +0000 +++ b/xtract/libxtract.h Wed Mar 30 10:51:39 2011 +0000 @@ -68,7 +68,7 @@ * @{ */ -#define XTRACT_FEATURES 60 +#define XTRACT_FEATURES 59 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */ enum xtract_features_ { @@ -81,7 +81,7 @@ XTRACT_SPECTRAL_MEAN, XTRACT_SPECTRAL_VARIANCE, XTRACT_SPECTRAL_STANDARD_DEVIATION, - XTRACT_SPECTRAL_AVERAGE_DEVIATION, + /*XTRACT_SPECTRAL_AVERAGE_DEVIATION, */ XTRACT_SPECTRAL_SKEWNESS, XTRACT_SPECTRAL_KURTOSIS, XTRACT_SPECTRAL_CENTROID,
--- a/xtract/xtract_scalar.h Wed Mar 30 10:05:07 2011 +0000 +++ b/xtract/xtract_scalar.h Wed Mar 30 10:51:39 2011 +0000 @@ -71,7 +71,8 @@ * \param *argv: a pointer to a float representing the mean of the input vector * \param *result: the average deviation of N values from the array pointed to by *data */ -int xtract_average_deviation(const float *data, const int N, const void *argv, float *result); +/*int xtract_average_deviation(const float *data, const int N, const void *argv, float *result); + */ /** \brief Extract the skewness of an input vector *