changeset 1:b8f2448f7207

Initial import
author Jamie Bullock <jamie@postlude.co.uk>
date Mon, 02 Oct 2006 14:18:15 +0000
parents 28af86ad3cc1
children 819937ea6359
files AUTHORS COPYING ChangeLog HEADER Makefile.am NEWS README autogen.sh config.h.in configure.in src/Makefile.am src/delta.c src/init.c src/libxtract.c src/scalar.c src/vector.c xtract/Makefile.am xtract/libxtract.h xtract/xtract_delta.h xtract/xtract_macros.h xtract/xtract_scalar.h xtract/xtract_types.h xtract/xtract_vector.h
diffstat 19 files changed, 1979 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/COPYING	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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 St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HEADER	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,20 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.am	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,2 @@
+SUBDIRS = src xtract
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autogen.sh	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# This works on Gentoo, whose automake wrapper is based on Mandrake:
+WANT_AUTOMAKE=1.7
+export WANT_AUTOMAKE
+
+
+case `uname -s` in
+  Linux)
+      LIBTOOLIZE=libtoolize
+      ACLOCALARGS=''
+      ;;
+  Darwin)
+      LIBTOOLIZE=glibtoolize
+      ACLOCALARGS='-I /usr/local/share/aclocal'
+      ;;
+  *)  echo error: unrecognized OS
+      exit 1
+      ;;
+esac
+
+AUTOMAKE_REQ=1.7
+
+# Automake version check from MusE
+lessthan () {
+  ver1="$1"
+  ver2="$2"
+
+  major1=$( echo $ver1 | sed "s/^\([0-9]*\)\..*/\1/");
+  minor1=$( echo $ver1 | sed "s/^[^\.]*\.\([0-9]*\).*/\1/" );
+  major2=$( echo $ver2 | sed "s/^\([0-9]*\)\..*/\1/");
+  minor2=$( echo $ver2 | sed "s/^[^\.]*\.\([0-9]*\).*/\1/" );
+  test "$major1" -lt "$major2" || test "$minor1" -lt "$minor2";
+}
+
+amver=$( automake --version | head -n 1 | sed "s/.* //" );
+if lessthan $amver $AUTOMAKE_REQ ; then
+    echo "you must have automake version >= $AUTOMAKE_REQ to proper plugin support"
+    exit 1
+fi
+
+
+echo "=============== running libtoolize --force --copy" &&
+    $LIBTOOLIZE --force --copy &&
+    echo "=============== running aclocal" &&
+    aclocal $ACLOCALARGS &&
+    echo "=============== running autoheader" &&
+    autoheader &&
+    echo "=============== running automake --add-missing --foreign" &&
+    automake --add-missing --foreign &&
+    echo "=============== running autoconf" &&
+    autoconf &&
+    echo "=============== done"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.h.in	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,61 @@
+/* config.h.in.  Generated from configure.in by autoheader.  */
+
+/* Build the vector functions */
+#undef BUILD_VECTOR
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <math.h> header file. */
+#undef HAVE_MATH_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#undef VERSION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure.in	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,41 @@
+AC_PREREQ(2.13)
+AC_INIT(src/libxtract.c)
+
+PACKAGE=libxtract
+VERSION=0.1.0
+
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+AM_CONFIG_HEADER(config.h)
+AC_PROG_CC
+AC_PROG_INSTALL
+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])
+
+AC_ARG_ENABLE(vector, 
+              [  --enable-vector    Turn fft-based vector processing on],
+              [case "${enableval}" in
+               yes) vector=true ;;
+               no)  vector=false ;;
+               *) AC_MSG_ERROR(bad value ${enableval} for --enable-vector) ;;
+           esac],[vector=false])
+
+XTRACT_SO_VERSION=0:0:0
+CFLAGS="-pedantic -ansi"
+LDFLAGS="-lm"
+
+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])
+fi
+
+AM_CONDITIONAL(BUILD_VECTOR, test "x${vector}" = 'xtrue')
+
+AC_OUTPUT(Makefile src/Makefile xtract/Makefile)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Makefile.am	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,15 @@
+
+
+
+SOURCES = libxtract.c scalar.c delta.c init.c
+
+if BUILD_VECTOR
+VECTOR  = vector.c
+else
+VECTOR =
+endif
+
+lib_LTLIBRARIES = libxtract.la
+libxtract_la_CFLAGS = -pedantic -ansi -g -O0 -ggdb
+libxtract_la_SOURCES = $(SOURCES) $(VECTOR)
+libxtract_la_LDFLAGS = -shared 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/delta.c	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,49 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+/* xtract_delta.c: defines functions that extract a feature as a single value from more than one input vector */
+
+#include "xtract/xtract_delta.h"
+#include "xtract/xtract_macros.h"
+
+int xtract_flux(float *data, int N, void *argv , float *result){
+
+    NOT_IMPLEMENTED;
+
+}
+
+int xtract_attack_time(float *data, int N, void *argv , float *result){
+
+    NOT_IMPLEMENTED;
+
+}
+
+int xtract_decay_time(float *data, int N, void *argv, float *result){
+
+    NOT_IMPLEMENTED;
+
+}
+
+int xtract_delta_feature(float *data, int N, void *argv, float *result){
+
+    NOT_IMPLEMENTED;
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/init.c	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,124 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+/* init.c: defines functions that extract a feature as a single value from an input vector */
+
+#include "xtract/libxtract.h"
+#include <math.h>
+#include <string.h>
+
+int xtract_init_mfcc(int N, float nyquist, int style, float freq_max, float freq_min, int freq_bands, float **fft_tables){
+
+    int n,i, *fft_peak, M; 
+    float norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val, 
+        freq_bw_mel, *mel_peak, *height_norm, *lin_peak;
+
+
+    mel_peak = height_norm = lin_peak = NULL;
+    fft_peak = NULL;
+    norm = 1; 
+
+    mel_freq_max = 1127 * log(1 + freq_max / 700);
+    mel_freq_min = 1127 * log(1 + freq_min / 700);
+    freq_bw_mel = (mel_freq_max - mel_freq_min) / freq_bands;
+
+    mel_peak = (float *)malloc((freq_bands + 2) * sizeof(float)); 
+    /* +2 for zeros at start and end */
+    lin_peak = (float *)malloc((freq_bands + 2) * sizeof(float));
+    fft_peak = (int *)malloc((freq_bands + 2) * sizeof(int));
+    height_norm = (float *)malloc(freq_bands * sizeof(float));
+
+    if(mel_peak == NULL || height_norm == NULL || 
+                    lin_peak == NULL || fft_peak == NULL)
+                    return MALLOC_FAILED;
+        
+    M = N >> 1;
+
+    mel_peak[0] = mel_freq_min;
+    lin_peak[0] = 700 * (exp(mel_peak[0] / 1127) - 1);
+    fft_peak[0] = lin_peak[0] / nyquist * M;
+
+
+    for (n = 1; n <= freq_bands; n++){	
+    /*roll out peak locations - mel, linear and linear on fft window scale */
+        mel_peak[n] = mel_peak[n - 1] + freq_bw_mel;
+        lin_peak[n] = 700 * (exp(mel_peak[n] / 1127) -1);
+        fft_peak[n] = lin_peak[n] / nyquist * M;
+    }
+
+    for (n = 0; n < freq_bands; n++){
+        /*roll out normalised gain of each peak*/
+        if (style == EQUAL_GAIN){
+            height = 1;	
+            norm_fact = norm;
+        }
+        else{
+            height = 2 / (lin_peak[n + 2] - lin_peak[n]);
+            norm_fact = norm / (2 / (lin_peak[2] - lin_peak[0]));
+        }
+        height_norm[n] = height * norm_fact;
+    }
+
+    i = 0;
+   
+    for(n = 0; n < freq_bands; n++){
+        if(n > 0)
+            /*calculate the rise increment*/
+            inc = height_norm[n] / (fft_peak[n] - fft_peak[n - 1]);
+        else
+            inc = height_norm[n] / fft_peak[n];
+        val = 0;	
+        for(; i <= fft_peak[n]; i++){ 
+            /*fill in the 'rise' */
+            fft_tables[n][i] = val;
+            val += inc;
+        }
+        inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]);
+        /*calculate the fall increment */
+        val = 0;
+        for(i = fft_peak[n + 1]; i > fft_peak[n]; i--){ 
+            /*reverse fill the 'fall' */
+            fft_tables[n][i] = val;
+            val += inc;
+        }
+    }
+
+    
+    free(mel_peak);
+    free(lin_peak);
+    free(height_norm);
+    free(fft_peak);
+
+    return SUCCESS;
+
+}
+
+int xtract_init_bark(int N, float nyquist, int *band_limits){
+
+    float  bark_freq_max, bark_freq_min, freq_bw_bark, temp, edges[] = {0, 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500, 20500, 27000}; /* Takes us up to sr = 54kHz (CCRMA: JOS)*/
+
+    int M, bands = BARK_BANDS;
+    
+    M = N >> 1;
+    
+    while(bands--)
+        band_limits[bands] = edges[bands] / nyquist * M;
+        /*FIX shohuld use rounding, but couldn't get it to work */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libxtract.c	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,87 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+/* libxtract - library for feature extraction from 1D vectors
+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.
+*/
+
+
+#include "xtract/libxtract.h"
+
+int(*xtract[])(float *, int, void *, float *) = {
+    /* xtract_scalar.h */
+    xtract_mean,
+    xtract_variance,
+    xtract_standard_deviation,
+    xtract_average_deviation,
+    xtract_skewness,
+    xtract_kurtosis,
+    xtract_irregularity_k,
+    xtract_irregularity_j,
+    xtract_tristimulus_1,
+    xtract_tristimulus_2,
+    xtract_tristimulus_3,
+    xtract_smoothness,
+    xtract_spread,
+    xtract_zcr,
+    xtract_rolloff,
+    xtract_loudness,
+    xtract_flatness,
+    xtract_tonality,
+    xtract_crest,
+    xtract_noisiness,
+    xtract_rms_amplitude,
+    xtract_inharmonicity,
+    xtract_power,
+    xtract_odd_even_ratio,
+    xtract_sharpness,
+    xtract_slope,
+    xtract_f0,
+    xtract_hps,
+    /* xtract_vector.h */
+    xtract_magnitude_spectrum,
+    xtract_autocorrelation,
+    xtract_autocorrelation_fft,
+    xtract_amdf,
+    xtract_asdf,
+    xtract_mfcc,
+    xtract_dct,
+    xtract_bark_coefficients,
+    xtract_peaks,
+    /* xtract_delta.h */
+    xtract_flux,
+    xtract_attack_time,
+    xtract_decay_time,
+    xtract_delta_feature
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/scalar.c	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,414 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+
+/* xtract_scalar.c: defines functions that extract a feature as a single value from an input vector */
+
+#include "xtract/libxtract.h"
+#include "math.h"
+
+int xtract_mean(float *data, int N, void *argv, float *result){
+   
+    int n = N;
+
+    while(n--)
+        *result += *data++;
+    
+    *result /= N;
+}
+
+int xtract_variance(float *data, int N, void *argv, float *result){
+    
+    int n = N;
+
+    while(n--)
+        *result += *data++ - *(float *)argv;
+   
+    *result = SQ(*result) / (N - 1);
+}
+
+int xtract_standard_deviation(float *data, int N, void *argv, float *result){
+    
+    *result = sqrt(*(float *)argv);
+    
+}
+
+int xtract_average_deviation(float *data, int N, void *argv, float *result){
+    
+    int n = N;
+
+    while(n--)
+        *result += fabs(*data++ - *(float *)argv);
+   
+    *result /= N;
+
+}
+
+int xtract_skewness(float *data, int N, void *argv,  float *result){
+    
+    int n = N;
+
+    while(n--)
+        *result += (*data++ - ((float *)argv)[0]) / ((float *)argv)[1];
+   
+    *result = pow(*result, 3) / N;
+
+}
+
+int xtract_kurtosis(float *data, int N, void *argv,  float *result){
+    
+    int n = N;
+
+    while(n--)
+        *result += (*data++ - ((float *)argv)[0]) / ((float *)argv)[1];
+   
+    *result = pow(*result, 4) / N - 3;
+    
+}
+
+int xtract_irregularity_k(float *data, int N, void *argv, float *result){
+   
+    int n,
+        M = M - 1;
+
+    for(n = 1; n < M; n++)
+        *result += abs(data[n] - (data[n-1] + data[n] + data[n+1]) / 3);
+
+}
+
+int xtract_irregularity_j(float *data, int N, void *argv, float *result){
+    
+    int n = N;
+
+    float num, den;
+
+    while(n--){
+	  num += data[n] - data[n+1];
+	  den += data[n] * data[n];
+    }
+  
+    *result = num / den;
+
+}
+
+int xtract_tristimulus_1(float *data, int N, void *argv, float *result){
+
+    int n = N;
+
+    float den;
+
+    while(n--)
+        den += data[n];
+
+    *result = data[0] / den;
+
+}
+
+int xtract_tristimulus_2(float *data, int N, void *argv, float *result){
+    
+    int n = N;
+
+    float den;
+
+    while(n--)
+        den += data[n];
+
+    *result = (data[1] + data[2] + data[3])  / den;
+   
+}
+
+int xtract_tristimulus_3(float *data, int N, void *argv, float *result){
+    
+    int n = N;
+
+    float den, num;
+
+    while(n--)
+        den += data[n];
+
+    num = den - data[0] + data[1] + data[2] + data[3];
+    
+    *result = num / den;
+ 
+}
+
+int xtract_smoothness(float *data, int N, void *argv, float *result){
+    
+    int n = N;
+
+    if (data[0] <= 0) data[0] = 1;
+    if (data[1] <= 0) data[1] = 1;
+        
+    for(n = 2; n < N; n++){ 
+	  if(data[n] <= 0) data[n] = 1;
+	  *result += abs(20 * log(data[n-1]) - (20 * log(data[n-2]) + 
+                            20 * log(data[n-1]) + 20 * log(data[n])) / 3);
+  }
+}
+
+int xtract_spread(float *data, int N, void *argv, float *result){
+
+    int n = N;
+
+    float num, den, tmp;
+
+    while(n--){
+        tmp = n - *(float *)argv;
+        num += SQ(tmp) * data[n];
+        den += data[n];
+    }
+
+    *result = sqrt(num / den);
+    
+}
+
+int xtract_zcr(float *data, int N, void *argv, float *result){
+
+    int n = N;
+    
+    for(n = 1; n < N; n++)
+        if(data[n] * data[n-1] < 0) (*result)++;
+    
+    *result /= N;
+    
+}
+
+int xtract_rolloff(float *data, int N, void *argv, float *result){
+
+    int n = N;
+    float pivot, temp;
+    
+    while(n--) pivot += data[n];   
+    
+    pivot *= *(float *)argv;
+    
+    for(n = 0; temp < pivot; temp += data[n++]);
+
+    *result = n;
+    
+}
+
+int xtract_loudness(float *data, int N, void *argv, float *result){
+    
+    int n = BARK_BANDS;
+   
+    /*if(n != N) return BAD_VECTOR_SIZE; */
+
+    while(n--)
+        *result += pow(data[n], 0.23);
+}
+
+
+int xtract_flatness(float *data, int N, void *argv, float *result){
+
+    int n = N;
+
+    float num, den;
+    
+    while(n--){
+        if(data[n] !=0){
+            num *= data[n];
+            den += data[n];
+        }
+    }
+
+    num = pow(num, 1 / N); 
+    den /= N;
+    
+    *result = 10 * log10(num / den);
+    
+}
+
+int xtract_tonality(float *data, int N, void *argv, float *result){
+    
+    float sfmdb, sfm;
+   
+    sfm = *(float *)argv;
+
+    sfmdb = (sfm > 0 ? (10 * log10(sfm)) / -60 : 0);
+    
+    *result = MIN(sfmdb, 1);
+    
+}
+
+int xtract_crest(float *data, int N, void *argv, float *result){
+    
+   NOT_IMPLEMENTED;
+   
+}
+
+int xtract_noisiness(float *data, int N, void *argv, float *result){
+    
+   NOT_IMPLEMENTED;
+   
+}
+int xtract_rms_amplitude(float *data, int N, void *argv, float *result){
+
+    int n = N;
+
+    while(n--) *result += SQ(data[n]);
+
+    *result = sqrt(*result / N);
+    
+}
+
+int xtract_inharmonicity(float *data, int N, void *argv, float *result){
+
+    int n = N;
+    float num, den,
+        *fund, *freq;
+
+    fund = *(float **)argv;
+    freq = fund+1;
+        
+    while(n--){
+        num += abs(freq[n] - n * *fund) * SQ(data[n]);
+        den += SQ(data[n]);
+    }
+
+    *result = (2 * num) / (*fund * den); 
+    
+}
+
+
+int xtract_power(float *data, int N, void *argv, float *result){
+
+   NOT_IMPLEMENTED;
+    
+}
+
+int xtract_odd_even_ratio(float *data, int N, void *argv, float *result){
+
+    int n = N >> 1, j, k;
+
+    float num, den;
+
+    while(n--){
+        j = n * 2;
+        k = j - 1;
+        num += data[k];
+        den += data[j];
+    }
+
+    *result = num / den;
+    
+}
+
+int xtract_sharpness(float *data, int N, void *argv, float *result){
+
+    NOT_IMPLEMENTED;
+    
+}
+
+int xtract_slope(float *data, int N, void *argv, float *result){
+
+    NOT_IMPLEMENTED;
+    
+}
+
+int xtract_f0(float *data, int N, void *argv, float *result){
+
+/*    int n, M = N >> 1;
+    float guess, error, minimum_error = 1000000, f0, freq;
+
+    guess = *(float *)argv;
+
+    for(n = 0; n < M; n++){
+        if(freq = data[n]){
+            error = abs(guess - freq);
+            if(error < minimum_error){
+                f0 = freq;
+                minimum_error = error;
+            }
+        }
+    }
+    *result = f0;*/
+
+    
+    float f0 = SR_LIMIT;
+    int n = N;
+
+    while(n--) {
+        if(data[n] > 0)
+            f0 = MIN(f0, data[n]);
+    }
+
+    *result = (f0 == SR_LIMIT ? 0 : f0);
+    
+}
+
+int xtract_hps(float *data, int N, void *argv, float *result){
+
+    int n = N, M, m, l, peak_index, position1_lwr;
+    float *coeffs2, *coeffs3, *product, L, 
+            largest1_lwr, peak, ratio1;
+
+    coeffs2 = (float *)malloc(N * sizeof(float));
+    coeffs3 = (float *)malloc(N * sizeof(float));
+    product = (float *)malloc(N * sizeof(float));
+            
+    while(n--) coeffs2[n] = coeffs3[n] = 1;
+
+    M = N >> 1;
+    L = N / 3;
+
+    while(M--){
+        m = M << 1;
+        coeffs2[M] = (data[m] + data[m+1]) * 0.5f;
+
+        if(M < L){
+            l = M * 3;
+            coeffs3[M] = (data[l] + data[l+1] + data[l+2]) / 3;
+        }
+    }
+    
+    peak_index = peak = 0;
+    
+    for(n = 1; n < N; n++){
+        product[n] = data[n] * coeffs2[n] * coeffs3[n];
+        if(product[n] > peak){
+            peak_index = n;
+            peak = product[n];
+        }
+    }
+
+    largest1_lwr = position1_lwr = 0;
+
+    for(n = 0; n < N; n++){
+        if(data[n] > largest1_lwr && n != peak_index){
+            largest1_lwr = data[n];
+            position1_lwr = n;
+        }
+    }
+
+    ratio1 = data[position1_lwr] / data[peak_index];
+
+    if(position1_lwr > peak_index * 0.4 && position1_lwr < 
+                                peak_index * 0.6 && ratio1 > 0.1)
+                                peak_index = position1_lwr;
+
+    *result = 22050 * (float)peak_index / (float)N;
+        
+    free(coeffs2);
+    free(coeffs3);
+    free(product);
+    
+}
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vector.c	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,228 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+
+/* xtract_vector.c: defines functions that extract a feature as a single value from an input vector */
+
+#include "xtract/libxtract.h"
+#include <math.h>
+#include <fftw3.h>
+
+int xtract_magnitude_spectrum(float *data, int N, void *argv, float *result){
+
+    float *temp;
+    int n , M = N >> 1;
+    fftwf_plan plan;
+
+    temp = (float *)fftwf_malloc(N * sizeof(float));
+
+    plan = fftwf_plan_r2r_1d(N, data, temp, FFTW_R2HC, FFTW_ESTIMATE);
+    
+    fftwf_execute(plan);
+    
+    for(n = 1; n < M; n++){
+        result[n] = sqrt(SQ(temp[n]) + SQ(temp[N - n])) / N;
+        result[N-n] = 0.0f;
+    }
+    
+    result[0] = fabs(temp[0]) / N;
+    result[M] = fabs(temp[M]) / N;
+    
+    fftwf_destroy_plan(plan);
+    fftwf_free(temp);
+    
+}
+
+int xtract_autocorrelation(float *data, int N, void *argv, float *result){
+
+    /* Naive time domain implementation  */
+    
+    int n = N, i;
+    
+    float corr;
+
+    while(n--){
+       corr = 0;
+        for(i = 0; i < N - n; i++){
+            corr += data[i] * data[i + n];
+        }
+        result[n] = corr / N;
+    }
+}
+
+int xtract_autocorrelation_fft(float *data, int N, void *argv, float *result){
+    
+    float *temp;
+    int n;
+    fftwf_plan plan;
+
+    temp = (float *)fftwf_malloc(N * sizeof(float));
+    plan = fftwf_plan_r2r_1d(N, data, temp, FFTW_HC2R, FFTW_ESTIMATE);
+
+    fftwf_execute(plan);
+    
+    for(n = 0; n < N - 1; n++)
+        result[n] = temp[n+1];
+    
+    fftwf_destroy_plan(plan);
+    fftwf_free(temp);
+}
+
+int xtract_amdf(float *data, int N, void *argv, float *result){
+
+    int n = N, i;
+    
+    float md;
+
+    while(n--){
+       md = 0;
+        for(i = 0; i < N - n; i++){
+            md += abs(data[i] - data[i + n]);
+        }
+        result[n] = md / N;
+    }
+}
+
+int xtract_asdf(float *data, int N, void *argv, float *result){
+    
+    int n = N, i;
+    
+    float sd;
+
+    while(n--){
+       sd = 0;
+        for(i = 0; i < N - n; i++){
+            sd = 1;
+            sd += SQ(data[i] - data[i + n]);
+        }
+        result[n] = sd / N;
+    }
+}
+
+int xtract_mfcc(float *data, int N, void *argv, float *result){
+
+    xtract_mel_filter *f;
+    int n, filter;
+    fftwf_plan plan;
+
+    f = (xtract_mel_filter *)argv;
+
+    for(filter = 0; filter < f->n_filters; filter++){
+        for(n = 0; n < N; n++){
+            result[filter] += data[n] * f->filters[filter][n];
+        }
+        if(result[filter] < LOG_LIMIT) result[filter] = LOG_LIMIT;
+        result[filter] = log(result[filter]);
+    }
+
+    for(n = filter + 1; n < N; n++) result[n] = 0; 
+    
+    xtract_dct(result, f->n_filters, NULL, result);
+
+}
+
+int xtract_dct(float *data, int N, void *argv, float *result){
+    
+    fftwf_plan plan;
+
+    plan = 
+        fftwf_plan_r2r_1d(N, data, result, FFTW_REDFT00, FFTW_ESTIMATE);
+    
+    fftwf_execute(plan);
+    fftwf_destroy_plan(plan);
+}
+
+int xtract_bark_coefficients(float *data, int N, void *argv, float *result){
+
+    int *limits, band, n;
+
+    limits = (int *)argv;
+    
+    for(band = 0; band < BARK_BANDS; band++){
+        for(n = limits[band]; n < limits[band + 1]; n++)
+            result[band] += data[n];
+    }
+}
+
+int xtract_peaks(float *data, int N, void *argv, float *result){
+
+    float thresh, max, y, y2, y3, p, width, sr; 
+    int n = N, M, return_code;
+    
+    if(argv != NULL){
+        thresh = ((float *)argv)[0];
+        sr = ((float *)argv)[1];
+        return_code = BAD_ARGV;
+    }
+    else{
+        thresh = 0;
+        sr = 44100;
+    }
+
+    M = N >> 1;
+    width = sr / N;
+    
+    y = y2 = y3 = p = max = 0;
+
+    if(thresh < 0 || thresh > 100){
+        thresh = 0;
+        return_code = BAD_ARGV;
+    }
+
+    if(!sr){
+        sr = 44100;
+        return_code = BAD_ARGV;
+    }
+
+    while(n--){
+        max = MAX(max, data[n]);
+        /* ensure we never take log10(0) */
+        /*data[n] = (data[n] < LOG_LIMIT ? LOG_LIMIT : data[n]);*/
+        if ((data[n] * 100000) <= 1)
+        /* We get a more stable peak this way */
+		    data[n] = 1;
+        
+    }
+    
+    thresh *= .01 * max;
+
+    result[0] = 0;
+    result[M] = 0;
+
+    for(n = 1; n < M; n++){
+        if(data[n] >= thresh){
+            if(data[n] > data[n - 1] && data[n] > data[n + 1]){
+                result[n] = width * (n + (p = .5 * (y = 20 * log10(data[n-1]) - (y3 = 20 * log10(data[n+1]))) / (20 * log10(data[n - 1]) - 2 * (y2 = 20 * log10(data[n])) + 20 * log10(data[n + 1]))));
+                result[M + n] = y2 - .25 * (y - y3) * p;
+            }
+            else{
+                result[n] = 0;
+                result[M + n] = 0;
+            }
+        }
+        else{
+            result[n] = 0;
+            result[M + n] = 0;
+        }
+    }	  
+   
+    return (return_code ? return_code : SUCCESS);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xtract/Makefile.am	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,5 @@
+libxtractdir = $(includedir)/xtract
+
+libxtract_HEADERS = libxtract.h xtract_macros.h xtract_types.h xtract_delta.h \
+		    xtract_scalar.h  xtract_vector.h
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xtract/libxtract.h	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,182 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+#ifndef XTRACT_H
+#define XTRACT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** 
+ * \file libxtract.h: main header file and API definition 
+ */
+
+#define VERSION "0.1"
+
+    
+#include "xtract_scalar.h"
+#include "xtract_vector.h"
+#include "xtract_delta.h"
+#include "xtract_types.h"
+#include "xtract_macros.h"
+
+#define XTRACT_FEATURES 40
+#define LOG_LIMIT 10e-10
+#define SR_LIMIT 192000
+#define BARK_BANDS 26
+
+/** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */
+
+enum features_ {
+    MEAN,
+    VARIANCE,
+    STANDARD_DEVIATION,
+    AVERAGE_DEVIATION,
+    SKEWNESS,
+    KURTOSIS,
+    IRREGULARITY_K,
+    IRREGULARITY_J,
+    TRISTIMULUS_1,
+    TRISTIMULUS_2,
+    TRISTIMULUS_3,
+    SMOOTHNESS,
+    SPREAD,
+    ZCR,
+    ROLLOFF,
+    LOUDNESS,
+    FLATNESS,
+    TONALITY,
+    CREST,
+    NOISINESS,
+    RMS_AMPLITUDE,
+    INHARMONICITY,
+    POWER,
+    ODD_EVEN_RATIO,
+    SHARPNESS,
+    SLOPE,
+    F0,
+    HPS,
+    MAGNITUDE_SPECTRUM,
+    AUTOCORRELATION,
+    AUTOCORRELATION_FFT,
+    AMDF,
+    ASDF,
+    MFCC,
+    DCT,
+    BARK_COEFFICIENTS,
+    PEAKS,
+    FLUX,
+    ATTACK_TIME,
+    DECAY_TIME,
+    DELTA_FEATURE
+};
+
+/** \brief Enumeration of feature types */
+
+enum feature_types_ {
+    SCALAR,
+    VECTOR,
+    DELTA
+};
+
+/** \brief Enumeration of mfcc types */
+
+enum mfcc_types_ {
+    EQUAL_GAIN,
+    EQUAL_AREA
+};
+
+/** \brief Enumeration of return codes */
+
+enum return_codes_ {
+    SUCCESS,
+    MALLOC_FAILED,
+    BAD_ARGV,
+    BAD_VECTOR_SIZE
+};
+
+/**
+ *                                                                          
+ * \brief Perform feature extraction
+ *
+ * \param
+ *                                                                           
+ * In general functions in this library conform to the following prototpe:  
+ *                                                                          
+ * int xtract_featurename(float *data, int N, void *argv, float *result)    
+ *                                                                          
+ *                                                                          
+ *      float *data: a pointer to an array element                          
+ *                                                                          
+ *      int N: the number of elements to be processed by the function          
+ *                                                                          
+ *      void *argv: an abitrary number of additional arguments 
+ *                                                                          
+ *      float *result: a pointer to the result                              
+ *                                                                          
+ *                                                                          
+ * Each function will iterate over N array elements, the first of which is  
+ * pointed to by *data. It is therefore up to the caller to ensure that an  
+ * approriate range of data is provided. For example, if the function expects
+ * an array containing an harmonic spectrum, then they array pointed to by 
+ * *data must contain the amplitudes of harmonic frequencies in adjacent 
+ * elemets
+ *                                                                          
+ * For scalar and delta features, *result will point to a single value.     
+ *                                                                          
+ * For vector features it will point to the first element in an array.      
+ *                                                                          
+ * Memory for this array must be allocated and freed by the calling         
+ * function.                                                                
+ *  
+ *  All functions return an integer error code as descibed in the enumeration
+ *  return_codes_
+ *                                                                          
+ * */
+
+
+int(*xtract[XTRACT_FEATURES])(float *, int, void *, float *);
+
+/* Data structures */
+
+typedef struct xtract_mel_filter_ {
+    int n_filters;
+    float **filters;
+} xtract_mel_filter;
+
+
+/* Initialisation functions */
+/* xtract_init_mfcc */
+/* It is up to the caller to pass in a pointer to memory allocated for freq_bands arrays of length N. This function populates these arrays with magnitude coefficients representing the mel filterbank on a linear scale */
+int xtract_init_mfcc(int N, float nyquist, int style, float freq_max, float freq_min, int freq_bands, float **fft_tables);
+
+/* xtract_init_bark */
+/* A pointer to an array of BARK_BANDS ints most be passed in, and is populated with BARK_BANDS fft bin numbers representing the limits of each band */
+int xtract_init_bark(int N, float nyquist, int *band_limits);
+
+
+/* Free functions */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xtract/xtract_delta.h	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,61 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+/* xtract_delta.h: declares functions that extract a feature as a single value from more than one input vector */
+
+#ifndef XTRACT_DELTA
+#define XTRACT_DELTA
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "xtract_types.h"
+/* Flux/temporal variation */
+
+/* Gaƫl Richard (2006)*/
+int xtract_flux(float *data, int N, void *argv , float *result);
+/*xtract_frame_tracker *xf */
+
+/* Attack Time */
+
+int xtract_attack_time(float *data, int N, void *argv , float *result);
+/* xtract_amp_tracker *xa */
+
+/* Temporal decrease */
+
+int xtract_decay_time(float *data, int N, void *argv, float *result);
+/* xtract_amp_tracker *xa */
+
+
+/* Delta vector */
+/* Generic function to calculate the delta of a feature over a given period (in frames */
+
+int xtract_delta_feature(float *data, int N, void *argv, float *result);
+/*xtract_frame_tracker *xf */
+/*float frames*/
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xtract/xtract_macros.h	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,41 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+
+
+/* xtract_delta.h: defines useful macros */
+
+#ifndef XTRACT_MACROS
+#define XTRACT_MACROS
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SQ(a) ((a) * (a))
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define NOT_IMPLEMENTED printf("Feature not implemented yet.\n")
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xtract/xtract_scalar.h	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,144 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+/* xtract_scalar.h: declares functions that extract a feature as a single value from an input vector */
+
+#ifndef XTRACT_SCALAR
+#define XTRACT_SCALAR
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Statistical features */
+
+int xtract_mean(float *data, int N, void *argv, float *result);
+/* mean is passed in as arg */
+int xtract_variance(float *data, int N, void *argv, float *result);
+/* variance is passed in as arg */
+int xtract_standard_deviation(float *data, int N, void *argv, float *result);
+/* mean is passed in as arg */
+int xtract_average_deviation(float *data, int N, void *argv, float *result);
+/* mean and standard deviation are passed in as arg */
+int xtract_skewness(float *data, int N, void *argv,  float *result);
+/* mean and standard deviation are passed in as arg */
+int xtract_kurtosis(float *data, int N, void *argv,  float *result);
+
+/* Irregularity */
+
+/* Krimphoff (1994) */
+int xtract_irregularity_k(float *data, int N, void *argv, float *result);
+/* Jensen (1999) */
+int xtract_irregularity_j(float *data, int N, void *argv, float *result);
+
+/* Tristimulus */
+
+/* Pollard and Jansson (1982) */
+int xtract_tristimulus_1(float *data, int N, void *argv, float *result);
+int xtract_tristimulus_2(float *data, int N, void *argv, float *result);
+int xtract_tristimulus_3(float *data, int N, void *argv, float *result);
+
+/* Smoothness */
+
+/*McAdams (1999)*/
+int xtract_smoothness(float *data, int N, void *argv, float *result);
+
+/* Spectral Spread */
+
+/* Casagrande 2005 */
+
+int xtract_spread(float *data, int N, void *argv, float *result);
+
+/* Zero crossing rate */
+
+int xtract_zcr(float *data, int N, void *argv, float *result);
+
+/* Rolloff */
+
+/* Bee Suan Ong (2005) */
+/* Threshold is the percentile at which the rolloff is determined */
+
+int xtract_rolloff(float *data, int N, void *argv, float *result);
+
+/* Loudness */
+/* A set of BARK_BANDS bark coefficients must be passed in, the loudness is calculated approximately according to Moore, Glasberg et al, 1997 */
+
+int xtract_loudness(float *data, int N, void *argv, float *result);
+
+/* Spectral Flatness Measure */
+/* Tristan Jehan (2005) */
+
+int xtract_flatness(float *data, int N, void *argv, float *result);
+
+/* Tonality Factor */
+/* Tristan Jehan (2005) */
+
+int xtract_tonality(float *data, int N, void *argv, float *result);
+
+/* Noisiness */
+/* Tae Hong Park (2000) */
+
+int xtract_noisiness(float *data, int N, void *argv, float *result);
+
+/* RMS amplitude */
+/* Tae Hong Park (2000) */
+
+int xtract_rms_amplitude(float *data, int N, void *argv, float *result);
+
+/* Inharmonicity */
+
+int xtract_inharmonicity(float *data, int N, void *argv, float *result);
+
+/* Spectral Crest */
+/* Peeters (2003) */
+int xtract_crest(float *data, int N, void *argv, float *result);
+    
+/* Spectral Power */
+/* Bee Suan Ong (2005) */
+int xtract_power(float *data, int N, void *argv, float *result);
+    
+/* Odd to even harmonic ratio */
+
+int xtract_odd_even_ratio(float *data, int N, void *argv, float *result);
+
+/* Sharpness */
+
+int xtract_sharpness(float *data, int N, void *argv, float *result);
+
+/* Slope */
+int xtract_slope(float *data, int N, void *argv, float *result);
+
+/* F0 */
+/*This method takes a guess which can come from taking the ZCR of an autocorrelation function, and then finds the spectral peak that most closely matches the gess */
+int xtract_f0(float *data, int N, void *argv, float *result);
+
+/* Pitch */
+/* Pitch via HPS analysis */
+int xtract_hps(float *data, int N, void *argv, float *result);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xtract/xtract_types.h	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,46 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+/* xtract_types.h: declares specialised variable types used by libxtract */
+
+#ifndef XTRACT_TYPES
+#define XTRACT_TYPES
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Data structure used to store amplitude data between calls to xtract_attack_time and other functions. */
+    
+typedef struct _xtract_amp_tracker {
+    int count;
+    float previous_amp;
+} xtract_amp_tracker;
+
+typedef struct _xtract_frame_tracker {
+    int frame_count;
+    float *previous_frame;
+} xtract_frame_tracker;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xtract/xtract_vector.h	Mon Oct 02 14:18:15 2006 +0000
@@ -0,0 +1,65 @@
+/* libxtract feature extraction library
+ *  
+ * 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.
+ */
+
+/* xtract_scalar.h: declares functions that extract a feature as a vector from an input vector */
+
+#ifndef XTRACT_VECTOR
+#define XTRACT_VECTOR
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Extracts normalized (0-1) frequency domain magnitude spectrum from time domain signal */
+int xtract_magnitude_spectrum(float *data, int N, void *argv, float *result);
+
+
+/* Autocorrelation */
+int xtract_autocorrelation(float *data, int N, void *argv, float *result);
+
+
+int xtract_autocorrelation_fft(float *data, int N, void *argv, float *result);
+
+/* Average Magnitude Difference Function */
+int xtract_amdf(float *data, int N, void *argv, float *result);
+    
+/* Average Squared Difference Function */
+int xtract_asdf(float *data, int N, void *argv, float *result);
+    
+/* MFCC */
+/* Rabiner */
+int xtract_mfcc(float *data, int N, void *argv, float *result);
+
+/* Bark band */
+
+int xtract_bark_coefficients(float *data, int N, void *argv, float *result);
+
+/* Discrete cosine transform */
+int xtract_dct(float *data, int N, void *argv, float *result);
+
+/* Frequency and amplitude of spectral peaks */
+/* Takes peak threshold as percentage below max peak, and sr as argv, returns a pointer to an array of size N, containing N/2 freqs and N/2 amplitudes, amplitudes are on a decibel scale with dbFS = 0 */
+int xtract_peaks(float *data, int N, void *argv, float *result);
+    
+#ifdef __cplusplus
+}
+#endif
+
+#endif