aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2006-10-08 15:01:54 +0000
committerJamie Bullock <jamie@postlude.co.uk>2006-10-08 15:01:54 +0000
commit89803e1f2ff7a54f0c8a6283d9b9f96e62a35af2 (patch)
tree5bfe93f591ab05509ee18f5d988352dde71403aa
parent67d61abd8be9314aa518fd6cd0b1684db8142e2e (diff)
downloadLibXtract-89803e1f2ff7a54f0c8a6283d9b9f96e62a35af2.tar.gz
LibXtract-89803e1f2ff7a54f0c8a6283d9b9f96e62a35af2.tar.bz2
LibXtract-89803e1f2ff7a54f0c8a6283d9b9f96e62a35af2.zip
Tweaks to enable build on OS X
-rw-r--r--configure.in79
-rw-r--r--examples/puredata/Makefile.am12
-rw-r--r--examples/puredata/xtract~.c1
-rw-r--r--xtract/libxtract.h26
4 files changed, 74 insertions, 44 deletions
diff --git a/configure.in b/configure.in
index a9990dd..ee7998b 100644
--- a/configure.in
+++ b/configure.in
@@ -27,12 +27,10 @@ AC_ARG_ENABLE(vector,
AC_ARG_ENABLE(pd_example,
[ --enable-pd_example Compile the Pure Data external example],
[case "${enableval}" in
- yes) vector=true ;;
- no) vector=false ;;
+ yes) pd_example=true ;;
+ no) pd_example=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-pd_external) ;;
- esac],[vector=false])
-
-
+ esac],[pd_example=false])
# libtool version: current:revision:age
#
@@ -49,47 +47,57 @@ AC_ARG_ENABLE(pd_example,
# age to 0.
XTRACT_SO_VERSION=0:0:0
-CFLAGS="-pedantic -ansi"
-LDFLAGS="-lm"
+CFLAGS="$CFLAGS -pedantic -ansi"
+LDFLAGS="$LDFLAGS -lm"
+
+AC_ARG_WITH(pd_dir,
+ [ --with-pd-dir=path pd header path (default=/usr/local/include) ],
+ [
+ CFLAGS="$CFLAGS -I$withval"
+ echo
+ echo "pd dir is $withval"
+ echo
+ ])
+
+AC_ARG_WITH(fftw3_dir,
+ [ --with-fftw3-dir=path fftw3 header path (default=/usr/local/include) ],
+ [
+ CFLAGS="$CFLAGS -I$withval"
+ echo
+ echo "fftw3 dir is $withval"
+ echo
+ ])
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])
+ AC_CHECK_HEADER(fftw3.h, [have_fftw3_hdr=yes ], [
+ have_pd_hdr=no
+ echo
+ echo "no fftw3.h header found. try with option --with-fftw3-dir=/path/to/fftw3/header"
+ echo
+ exit
+ ])
fi
AM_CONDITIONAL(BUILD_VECTOR, test "x${vector}" = 'xtrue')
+dnl Are we building the PD examples?
if [[ "$pd_example" = "true" ]] ; then
+ PD_SOURCES="xtract~.c"
AC_DEFINE([BUILD_PD_EXAMPLE], [1], [Build the pd example])
-dnl At some point we need to support other platforms, and include checks
- pd_suffix=pd_linux
-fi
-
-dnl ------------------------------------------
-dnl ---- add PureData includes dir
-dnl ---- usually /usr/local/include
-dnl ------------------------------------------
-AC_ARG_WITH(pd_dir,
- [ --with-pd-dir=path pd header path (default=/usr/local/include) ],
- [
- CFLAGS="$CFLAGS -I$withval"
- echo
- echo "pd dir is $withval"
- echo
- ])
-
-dnl ------------------------------------------
-dnl ---- check for PureData Header
-dnl ------------------------------------------
-AC_CHECK_HEADER(m_pd.h, [have_pd_hdr=yes ], [
+ AC_CHECK_HEADER(m_pd.h, [have_pd_hdr=yes ], [
have_pd_hdr=no
echo
echo "no m_pd.h header found. try with option --with-pd-dir=/path/to/pd/src"
echo
exit
])
+dnl At some point we need to support other platforms, and include checks
+dnl pd_suffix=pd_linux
+fi
AM_CONDITIONAL(BUILD_PD_EXAMPLE, test "x${pd_example}" = 'xtrue')
@@ -99,7 +107,7 @@ dnl ---- taken from libvorbis configure.in
dnl ------------------------------------------
dnl AC_CANONICAL_HOST
-dnl AC_SUBST(PD_CFLAGS,"$PD_CFLAGS -DUNIX -Wno-deprecated -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1")
+dnl AC_SUBST(PD_CFLAGS,"$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1")
dnl AC_SUBST(PD_LDFLAGS,"$PD_LDFLAGS -shared")
dnl pd_ldflags="$PD_LDFLAGS -L/usr/local/lib -ldl"
if test -z "$GCC"; then
@@ -122,18 +130,18 @@ else
case $host in
*86-*-linux*)
- PD_CFLAGS="$PD_CFLAGS -DUNIX -Wno-deprecated -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1"
+ PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1"
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 -Wno-deprecated -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1 "
+ PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1 "
PD_LDFLAGS="$PD_LDFLAGS -shared"
PD_SUFFIX=pd_linux
;;
*-*-linux*)
- PD_CFLAGS="$PD_CFLAGS -DUNIX -Wno-deprecated -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1 -fPIC"
+ PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1 -fPIC"
PD_LDFLAGS="$PD_LDFLAGS -shared"
PD_SUFFIX=pd_linux
;;
@@ -141,22 +149,25 @@ else
echo "YOU HAVE A SPARC STATION, not setting any flags, not supported yet"
;;
*-*-darwin*)
- PD_CFLAGS="$PD_CFLAGS -DUNIX -Wno-deprecated -Wall -Wimplicit -Wunused -Wmissing-prototypes -O3 "
+ PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O3 "
PD_LDFLAGS="$PD_LDFLAGS -bundle -undefined suppress -flat_namespace"
PD_SUFFIX=pd_darwin
;;
*)
dnl assume unix
- PD_CFLAGS="$PD_CFLAGS -DUNIX -Wno-deprecated -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1"
+ PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1"
PD_LDFLAGS="$PD_LDFLAGS -shared"
PD_SUFFIX=pd_linux
;;
esac
fi
+PD_CFLAGS="$PD_CFLAGS -DPD"
+
AC_SUBST(PD_CFLAGS)
AC_SUBST(PD_LDFLAGS)
AC_SUBST(PD_SUFFIX)
+AC_SUBST(PD_SOURCES)
AC_CONFIG_FILES([doc/documentation.doxygen])
diff --git a/examples/puredata/Makefile.am b/examples/puredata/Makefile.am
index f3eb08e..c45fc32 100644
--- a/examples/puredata/Makefile.am
+++ b/examples/puredata/Makefile.am
@@ -8,14 +8,9 @@ pdinstalldir = $(pddir)/extra
pdinstallrefdir = $(pddir)/doc/5.reference
pdinstallexpdir = $(pddir)/doc/xtract
-# Automake won't accept something ending in ".pd_linux" as a library
-pdinstall_PROGRAMS = xtract~.@PD_SUFFIX@
+pdinstall_PROGRAMS = xtract.@PD_SUFFIX@
-if BUILD_PD_EXAMPLE
-xtract_pd_linux_SOURCES = xtract~.c
-else
-xtract_pd_linux_SOURCES =
-endif
+xtract_@PD_SUFFIX@_SOURCES = xtract~.c
pdincludedir = $(pddir)/src
@@ -31,6 +26,9 @@ AM_LDFLAGS = @PD_LDFLAGS@ -lxtract
## Install the documentation.
+install:
+ -mv xtract.@PD_SUFFIX@ $(pdinstalldir)/xtract~.@PD_SUFFIX@
+
#pdinstallref_DATA = \
# help/aubioonset-help.pd \
# help/aubioquiet-help.pd \
diff --git a/examples/puredata/xtract~.c b/examples/puredata/xtract~.c
index 0fa5926..035a43d 100644
--- a/examples/puredata/xtract~.c
+++ b/examples/puredata/xtract~.c
@@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
/* calculates the spectral xtract of one frame, given peak frequency and amplitude to first and second inputs respectively */
+#define XTRACT
#include "xtract/libxtract.h"
#include "m_pd.h"
diff --git a/xtract/libxtract.h b/xtract/libxtract.h
index 921eb4d..f1da9c1 100644
--- a/xtract/libxtract.h
+++ b/xtract/libxtract.h
@@ -38,7 +38,7 @@ extern "C" {
#include "xtract_types.h"
#include "xtract_macros.h"
-#define XTRACT_FEATURES 41
+#define XTRACT_FEATURES 42
#define LOG_LIMIT 10e-10
#define VERY_BIG_NUMBER 2e10
#define SR_LIMIT 192000
@@ -74,7 +74,7 @@ enum features_ {
SLOPE,
LOWEST_MATCH,
HPS,
- F0,
+ F0,
MAGNITUDE_SPECTRUM,
AUTOCORRELATION,
AUTOCORRELATION_FFT,
@@ -136,10 +136,30 @@ enum return_codes_ {
* All functions return an integer error code as descibed in the enumeration
* return_codes_
*
+ * The preprocessor macro: XTRACT must be defined before this can be used
+ *
* example:<br>
- * xtract[PEAKS](amplitude_spectrum, 512, threshold, peaks)
+ *
+ * #include <stdio.h>
+ * #define XTRACT
+ * #include "libxtract.h"
+ *
+ * main () {
+ * float values[] = {1.0, 2.0, 3.0, 4.0, 5.0};
+ * int N = 5;
+ * float mean;
+ *
+ * xtract[MEAN]((void *)values, N, NULL, &mean);
+ *
+ * printf("Mean = %.2f\n", mean);
+ * }
+ *
+ * The calling function may additionally make some tests against the value returned by xtract
+ *
*/
+#ifdef XTRACT
int(*xtract[XTRACT_FEATURES])(float *data, int N, void *argv, float *result);
+#endif
/** \brief A structure to store a set of n_filters Mel filters */
typedef struct xtract_mel_filter_ {