Mercurial > hg > libxtract
changeset 29:a9154a4599c2
Added simpletest example
author | Jamie Bullock <jamie@postlude.co.uk> |
---|---|
date | Fri, 20 Oct 2006 11:30:55 +0000 |
parents | c9223f9082e0 |
children | 4df9012cebf1 |
files | config.h.in configure.in examples/Makefile.am examples/simpletest/Makefile.am examples/simpletest/simpletest.c src/Makefile.am src/libxtract.c xtract/Makefile.am xtract/libxtract.h |
diffstat | 9 files changed, 91 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/config.h.in Wed Oct 18 20:06:45 2006 +0000 +++ b/config.h.in Fri Oct 20 11:30:55 2006 +0000 @@ -3,6 +3,9 @@ /* Build the pd example */ #undef BUILD_PD_EXAMPLE +/* Build the simpletest example */ +#undef BUILD_SIMPLETEST + /* Build the vector functions */ #undef BUILD_VECTOR
--- a/configure.in Wed Oct 18 20:06:45 2006 +0000 +++ b/configure.in Fri Oct 20 11:30:55 2006 +0000 @@ -21,10 +21,6 @@ AC_ENABLE_STATIC(no) AC_ENABLE_SHARED(yes) AC_PROG_LIBTOOL -#AC_ARG_WITH(fftw, AC_HELP_STRING([--with-vector], [build vector features]), -# [ if test $withval = "yes"; then with_vector=yes ; -# else with_vector=no ; fi ], with_vector=no) - AC_CHECK_HEADERS([math.h, stdlib.h, stdio.h]) AC_CHECK_PROG([DOXYGEN], [doxygen], [doc], []) AC_SUBST(DOXYGEN) @@ -44,6 +40,14 @@ no) pd_example=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-pd_external) ;; esac],[pd_example=false]) + +AC_ARG_ENABLE(simpletest, + [ --enable-simpletest Compile the 'simpletest' example], + [case "${enableval}" in + yes) simpletest=true ;; + no) simpletest=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-simpletest) ;; + esac],[simpletest=false]) # libtool version: current:revision:age # @@ -61,7 +65,7 @@ XTRACT_SO_VERSION=0:0:0 CFLAGS="$CFLAGS -pedantic -ansi -O3" -LDFLAGS="$LDFLAGS -lm" +LDFLAGS="$LDFLAGS -lm --allow-shlib-undefined" AC_ARG_WITH(pd_dir, [ --with-pd-dir=path pd header path (default=/usr/local/include) ], @@ -82,7 +86,6 @@ ]) dnl Are we building with fftw? -#if [[ "$with_vector" = "yes" ]] ; then if [[ "$vector" = "true" ]] ; then LDFLAGS="$LDFLAGS -lfftw3f" AC_DEFINE([BUILD_VECTOR], [1], [Build the vector functions]) @@ -95,8 +98,16 @@ ]) fi +AM_CONDITIONAL(BUILD_VECTOR, test "x${vector}" = 'xtrue') -AM_CONDITIONAL(BUILD_VECTOR, test "x${vector}" = 'xtrue') + +dnl are we building the simpletest example +if [[ "$simpletest" = "true" ]] ; then + AC_DEFINE([BUILD_SIMPLETEST], [1], [Build the simpletest example]) +fi + +AM_CONDITIONAL(BUILD_SIMPLETEST, test "x${simpletest}" = 'xtrue') + dnl Are we building the PD examples? if [[ "$pd_example" = "true" ]] ; then @@ -201,7 +212,7 @@ AC_CONFIG_FILES([doc/documentation.doxygen libxtract.pc]) -AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile) +AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile) echo echo "**************************************************************" @@ -213,7 +224,12 @@ if test "$vector" = "true"; then echo "Fftw3: yes (using fftw3f)" else - echo "Fftw3: no (not using fftw3, the vector functions will not work)" + echo "Fftw3: no (not using fftw3, no vector functions)" +fi +if test "$simpletest" = "true"; then + echo "simpletest example: yes" +else + echo "simpletest example: no" fi if test "$pd_example" = "true"; then echo "PD external: yes" @@ -222,8 +238,9 @@ echo ${prefix}"/lib/doc/5.reference/xtract/" echo "You must make sure that this is in your PD help path" else - echo "PD external: no" + echo "PD external: no" fi + echo echo "**************************************************************" echo
--- a/examples/Makefile.am Wed Oct 18 20:06:45 2006 +0000 +++ b/examples/Makefile.am Fri Oct 20 11:30:55 2006 +0000 @@ -1,4 +1,9 @@ if BUILD_PD_EXAMPLE -SUBDIRS = puredata +PUREDATA_DIR = puredata endif +if BUILD_SIMPLETEST +SIMPLETEST_DIR = simpletest +endif + +SUBDIRS = $(PUREDATA_DIR) $(SIMPLETEST_DIR)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/simpletest/Makefile.am Fri Oct 20 11:30:55 2006 +0000 @@ -0,0 +1,8 @@ +MAINTAINERCLEANFILES = Makefile.in + +noinst_PROGRAMS = simpletest +INCLUDES = -I$(top_srcdir)/src +simpletest_SOURCES = simpletest.c +simpletest_LDADD = ../../src/libxtract.la + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/simpletest/simpletest.c Fri Oct 20 11:30:55 2006 +0000 @@ -0,0 +1,33 @@ +/* xtract~ - PD library for feature extraction +Copyright (C) 2006 Jamie Bullock + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#define XTRACT +#include "xtract/libxtract.h" +#include <stdio.h> + +int main() { + + float mean = 0, vector[] = {1, 2, 3}; + + xtract[MEAN]((void *)&vector, 6, NULL, (void *)&mean); + + printf("\nThe mean of [1, 2, 3] = %.1f\n\n", mean); + + return 0; + +}
--- a/src/Makefile.am Wed Oct 18 20:06:45 2006 +0000 +++ b/src/Makefile.am Fri Oct 20 11:30:55 2006 +0000 @@ -5,11 +5,13 @@ if BUILD_VECTOR VECTOR = vector.c +VECTOR_DEFINE = -DVECTORFUNCS else VECTOR = +VECTOR_DEFINE = endif lib_LTLIBRARIES = libxtract.la -libxtract_la_CFLAGS = -pedantic -ansi -g -O0 -ggdb +libxtract_la_CFLAGS = $(VECTOR_DEFINE) libxtract_la_SOURCES = $(SOURCES) $(VECTOR) libxtract_la_LDFLAGS = -shared
--- a/src/libxtract.c Wed Oct 18 20:06:45 2006 +0000 +++ b/src/libxtract.c Fri Oct 20 11:30:55 2006 +0000 @@ -55,6 +55,7 @@ xtract_hps, xtract_f0, /* xtract_vector.h */ +#ifdef VECTORFUNCS xtract_magnitude_spectrum, xtract_autocorrelation, xtract_autocorrelation_fft, @@ -64,6 +65,7 @@ xtract_dct, xtract_bark_coefficients, xtract_peaks, +#endif /* xtract_delta.h */ xtract_flux, xtract_attack_time,
--- a/xtract/Makefile.am Wed Oct 18 20:06:45 2006 +0000 +++ b/xtract/Makefile.am Fri Oct 20 11:30:55 2006 +0000 @@ -1,5 +1,11 @@ libxtractdir = $(includedir)/xtract +if BUILD_VECTOR +XTRACT_VECTOR = xtract_vector.h +else +XTRACT_VECTOR = +endif + libxtract_HEADERS = libxtract.h xtract_macros.h xtract_types.h xtract_delta.h \ - xtract_scalar.h xtract_vector.h + xtract_scalar.h $(XTRACT_VECTOR)
--- a/xtract/libxtract.h Wed Oct 18 20:06:45 2006 +0000 +++ b/xtract/libxtract.h Fri Oct 20 11:30:55 2006 +0000 @@ -67,7 +67,7 @@ AVERAGE_DEVIATION, SKEWNESS, KURTOSIS, - CENTROID, + CENTROID, IRREGULARITY_K, IRREGULARITY_J, TRISTIMULUS_1, @@ -125,7 +125,7 @@ MALLOC_FAILED, BAD_ARGV, BAD_VECTOR_SIZE, - NO_RESULT + NO_RESULT }; /**