Index: examples/Makefile.am
===================================================================
--- examples/Makefile.am	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/Makefile.am	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,29 @@
+
+#SUBDIRS=onsets
+
+# global flags
+AM_CFLAGS = -I../src
+AM_LDFLAGS = -L../src -laubio
+#AM_SOURCES = utils.c
+
+# add your programs to this list
+bin_PROGRAMS = \
+	aubioonset \
+	aubionotesmedian \
+	aubionotes
+	
+noinst_PROGRAMS = \
+	midiparse \
+	midiplay \
+	midialsa \
+	testforclam
+	
+man_MANS = aubionotes.1 aubioonset.1
+EXTRA_DIST = utils.h $(man_MANS)
+
+
+# optionally add sources file for these programs
+aubioonset_SOURCES = aubioonset.c utils.c
+aubionotes_SOURCES = aubionotes.c utils.c
+aubionotesmedian_SOURCES = aubionotesmedian.c utils.c
+testforclam_SOURCES = testforclam.c utils.c
Index: examples/Makefile.in
===================================================================
--- examples/Makefile.in	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/Makefile.in	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,608 @@
+# Makefile.in generated by automake 1.7.9 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+#SUBDIRS=onsets
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_triplet = @host@
+ACLOCAL = @ACLOCAL@
+ALSA_CFLAGS = @ALSA_CFLAGS@
+ALSA_LIBS = @ALSA_LIBS@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FFTWLIB_CFLAGS = @FFTWLIB_CFLAGS@
+FFTWLIB_LIBS = @FFTWLIB_LIBS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JACK_CFLAGS = @JACK_CFLAGS@
+JACK_LIBS = @JACK_LIBS@
+LADCCA_CFLAGS = @LADCCA_CFLAGS@
+LADCCA_LIBS = @LADCCA_LIBS@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SAMPLERATE_CFLAGS = @SAMPLERATE_CFLAGS@
+SAMPLERATE_LIBS = @SAMPLERATE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SNDLIB_CFLAGS = @SNDLIB_CFLAGS@
+SNDLIB_LIBS = @SNDLIB_LIBS@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+
+# global flags
+AM_CFLAGS = -I../src
+AM_LDFLAGS = -L../src -laubio
+#AM_SOURCES = utils.c
+
+# add your programs to this list
+bin_PROGRAMS = \
+	aubioonset \
+	aubionotesmedian \
+	aubionotes
+
+
+noinst_PROGRAMS = \
+	midiparse \
+	midiplay \
+	midialsa \
+	testforclam
+
+
+man_MANS = aubionotes.1 aubioonset.1
+EXTRA_DIST = utils.h $(man_MANS)
+
+# optionally add sources file for these programs
+aubioonset_SOURCES = aubioonset.c utils.c
+aubionotes_SOURCES = aubionotes.c utils.c
+aubionotesmedian_SOURCES = aubionotesmedian.c utils.c
+testforclam_SOURCES = testforclam.c utils.c
+subdir = examples
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_CLEAN_FILES =
+bin_PROGRAMS = aubioonset$(EXEEXT) aubionotesmedian$(EXEEXT) \
+	aubionotes$(EXEEXT)
+noinst_PROGRAMS = midiparse$(EXEEXT) midiplay$(EXEEXT) midialsa$(EXEEXT) \
+	testforclam$(EXEEXT)
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
+
+am_aubionotes_OBJECTS = aubionotes.$(OBJEXT) utils.$(OBJEXT)
+aubionotes_OBJECTS = $(am_aubionotes_OBJECTS)
+aubionotes_LDADD = $(LDADD)
+aubionotes_DEPENDENCIES =
+aubionotes_LDFLAGS =
+am_aubionotesmedian_OBJECTS = aubionotesmedian.$(OBJEXT) utils.$(OBJEXT)
+aubionotesmedian_OBJECTS = $(am_aubionotesmedian_OBJECTS)
+aubionotesmedian_LDADD = $(LDADD)
+aubionotesmedian_DEPENDENCIES =
+aubionotesmedian_LDFLAGS =
+am_aubioonset_OBJECTS = aubioonset.$(OBJEXT) utils.$(OBJEXT)
+aubioonset_OBJECTS = $(am_aubioonset_OBJECTS)
+aubioonset_LDADD = $(LDADD)
+aubioonset_DEPENDENCIES =
+aubioonset_LDFLAGS =
+midialsa_SOURCES = midialsa.c
+midialsa_OBJECTS = midialsa.$(OBJEXT)
+midialsa_LDADD = $(LDADD)
+midialsa_DEPENDENCIES =
+midialsa_LDFLAGS =
+midiparse_SOURCES = midiparse.c
+midiparse_OBJECTS = midiparse.$(OBJEXT)
+midiparse_LDADD = $(LDADD)
+midiparse_DEPENDENCIES =
+midiparse_LDFLAGS =
+midiplay_SOURCES = midiplay.c
+midiplay_OBJECTS = midiplay.$(OBJEXT)
+midiplay_LDADD = $(LDADD)
+midiplay_DEPENDENCIES =
+midiplay_LDFLAGS =
+am_testforclam_OBJECTS = testforclam.$(OBJEXT) utils.$(OBJEXT)
+testforclam_OBJECTS = $(am_testforclam_OBJECTS)
+testforclam_LDADD = $(LDADD)
+testforclam_DEPENDENCIES =
+testforclam_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/aubionotes.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/aubionotesmedian.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/aubioonset.Po ./$(DEPDIR)/midialsa.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/midiparse.Po ./$(DEPDIR)/midiplay.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/testforclam.Po ./$(DEPDIR)/utils.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+	$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(aubionotes_SOURCES) $(aubionotesmedian_SOURCES) \
+	$(aubioonset_SOURCES) midialsa.c midiparse.c midiplay.c \
+	$(testforclam_SOURCES)
+
+NROFF = nroff
+MANS = $(man_MANS)
+DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
+SOURCES = $(aubionotes_SOURCES) $(aubionotesmedian_SOURCES) $(aubioonset_SOURCES) midialsa.c midiparse.c midiplay.c $(testforclam_SOURCES)
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  examples/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	$(mkinstalldirs) $(DESTDIR)$(bindir)
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	     || test -f $$p1 \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
+	  rm -f $(DESTDIR)$(bindir)/$$f; \
+	done
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+
+clean-noinstPROGRAMS:
+	@list='$(noinst_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+aubionotes$(EXEEXT): $(aubionotes_OBJECTS) $(aubionotes_DEPENDENCIES) 
+	@rm -f aubionotes$(EXEEXT)
+	$(LINK) $(aubionotes_LDFLAGS) $(aubionotes_OBJECTS) $(aubionotes_LDADD) $(LIBS)
+aubionotesmedian$(EXEEXT): $(aubionotesmedian_OBJECTS) $(aubionotesmedian_DEPENDENCIES) 
+	@rm -f aubionotesmedian$(EXEEXT)
+	$(LINK) $(aubionotesmedian_LDFLAGS) $(aubionotesmedian_OBJECTS) $(aubionotesmedian_LDADD) $(LIBS)
+aubioonset$(EXEEXT): $(aubioonset_OBJECTS) $(aubioonset_DEPENDENCIES) 
+	@rm -f aubioonset$(EXEEXT)
+	$(LINK) $(aubioonset_LDFLAGS) $(aubioonset_OBJECTS) $(aubioonset_LDADD) $(LIBS)
+midialsa$(EXEEXT): $(midialsa_OBJECTS) $(midialsa_DEPENDENCIES) 
+	@rm -f midialsa$(EXEEXT)
+	$(LINK) $(midialsa_LDFLAGS) $(midialsa_OBJECTS) $(midialsa_LDADD) $(LIBS)
+midiparse$(EXEEXT): $(midiparse_OBJECTS) $(midiparse_DEPENDENCIES) 
+	@rm -f midiparse$(EXEEXT)
+	$(LINK) $(midiparse_LDFLAGS) $(midiparse_OBJECTS) $(midiparse_LDADD) $(LIBS)
+midiplay$(EXEEXT): $(midiplay_OBJECTS) $(midiplay_DEPENDENCIES) 
+	@rm -f midiplay$(EXEEXT)
+	$(LINK) $(midiplay_LDFLAGS) $(midiplay_OBJECTS) $(midiplay_LDADD) $(LIBS)
+testforclam$(EXEEXT): $(testforclam_OBJECTS) $(testforclam_DEPENDENCIES) 
+	@rm -f testforclam$(EXEEXT)
+	$(LINK) $(testforclam_LDFLAGS) $(testforclam_OBJECTS) $(testforclam_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT) core *.core
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aubionotes.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aubionotesmedian.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aubioonset.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/midialsa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/midiparse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/midiplay.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testforclam.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+
+.c.lo:
+@am__fastdepCC_TRUE@	if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+
+man1dir = $(mandir)/man1
+install-man1: $(man1_MANS) $(man_MANS)
+	@$(NORMAL_INSTALL)
+	$(mkinstalldirs) $(DESTDIR)$(man1dir)
+	@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
+	  case "$$i" in \
+	    *.1*) list="$$list $$i" ;; \
+	  esac; \
+	done; \
+	for i in $$list; do \
+	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+	  else file=$$i; fi; \
+	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    1*) ;; \
+	    *) ext='1' ;; \
+	  esac; \
+	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
+	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \
+	  $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \
+	done
+uninstall-man1:
+	@$(NORMAL_UNINSTALL)
+	@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
+	  case "$$i" in \
+	    *.1*) list="$$list $$i" ;; \
+	  esac; \
+	done; \
+	for i in $$list; do \
+	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    1*) ;; \
+	    *) ext='1' ;; \
+	  esac; \
+	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
+	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+	  echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \
+	  rm -f $(DESTDIR)$(man1dir)/$$inst; \
+	done
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
+
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) $(MANS)
+
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+	clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-exec-am: install-binPROGRAMS
+
+install-info: install-info-am
+
+install-man: install-man1
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man
+
+uninstall-man: uninstall-man1
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic clean-libtool clean-noinstPROGRAMS ctags \
+	distclean distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am info info-am install \
+	install-am install-binPROGRAMS install-data install-data-am \
+	install-exec install-exec-am install-info install-info-am \
+	install-man install-man1 install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-binPROGRAMS \
+	uninstall-info-am uninstall-man uninstall-man1
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: examples/aubionotes.1
===================================================================
--- examples/aubionotes.1	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/aubionotes.1	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,102 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH AUBIONOTES 1 "May  3, 2004"
+.\" Please adjust this date whenever revising the man-page.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for man-page-specific macros, see man(7)
+.SH NAME
+aubionotes \- detects notes in a sound file 
+.SH SYNOPSIS
+.B aubionotes
+.RI [ -i | --input
+.RB < soundfilein > 
+.RI ]
+.RI [ -o | --output 
+.RB < soundfileout > 
+.RI ]
+.RI [ -t | --threshold 
+.RB < thres > 
+.RI ]
+.RI [ -j | --jack ]
+.RI [ -v | --verbose ]
+.SH DESCRIPTION
+This manual page documents briefly the
+.B aubionotes
+command.
+.PP
+The library \fBaubio\fP provides a small set of functions to extract events and
+objects from audio, from live streams or still files. Onsets are used to label
+the beginning of notes, pitches to label their height.
+
+\fBaubionotes\fP is still in an experimental state. Its aim is to segment notes
+with onsets, and label them with their detected pitch. When started without an
+input file argument (\fI\-i\fP), aubionotes creates a jack input and a midi
+output. When an input file is given, it outputs the results on the console.
+
+.SH OPTIONS
+This program follows the usual GNU command line syntax, with long
+options starting with two dashes (`-').
+A summary of options is included below.
+.TP
+.B \-i, \-\-input filein
+Run analysis on this audio file. Most common (uncompressed) formats are 
+supported.
+.TP
+.B \-o, \-\-output fileout
+Save results in this file. The file will be created on the model of the input
+file. Results are marked by a very short wood-block sample.
+.TP
+.B \-t, \-\-threshold value
+Set the threshold value for the onset peak picking. Typical values are within
+\fI0.001\fP and \fI0.900\fP. Default is \fI0.1\fP. The \fBlower\fP the \fBmore
+sensible\fP.  Try \fI0.3\fP in case of over-detections.
+.TP
+.B \-j, \-\-jack
+Run in jack mode (default when started without input file) and creates a midi output.
+.TP
+.B \-h, \-\-help
+Show summary of options.
+.TP
+.B \-v, \-\-verbose
+Show results on the console.
+
+.SH EXAMPLES
+.TP
+.I Analyse a file and save the notes times and pitches 
+
+$ aubionotes -v -i myloop.wav 2> myloop.txt
+
+The results are expressed in seconds and midi pitch. 
+
+.TP
+.I Start as a jack client
+
+$ aubionotes -t 0.4
+
+Note you will need to have \fIjackd\fP(1) running. Try connecting a midi
+instrument to the aubio midi output.
+
+.SH LIMITATIONS
+The audio feedback is still limited to playing a wood-block sound.
+.SH BUGS
+For now the program works only on audio signals sampled at 44.1 kHz. It is also
+way too intensive. Hopefully this will be fixed in the next release.
+.SH SEE ALSO
+The source code is documented using
+.IR doxygen (1),
+available in the documentation package or at 
+.BR http://piem.homeip.net/~piem/aubio/doc/ .
+.SH AUTHOR
+This manual page was written by Paul Brossier <piem@altern.org>,
+for the Debian project (but may be used by others).
Index: examples/aubionotes.c
===================================================================
--- examples/aubionotes.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/aubionotes.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,267 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <math.h> // how do i do a floorf with a mask again ?
+#include "aubio.h"
+#include "utils.h"
+
+/* settings */
+const char * output_filename = NULL;
+const char * input_filename  = NULL;
+const char * onset_filename  = "/usr/share/sounds/aubio/woodblock.aiff";
+int verbose = 0;
+int usejack = 0;
+int usedoubled = 1;
+int usemidi = 1;
+
+/* energy,specdiff,hfc,complexdomain,phase */
+aubio_onsetdetection_type type_onset  = hfc;
+aubio_onsetdetection_type type_onset2 = hfc;
+smpl_t threshold                      = 0.3;
+smpl_t threshold2                     = -90.;
+uint_t buffer_size                    = 1024;
+uint_t overlap_size                   = 512;
+uint_t channels                       = 1;
+uint_t samplerate                     = 44100;
+
+/* global objects */
+int frames;
+aubio_pvoc_t * pv;
+fvec_t * ibuf;
+fvec_t * obuf;
+cvec_t * fftgrain;
+fvec_t * woodblock;
+aubio_onsetdetection_t *o;
+aubio_onsetdetection_t *o2;
+fvec_t *onset;
+fvec_t *onset2;
+int isonset = 0;
+aubio_pickpeak_t * parms;
+
+/* pitch objects */
+int curnote                = 0;
+smpl_t pitch               = 0.;
+aubio_pitchdetection_t * pitchdet;
+int bufpos = 0;
+smpl_t curlevel = 0;
+smpl_t maxonset = 0.;
+
+/* midi objects */
+aubio_midi_player_t * mplay; 
+aubio_midi_driver_t * mdriver; 
+aubio_midi_event_t  * event;
+
+void send_noteon(aubio_midi_driver_t * d, int pitch, int velo);
+void send_noteon(aubio_midi_driver_t * d, int pitch, int velo)
+{
+    /* we should check if we use midi here, not jack */
+#if ALSA_SUPPORT
+    if (usejack) {
+        if (velo==0) {
+            aubio_midi_event_set_type(event,NOTE_OFF);
+        } else {
+            aubio_midi_event_set_type(event,NOTE_ON);
+        }
+        aubio_midi_event_set_channel(event,0);
+        aubio_midi_event_set_pitch(event,pitch);
+        aubio_midi_event_set_velocity(event,velo);
+        aubio_midi_direct_output(mdriver,event);
+    } else 
+#endif
+    {
+        if (velo==0) {
+            outmsg("%f\n",frames*overlap_size/(float)samplerate);
+        } else {
+            outmsg("%d\t%f\t",pitch,frames*overlap_size/(float)samplerate);
+        }
+    }
+}
+
+int aubio_process(float **input, float **output, int nframes);
+int aubio_process(float **input, float **output, int nframes) {
+  unsigned int i;       /*channels*/
+  unsigned int j;       /*frames*/
+  unsigned int pos = 0; /*frames%dspblocksize*/
+  for (j=0;j<nframes;j++) {
+    if(usejack) {
+      for (i=0;i<channels;i++) {
+        /* write input to datanew */
+        fvec_write_sample(ibuf, input[i][j], i, pos);
+        /* put synthnew in output */
+        output[i][j] = fvec_read_sample(obuf, i, pos);
+      }
+    }
+    /*time for fft*/
+    if (pos == overlap_size-1) {         
+      /* block loop */
+      aubio_pvoc_do (pv,ibuf, fftgrain);
+      aubio_onsetdetection(o,fftgrain, onset);
+      if (usedoubled) {
+        aubio_onsetdetection(o2,fftgrain, onset2);
+        onset->data[0][0] *= onset2->data[0][0];
+      }
+      isonset = aubio_peakpick_pimrt(onset,parms);
+      
+      pitch = aubio_pitchdetection(pitchdet,ibuf);
+
+      /* curlevel is negatif or 1 if silence */
+      curlevel = aubio_level_detection(ibuf, threshold2);
+      if (isonset) {
+        /* test for silence */
+        if (curlevel == 1.) {
+          isonset=0;
+          /* send note off */
+          send_noteon(mdriver,curnote,0);
+        } else {
+          /* kill old note */
+          send_noteon(mdriver,curnote,0);
+          //curnote = (int)FLOOR(bintomidi(pitch,samplerate,buffer_size*4) + .5);
+          curnote = (int)FLOOR(freqtomidi(pitch) + .5);
+          /* get and send new one */
+          /*if (curnote<45){
+            send_noteon(mdriver,curnote,0);
+          } else {*/
+          if (curnote>45){
+            send_noteon(mdriver,curnote,127+(int)FLOOR(curlevel));
+          }
+          for (pos = 0; pos < overlap_size; pos++){
+            obuf->data[0][pos] = woodblock->data[0][pos];
+          }
+        }
+      } else {
+        for (pos = 0; pos < overlap_size; pos++)
+          obuf->data[0][pos] = 0.;
+      }
+      /* end of block loop */
+      pos = -1; /* so it will be zero next j loop */
+    }
+    pos++;
+  }
+  return 1;
+}
+
+int main(int argc, char **argv) {
+
+  aubio_file_t * file = NULL;
+  aubio_file_t * fileout = NULL;
+
+  aubio_file_t * onsetfile = new_file_ro(onset_filename);
+  /* parse command line arguments */
+  parse_args(argc, argv);
+
+  if(!usejack)
+  {
+    debug("Opening files ...\n");
+    file = new_file_ro (input_filename);
+    file_info(file);
+    samplerate = aubio_file_samplerate(file);
+    channels = aubio_file_channels(file);
+    if (output_filename != NULL)
+      fileout = new_file_wo(file, output_filename);
+  }
+
+  ibuf        = new_fvec(overlap_size, channels);
+  obuf        = new_fvec(overlap_size, channels);
+  woodblock   = new_fvec(buffer_size,1);
+  fftgrain    = new_cvec(buffer_size, channels);
+
+  pitchdet = new_aubio_pitchdetection(buffer_size*4, overlap_size, channels, samplerate, mcomb, freq);
+  //pitchdet = new_aubio_pitchdetection(buffer_size*2, overlap_size, channels, samplerate, yin, freq);
+  
+  /* read the output sound once */
+  file_read(onsetfile, overlap_size, woodblock);
+  /* phase vocoder */
+  pv = new_aubio_pvoc(buffer_size, overlap_size, channels);
+  /* onsets */
+  parms = new_aubio_peakpicker(threshold);
+  o = new_aubio_onsetdetection(type_onset,buffer_size,channels);
+  onset = new_fvec(1, channels);
+  if (usedoubled)    {
+    o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels);
+    onset2 = new_fvec(1 , channels);
+  }
+
+  if(usejack) {
+#ifdef JACK_SUPPORT
+    aubio_jack_t * jack_setup;
+    debug("Midi init ...\n");
+    debug("Jack init ...\n");
+    jack_setup = new_aubio_jack(channels, channels,
+          (aubio_process_func_t)aubio_process);
+
+    mplay = new_aubio_midi_player();
+
+    mdriver = new_aubio_midi_driver("alsa_seq",
+        (handle_midi_event_func_t)aubio_midi_send_event, mplay);
+
+    event = new_aubio_midi_event();
+    
+    debug("Jack activation ...\n");
+    aubio_jack_activate(jack_setup);
+    debug("Processing (Ctrl+C to quit) ...\n");
+    pause();
+    send_noteon(mdriver,curnote,0);
+    aubio_jack_close(jack_setup);
+    del_aubio_midi_driver(mdriver);
+#else
+    usage(stderr, 1);
+    outmsg("Compiled without jack output, exiting.\n");
+#endif
+
+  } else {
+    /* phasevoc */
+    debug("Processing ...\n");
+
+    frames = 0;
+
+    while (overlap_size == file_read(file, overlap_size, ibuf))
+    {
+      isonset=0;
+      aubio_process(ibuf->data, obuf->data, overlap_size);
+      if (output_filename != NULL) {
+        file_write(fileout,overlap_size,obuf);
+      }
+      frames++;
+    }
+    send_noteon(mdriver,curnote,0);
+
+    debug("Processed %d frames of %d samples.\n", frames, buffer_size);
+    del_file(file);
+
+    if (output_filename != NULL)
+      del_file(fileout);
+
+  }
+
+  del_aubio_pvoc(pv);
+  del_fvec(obuf);
+  del_fvec(ibuf);
+  del_cvec(fftgrain);
+  del_aubio_pitchdetection(pitchdet);
+  del_fvec(onset);
+
+  debug("End of program.\n");
+  fflush(stderr);
+  return 0;
+}
+
Index: examples/aubionotesmedian.c
===================================================================
--- examples/aubionotesmedian.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/aubionotesmedian.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,330 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <getopt.h>
+#include <unistd.h>
+#include "aubio.h"
+#include "utils.h"
+
+#include <math.h> //required for FLOORF :(
+
+/* settings */
+const char * output_filename = NULL;
+const char * input_filename  = NULL;
+const char * onset_filename  = "/usr/share/sounds/aubio/woodblock.aiff";
+int verbose = 0;
+int usejack = 0;
+int usedoubled = 1;
+int usemidi = 1;
+
+/* energy,specdiff,hfc,complexdomain,phase */
+aubio_onsetdetection_type type_onset  = hfc;
+aubio_onsetdetection_type type_onset2 = complexdomain;
+smpl_t threshold                      = 0.3;
+smpl_t threshold2                     = -90.;
+uint_t buffer_size                    = 1024;
+uint_t overlap_size                   = 512;
+uint_t channels                       = 1;
+uint_t samplerate                     = 44100;
+
+/* global objects */
+int frames;
+aubio_pvoc_t * pv;
+fvec_t * ibuf;
+fvec_t * obuf;
+cvec_t * fftgrain;
+fvec_t * woodblock;
+aubio_onsetdetection_t *o;
+aubio_onsetdetection_t *o2;
+fvec_t *onset;
+fvec_t *onset2;
+int isonset = 0;
+aubio_pickpeak_t * parms;
+
+/* pitch objects */
+smpl_t pitch               = 0.;
+cvec_t * fftpitch          = NULL;
+aubio_filter_t * filter    = NULL;
+aubio_pvoc_t * pvi         = NULL;
+aubio_pitchmcomb_t * p = NULL;
+
+fvec_t * note_buffer = NULL;
+fvec_t * note_buffer2 = NULL;
+uint_t medianfiltlen = 6;
+smpl_t curlevel = 0;
+smpl_t maxonset = 0.;
+
+/* midi objects */
+aubio_midi_player_t * mplay; 
+aubio_midi_driver_t * mdriver; 
+aubio_midi_event_t  * event;
+
+void send_noteon(aubio_midi_driver_t * d, int pitch, int velo);
+void send_noteon(aubio_midi_driver_t * d, int pitch, int velo)
+{
+    /* we should check if we use midi here, not jack */
+#if ALSA_SUPPORT
+    if (usejack) {
+        if (velo==0) {
+            aubio_midi_event_set_type(event,NOTE_OFF);
+        } else {
+            aubio_midi_event_set_type(event,NOTE_ON);
+        }
+        aubio_midi_event_set_channel(event,0);
+        aubio_midi_event_set_pitch(event,pitch);
+        aubio_midi_event_set_velocity(event,velo);
+        aubio_midi_direct_output(mdriver,event);
+    } else 
+#endif
+    {
+        if (velo==0) {
+            outmsg("%f\n",frames*overlap_size/(float)samplerate);
+        } else {
+            outmsg("%d\t%f\t",pitch,frames*overlap_size/(float)samplerate);
+        }
+    }
+}
+
+
+/** append new note candidate to the note_buffer and return filtered value. we
+ * need to copy the input array as vec_median destroy its input data.*/
+
+void note_append(fvec_t * note_buffer, smpl_t curnote); 
+void note_append(fvec_t * note_buffer, smpl_t curnote) {
+  uint_t i = 0;
+  for (i = 0; i < note_buffer->length - 1; i++) { 
+      note_buffer->data[0][i] = note_buffer->data[0][i+1];
+  }
+  note_buffer->data[0][note_buffer->length - 1] = curnote;
+  return;
+}
+
+uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2);
+uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2){
+  uint_t i = 0;
+  for (i = 0; i < note_buffer->length; i++) { 
+      note_buffer2->data[0][i] = note_buffer->data[0][i];
+  }
+  return vec_median(note_buffer2);
+}
+
+
+smpl_t curnote = 0.;
+smpl_t newnote = 0.;
+uint_t isready = 0;
+
+int aubio_process(float **input, float **output, int nframes);
+int aubio_process(float **input, float **output, int nframes) {
+  unsigned int i;       /*channels*/
+  unsigned int j;       /*frames*/
+  unsigned int pos = 0; /*frames%dspblocksize*/
+  for (j=0;j<nframes;j++) {
+    if(usejack) {
+      for (i=0;i<channels;i++) {
+        /* write input to datanew */
+        fvec_write_sample(ibuf, input[i][j], i, pos);
+        /* put synthnew in output */
+        output[i][j] = fvec_read_sample(obuf, i, pos);
+      }
+    }
+    /*time for fft*/
+    if (pos == overlap_size-1) {         
+      /* block loop */
+      aubio_pvoc_do (pv,ibuf, fftgrain);
+      aubio_onsetdetection(o,fftgrain, onset);
+      if (usedoubled) {
+        aubio_onsetdetection(o2,fftgrain, onset2);
+        onset->data[0][0] *= onset2->data[0][0];
+      }
+      isonset = aubio_peakpick_pimrt(onset,parms);
+      
+      aubio_filter_do(filter,ibuf);
+      aubio_filter_do(filter,ibuf);
+      aubio_pvoc_do(pvi,ibuf, fftpitch);
+      pitch = aubio_pitchmcomb_detect(p,fftpitch);
+      newnote = (FLOOR)(bintomidi(pitch,samplerate,buffer_size*4)+.5);
+      note_append(note_buffer, newnote);
+
+      //outmsg("%f    %f\n", pitch, newnote);
+
+      /* curlevel is negatif or 1 if silence */
+      curlevel = aubio_level_detection(ibuf, threshold2);
+      if (isonset) {
+        /* test for silence */
+        if (curlevel == 1.) {
+          isonset=0;
+          isready=0;
+          /* send note off */
+          send_noteon(mdriver,curnote,0);
+        } else {
+          isready = 1;
+          for (pos = 0; pos < overlap_size; pos++){
+            obuf->data[0][pos] = woodblock->data[0][pos];
+          }
+        }
+      } else {
+//        if (curlevel != 1) {
+//          if (bufpos == note_buffer->length)
+//            curnote = aubio_getnote(note_buffer);
+//        }
+//
+        if (isready > 0)
+            isready++;
+        if (isready == note_buffer->length)
+        {
+            //outmsg("%d, %f\n", isready, curnote);
+            send_noteon(mdriver,curnote,0);
+        /* kill old note */
+            newnote = get_note(note_buffer, note_buffer2);
+            curnote = newnote;
+        /* get and send new one */
+        /*if (curnote<45){
+          send_noteon(mdriver,curnote,0);
+        } else {*/
+            if (curnote>45){
+                send_noteon(mdriver,curnote,127+(int)FLOOR(curlevel));
+            }
+        }
+        for (pos = 0; pos < overlap_size; pos++)
+          obuf->data[0][pos] = 0.;
+      }
+      /* end of block loop */
+      //aubio_pvoc_rdo(pv,fftgrain, obuf);
+      pos = -1; /* so it will be zero next j loop */
+    }
+    pos++;
+  }
+  return 1;
+}
+
+int main(int argc, char **argv) {
+
+  aubio_file_t * file = NULL;
+  aubio_file_t * fileout = NULL;
+
+  aubio_file_t * onsetfile = new_file_ro(onset_filename);
+  /* parse command line arguments */
+  parse_args(argc, argv);
+
+  if(!usejack)
+  {
+    debug("Opening files ...\n");
+    file = new_file_ro (input_filename);
+    file_info(file);
+    channels = aubio_file_channels(file);
+    if (output_filename != NULL)
+      fileout = new_file_wo(file, output_filename);
+  }
+
+  ibuf        = new_fvec(overlap_size, channels);
+  obuf        = new_fvec(overlap_size, channels);
+  woodblock   = new_fvec(buffer_size,1);
+  fftgrain    = new_cvec(buffer_size, channels);
+
+  pvi      = new_aubio_pvoc(buffer_size*4, overlap_size, channels);
+  fftpitch = new_cvec(buffer_size*4, channels);
+  filter   = new_aubio_adsgn_filter((smpl_t)samplerate);
+  p        = new_aubio_pitchmcomb(buffer_size*4,channels);
+
+  note_buffer = new_fvec(medianfiltlen, 1);
+  note_buffer2= new_fvec(medianfiltlen, 1);
+  /* read the output sound once */
+  file_read(onsetfile, overlap_size, woodblock);
+
+  /* phase vocoder */
+  debug("Phase voc init ... \n");
+  pv = new_aubio_pvoc(buffer_size, overlap_size, channels);
+
+  /* onsets */
+  parms = new_aubio_peakpicker(threshold);
+  o = new_aubio_onsetdetection(type_onset,buffer_size,channels);
+  onset = new_fvec(1, channels);
+  if (usedoubled)    {
+    o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels);
+    onset2 = new_fvec(1 , channels);
+  }
+
+  if(usejack) {
+#ifdef JACK_SUPPORT
+    aubio_jack_t * jack_setup;
+    debug("Midi init ...\n");
+    debug("Jack init ...\n");
+    jack_setup = new_aubio_jack(channels, channels,
+          (aubio_process_func_t)aubio_process);
+
+    mplay = new_aubio_midi_player();
+
+    mdriver = new_aubio_midi_driver("alsa_seq",
+        (handle_midi_event_func_t)aubio_midi_send_event, mplay);
+
+    event = new_aubio_midi_event();
+    
+    debug("Jack activation ...\n");
+    aubio_jack_activate(jack_setup);
+    debug("Processing (Ctrl+C to quit) ...\n");
+    pause();
+    send_noteon(mdriver,curnote,0);
+    aubio_jack_close(jack_setup);
+    del_aubio_midi_driver(mdriver);
+#else
+    outmsg("Compiled without jack output, exiting.");
+#endif
+
+  } else {
+    /* phasevoc */
+    debug("Processing ...\n");
+
+    frames = 0;
+
+    while (overlap_size == file_read(file, overlap_size, ibuf))
+    {
+      isonset=0;
+      aubio_process(ibuf->data, obuf->data, overlap_size);
+      if (output_filename != NULL) {
+        file_write(fileout,overlap_size,obuf);
+      }
+      frames++;
+    }
+    send_noteon(mdriver,curnote,0);
+
+    debug("Processed %d frames of %d samples.\n", frames, buffer_size);
+    del_file(file);
+
+    if (output_filename != NULL)
+      del_file(fileout);
+
+  }
+
+  del_aubio_pvoc(pv);
+  del_fvec(obuf);
+  del_fvec(ibuf);
+  del_cvec(fftgrain);
+  del_cvec(fftpitch);
+  del_aubio_pvoc(pvi);
+  del_fvec(onset);
+  del_fvec(note_buffer);
+  del_fvec(note_buffer2);
+
+  debug("End of program.\n");
+  fflush(stderr);
+  return 0;
+}
+
Index: examples/aubioonset.1
===================================================================
--- examples/aubioonset.1	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/aubioonset.1	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,103 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH AUBIOONSET 1 "May  3, 2004"
+.\" Please adjust this date whenever revising the man-page.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for man-page-specific macros, see man(7)
+.SH NAME
+aubioonset \- detects onset times in a sound file 
+.SH SYNOPSIS
+.B aubioonset
+.RI [ -i | --input
+.RB < soundfilein > 
+.RI ]
+.RI [ -o | --output 
+.RB < soundfileout > 
+.RI ]
+.RI [ -t | --threshold 
+.RB < thres > 
+.RI ]
+.RI [ -j | --jack ]
+.RI [ -v | --verbose ]
+
+.SH DESCRIPTION
+This manual page documents briefly the
+.B aubioonset
+command.
+.PP
+The \fBaubio\fP library provides a small set of functions to extract events and
+objects from audio, from live streams or still files. Onsets are used to label
+the beginning of notes.
+
+\fBaubioonset\fP extract onsets from an audio input. It works online or
+off-line: live as a jack client, or with an input sound file. When running on a
+file, results can be printed to the console using the \fI\-v\fP flag.
+
+.SH OPTIONS
+This program follows the usual GNU command line syntax, with long
+options starting with two dashes (`-').
+A summary of options is included below.
+.TP
+.B \-i, \-\-input filein
+Run analysis on this audio file. Most common (uncompressed) formats are 
+supported.
+.TP
+.B \-o, \-\-output fileout
+Save results in this file. The file will be created on the model of the input
+file. Results are marked by a very short wood-block sample.
+.TP
+.B \-t, \-\-threshold value
+Set the threshold value for the onset peak picking. Typical values are within
+\fI0.001\fP and \fI0.900\fP. Default is \fI0.1\fP. The \fBlower\fP the \fBmore
+sensible\fP.  Try \fI0.3\fP in case of over-detections.
+.TP
+.B \-j, \-\-jack
+Run in jack mode (default when started without input file).
+.TP
+.B \-h, \-\-help
+Show summary of options.
+.TP
+.B \-v, \-\-verbose
+Show results on the console.
+
+.SH EXAMPLES
+.TP
+.I Analyse a file and save the onsets times (in seconds)
+
+$ aubioonset -v -i myloop.wav 2> myloop.txt
+
+One can start a new project in \fIaudacity\fP(1), import myloop.wav as an audio
+track, and myloop.txt as a label track. This allows to verify each onset
+position, label them with text and select notes, bars and loops.
+
+.TP
+.I Start as a jack client
+
+$ aubioonset -t 0.2
+
+Note you will need to have \fIjackd\fP(1) running.
+
+.SH LIMITATIONS
+The audio feedback in both case is still limited to playing a wood-block sound.
+Midi messages will be sent in the near future.
+.SH BUGS
+For now the program works only on audio signals sampled at 44.1 kHz.
+.SH SEE ALSO
+The source code is documented using
+.IR doxygen (1),
+available in the documentation package or at 
+.BR http://piem.homeip.net/~piem/aubio/doc/ .
+.SH AUTHOR
+This manual page was written by Paul Brossier <piem@altern.org>,
+for the Debian project (but may be used by others).
Index: examples/aubioonset.c
===================================================================
--- examples/aubioonset.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/aubioonset.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,202 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <getopt.h>
+#include <unistd.h>
+#include "aubio.h"
+#include "utils.h"
+
+int aubio_process(float **input, float **output, int nframes);
+
+const char * output_filename = NULL;
+const char * input_filename  = NULL;
+const char * onset_filename  = "/usr/share/sounds/aubio/woodblock.aiff";
+
+/* settings */
+int verbose = 0;
+int usejack = 0;
+int usedoubled = 1;
+
+
+/* energy,specdiff,hfc,complexdomain,phase */
+aubio_onsetdetection_type type_onset  = hfc;
+aubio_onsetdetection_type type_onset2 = complexdomain;
+smpl_t threshold                      = 0.1;
+smpl_t threshold2                     = -90.;
+uint_t buffer_size                    = 1024;
+uint_t overlap_size                   = 512;
+uint_t channels                       = 1;
+uint_t samplerate                     = 44100;
+
+/* global objects */
+aubio_pvoc_t * pv;
+fvec_t * ibuf;
+fvec_t * obuf;
+cvec_t * fftgrain;
+fvec_t * woodblock;
+aubio_onsetdetection_t *o;
+aubio_onsetdetection_t *o2;
+fvec_t *onset;
+fvec_t *onset2;
+int isonset = 0;
+aubio_pickpeak_t * parms;
+
+int aubio_process(float **input, float **output, int nframes) {
+  unsigned int i;       /*channels*/
+  unsigned int j;       /*frames*/
+  unsigned int pos = 0; /*frames%dspblocksize*/
+  for (j=0;j<nframes;j++) {
+    if(usejack) {
+      for (i=0;i<channels;i++) {
+        /* write input to datanew */
+        fvec_write_sample(ibuf, input[i][j], i, pos);
+        /* put synthnew in output */
+        output[i][j] = fvec_read_sample(obuf, i, pos);
+      }
+    }
+    /*time for fft*/
+    if (pos == overlap_size-1) {         
+      /* block loop */
+      aubio_pvoc_do (pv,ibuf, fftgrain);
+      aubio_onsetdetection(o,fftgrain, onset);
+      if (usedoubled) {
+        aubio_onsetdetection(o2,fftgrain, onset2);
+        onset->data[0][0] *= onset2->data[0][0];
+      }
+      isonset = aubio_peakpick_pimrt(onset,parms);
+      if (isonset) {
+        /* test for silence */
+        if (aubio_silence_detection(ibuf, threshold2)==1)
+          isonset=0;
+        else
+          for (pos = 0; pos < overlap_size; pos++){
+            obuf->data[0][pos] = woodblock->data[0][pos];
+          }
+      } else {
+        for (pos = 0; pos < overlap_size; pos++)
+          obuf->data[0][pos] = 0.;
+      }
+      /* end of block loop */
+      //aubio_pvoc_rdo(pv,fftgrain, obuf);
+      pos = -1; /* so it will be zero next j loop */
+    }
+    pos++;
+  }
+  return 1;
+}
+
+int main(int argc, char **argv) {
+  int frames;
+
+  aubio_file_t * file = NULL;
+  aubio_file_t * fileout = NULL;
+
+  aubio_file_t * onsetfile = new_file_ro(onset_filename);
+  parse_args(argc, argv);
+
+  if(!usejack)
+  {
+    debug("Opening files ...\n");
+    file = new_file_ro (input_filename);
+    file_info(file);
+    channels = aubio_file_channels(file);
+    if (output_filename != NULL)
+      fileout = new_file_wo(file, output_filename);
+  }
+
+  ibuf      = new_fvec(overlap_size, channels);
+  obuf      = new_fvec(overlap_size, channels);
+  woodblock = new_fvec(buffer_size,1);
+  fftgrain  = new_cvec(buffer_size, channels);
+
+  /* read the output sound once */
+  file_read(onsetfile, overlap_size, woodblock);
+
+  /* phase vocoder */
+  debug("Phase voc init ... \n");
+  pv = new_aubio_pvoc(buffer_size, overlap_size, channels);
+
+  /* onsets */
+  parms = new_aubio_peakpicker(threshold);
+  o = new_aubio_onsetdetection(type_onset,buffer_size,channels);
+  onset = new_fvec(1, channels);
+  if (usedoubled)    {
+    o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels);
+    onset2 = new_fvec(1 , channels);
+  }
+
+  // command line argument parsing
+  if(usejack) {
+#ifdef JACK_SUPPORT
+    aubio_jack_t * jack_setup;
+    debug("Jack init ...\n");
+    jack_setup = new_aubio_jack(channels, channels,
+          (aubio_process_func_t)aubio_process);
+    debug("Jack activation ...\n");
+    aubio_jack_activate(jack_setup);
+    debug("Processing (Ctrl+C to quit) ...\n");
+    pause();
+    aubio_jack_close(jack_setup);
+#else
+    outmsg("Compiled without jack output, exiting.");
+#endif
+
+  } else {
+    /* phasevoc */
+    debug("Processing ...\n");
+
+    frames = 0;
+
+    while (overlap_size == file_read(file, overlap_size, ibuf))
+    {
+      isonset=0;
+      aubio_process(ibuf->data, obuf->data, overlap_size);
+      /* output times in seconds, taking back some 
+       * delay to ensure the label is _before_ the
+       * actual onset */
+      if (isonset && verbose) {
+        outmsg("%f\n",(frames-4)*overlap_size/(float)samplerate);
+      }
+      if (output_filename != NULL) {
+        file_write(fileout,overlap_size,obuf);
+      }
+      frames++;
+    }
+
+    debug("Processed %d frames of %d samples.\n", frames, buffer_size);
+    del_file(file);
+
+    if (output_filename != NULL)
+      del_file(fileout);
+
+  }
+
+  del_aubio_pvoc(pv);
+  del_fvec(obuf);
+  del_fvec(ibuf);
+  del_cvec(fftgrain);
+  del_fvec(onset);
+
+  debug("End of program.\n");
+  fflush(stderr);
+  return 0;
+}
+
Index: examples/midialsa.c
===================================================================
--- examples/midialsa.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/midialsa.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,15 @@
+/* __copyright__ */
+
+#include "aubio.h"
+#include <unistd.h>
+
+int main(int argc, char **argv) {
+#if ALSA_SUPPORT
+  aubio_midi_player_t * mplay = new_aubio_midi_player();
+  aubio_midi_driver_t * mdriver = new_aubio_midi_driver("alsa_seq",
+    (handle_midi_event_func_t)aubio_midi_send_event, mplay);
+  pause();
+  del_aubio_midi_driver(mdriver);
+#endif
+  return 0;
+}
Index: examples/midiparse.c
===================================================================
--- examples/midiparse.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/midiparse.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,35 @@
+/*
+   copyright (c) 2003 paul brossier
+
+   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., 675 mass ave, cambridge, ma 02139, usa.
+
+*/
+
+#include "aubio.h"
+#include <unistd.h>
+
+int main(int argc, char ** argv) {
+#if ALSA_SUPPORT
+	aubio_midi_player_t * mplay = new_aubio_midi_player();
+	argc--;
+	aubio_midi_player_add(mplay,argv[argc]);
+	while(aubio_midi_player_play_offline(mplay) == 0)
+		pause();
+	aubio_midi_player_stop(mplay);
+	del_aubio_midi_player(mplay);
+#endif
+	return 0;
+} 
+
Index: examples/midiplay.c
===================================================================
--- examples/midiplay.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/midiplay.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,39 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** \bug have it stop at the end of the playlist (but keep using thread, see
+ *      new_aubio_timer call in midi_player)
+ * 
+ */
+
+#include "aubio.h"
+#include <unistd.h>
+
+int main(int argc, char ** argv) {
+#if ALSA_SUPPORT
+  aubio_midi_player_t * mplay = new_aubio_midi_player();
+  argc--;
+  aubio_midi_player_add(mplay,argv[argc]);
+  aubio_midi_player_play(mplay);
+  pause();
+  aubio_midi_player_stop(mplay);
+  del_aubio_midi_player(mplay);
+#endif
+  return 0;
+} 
Index: examples/testforclam.c
===================================================================
--- examples/testforclam.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/testforclam.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,238 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <getopt.h>
+#include <unistd.h>
+
+#include "aubio.h"	
+
+#include "utils.h"
+
+
+const char * output_filename = NULL;
+const char * input_filename = NULL;
+
+const char * onset_filename = "/usr/share/sounds/aubio/woodblock.aiff";
+
+int verbose = 0;
+int usejack = 0;
+
+int aubio_process(float **input, float **output, int nframes);
+
+/* settings */
+
+/* energy,specdiff,hfc,complexdomain,phase */
+aubio_onsetdetection_type type_onset;
+smpl_t threshold = 0.1;
+
+smpl_t threshold2 = -80.;
+
+int buffer_size = 1024;
+int overlap_size = 512;
+int channels = 1;
+int samplerate = 44100;
+
+/* global objects */
+aubio_pvoc_t * pv;
+
+fvec_t * ibuf;
+fvec_t * obuf;
+cvec_t * fftgrain;
+
+fvec_t * woodblock;
+
+aubio_onsetdetection_t *o;
+fvec_t *onset;
+//fvec_t *onset_keep;
+//fvec_t *onset_proc;
+int post = 5;
+int pre  = 1;
+
+int isonset = 0;
+
+aubio_pickpeak_t * parms;
+
+int aubio_process(float **input, float **output, int nframes) {
+	unsigned int i; 	/*channels*/
+	unsigned int j; 	/*frames*/   
+	unsigned int pos = 0; 	/*frames%dspblocksize*/
+	//unsigned int ons = 0; /*onset counter*/
+	for (j=0;j<nframes;j++) {
+
+		for (i=0;i<channels;i++) { 
+			/* write input to datanew */
+			fvec_write_sample(ibuf, input[i][j], i, pos);
+			/* put synthnew in output */
+			output[i][j] = fvec_read_sample(obuf, i, pos);
+		}
+		/*time for fft*/
+		if (pos == overlap_size-1) { 			
+			aubio_pvoc_do (pv,ibuf, fftgrain);
+			aubio_onsetdetection(o,fftgrain, onset);
+			fprintf(stderr,"onsetfunc: %f\n",onset->data[0][0]);
+			isonset = aubio_peakpick_pimrt(onset,parms);
+			if (isonset) {
+				/* test for silence */
+				if (aubio_silence_detection(ibuf, threshold2)==1)
+					isonset=0; 
+				else
+					for (pos = 0; pos < overlap_size; pos++)
+						obuf->data[0][pos] = 
+							woodblock->data[0][pos];
+			} else {
+				for (pos = 0; pos < overlap_size; pos++)
+					obuf->data[0][pos] = 0.;
+			}
+			//aubio_pvoc_rdo(pv,fftgrain, obuf);
+			pos = -1; /* so it will be zero next j loop */
+		}
+		pos++;
+	}
+	return 1;
+}
+
+int main (int argc, char **argv) {  
+	int frames;
+	//int pos;
+
+	aubio_file_t * file = NULL;
+	aubio_file_t * fileout = NULL;
+
+	aubio_file_t * onsetfile = new_file_ro(onset_filename);
+	parse_args(argc, argv);
+
+	if(!usejack) 
+	{
+		debug("Opening  files ...\n");
+		file = new_file_ro (input_filename);
+		file_info(file);
+		channels = aubio_file_channels(file);
+		if (output_filename != NULL)
+			fileout = new_file_wo(file, output_filename);
+	}
+
+	ibuf = new_fvec(overlap_size, channels);
+	obuf = new_fvec(overlap_size, channels);
+	woodblock = new_fvec(buffer_size,1);
+	fftgrain = new_cvec(buffer_size, channels);
+
+	file_read(onsetfile, overlap_size, woodblock);
+
+	/* phase vocoder */
+	debug("Phase voc init ... \n");
+	pv = new_aubio_pvoc(buffer_size, overlap_size, channels);
+
+	/* onset init */
+	debug("type_onset: %d\n", (int)type_onset);
+	debug("threshold : %f\n", threshold);
+	parms = new_aubio_peakpicker(threshold);
+
+	o = new_aubio_onsetdetection(type_onset,buffer_size,channels);
+	/*onset = new_fvec(overlap_size, channels);
+	for (frames=0;frames<overlap_size;frames++){
+		onset->data[0][frames] = 0.; 
+	}*/
+	onset = new_fvec(0, channels);
+	
+	//onset_keep = new_fvec(post+pre+1, channels);
+	//onset_proc = new_fvec(post+pre+1, channels);
+
+	// command line argument parsing
+	if(usejack) {
+#ifdef JACK_SUPPORT
+		aubio_jack_t * jack_setup;
+		debug("Jack init ...\n");
+		jack_setup = new_aubio_jack(channels, channels, 
+				(aubio_process_func_t)aubio_process);
+
+		/* initialise fftgrain */
+		aubio_pvoc_do (pv,ibuf, fftgrain);
+
+		debug("Jack activation ...\n");
+		aubio_jack_activate(jack_setup);
+
+		debug("Processing (Ctrl+C to quit) ...\n");
+		pause();
+
+		aubio_jack_close(jack_setup);
+#endif
+
+	} else {
+		fvec_t * inputbuf ;
+		fvec_t * outputbuf;
+		/* file objects */
+
+		inputbuf 	= new_fvec(overlap_size, channels);
+		outputbuf	= new_fvec(overlap_size, channels);	
+		/* phasevoc init */
+		debug("Processing ...\n");
+
+		/** \bug phasevoc not initialized yet */
+		/* initialise fftgrain and input bug */
+		for (frames=0;frames<2;frames++) {
+			aubio_pvoc_do (pv,inputbuf, fftgrain);
+		}
+
+		/** start filling the phasevoc */
+		//for (frames=0;frames<1;frames++) {
+			//file_read(file, overlap_size, inputbuf);
+			//aubio_pvoc_do (pv,inputbuf, fftgrain);
+			/** \bug onset is still badly initialized */
+			//aubio_onsetdetection(o,fftgrain, onset);
+		//}
+
+		//debug("coucou\n");
+		frames = 0;
+		while ((overlap_size == file_read(file, overlap_size, inputbuf)) ) 
+		{
+			isonset=0;
+			aubio_process(inputbuf->data, outputbuf->data, overlap_size);
+			if (isonset) {
+				/*output times in seconds*/
+				//errmsg("%f\n",(frames-1)*overlap_size/(float)samplerate);
+				errmsg("%f\n",(frames-3)*overlap_size/(float)samplerate);
+			}
+			if (output_filename != NULL)
+				file_write(fileout,overlap_size,outputbuf);
+			frames++;
+		}
+		debug("Processed %d frames of %d samples.\n", frames, buffer_size);
+		del_file(file);
+		if (output_filename != NULL)
+			del_file(fileout);
+	}
+
+	del_aubio_pvoc(pv);
+
+	del_fvec(obuf);
+	del_fvec(ibuf);
+	del_cvec(fftgrain);
+	//del_fvec(onset_keep);
+	//del_fvec(onset_proc);
+	del_fvec(onset);
+
+	debug("End of program.\n");
+	fflush(stderr);
+	return 0;
+}
+
+
Index: examples/utils.c
===================================================================
--- examples/utils.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/utils.c	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,135 @@
+
+#include "aubio.h"
+
+#ifndef JACK_SUPPORT
+#define JACK_SUPPORT 0
+#endif
+
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h> /* for isfinite */
+#include "utils.h"
+
+#ifdef LADCCA_SUPPORT
+#include <ladcca/ladcca.h>
+cca_client_t * aubio_cca_client;
+#endif /* LADCCA_SUPPORT */
+
+
+/* badly redeclare some things */
+aubio_onsetdetection_type type_onset;
+smpl_t threshold;
+smpl_t averaging;
+const char * prog_name;
+
+void usage (FILE * stream, int exit_code)
+{
+	fprintf(stream, "usage: %s [ options ] \n", prog_name);
+	fprintf(stream, 
+			"	-j	--jack		Use Jack.\n"
+			"	-o	--output	Output type.\n"
+			"	-i	--input		Input type.\n"
+			"	-h	--help		Display this message.\n"
+			"	-v	--verbose	Print verbose message.\n"
+			);
+	exit(exit_code);
+}
+
+int parse_args (int argc, char **argv) {
+	const char *options = "hvjo:i:O:t:a";
+	int next_option;
+	struct option long_options[] =
+	{
+		{"help", 		0, NULL, 'h'},
+		{"verbose",	0, NULL, 'v'},
+		{"jack", 		0, NULL, 'j'},
+		{"output", 	0, NULL, 'o'},
+		{"input", 	0, NULL, 'i'},
+		{"onset", 	0, NULL, 'O'},
+		{"threshold", 	0, NULL, 't'},
+		{"averaging", 	0, NULL, 'a'},
+		{NULL,			0, NULL, 0}
+	};
+	prog_name = argv[0];	
+	if( argc < 1 ) {
+		usage (stderr, 1);
+		return -1;
+	}
+	do {
+		next_option = getopt_long (argc, argv, options, 
+									long_options, NULL);
+		switch (next_option) {
+			case 'o':
+				output_filename = optarg;
+				break;
+			case 'i':
+				input_filename = optarg;
+				break;
+			case 'h': 	/* help */
+				usage (stdout, 0);
+				return -1;
+			case 'v':		/* verbose */
+				verbose = 1;
+				break;
+			case 'j':		/* verbose */
+				usejack = 1;
+				break;
+      case 'O':   /*onset type*/
+        if (strcmp(optarg,"energy") == 0) 
+          type_onset = energy;
+        else if (strcmp(optarg,"specdiff") == 0) 
+          type_onset = specdiff;
+        else if (strcmp(optarg,"hfc") == 0) 
+          type_onset = hfc;
+        else if (strcmp(optarg,"complexdomain") == 0) 
+          type_onset = complexdomain;
+        else if (strcmp(optarg,"phase") == 0) 
+          type_onset = phase;
+        else {
+          debug("could not get onset type.\n");
+          abort();
+        }
+        break;
+      case 't':   /* threshold value for onset */
+        threshold = (smpl_t)atof(optarg);
+        /*
+        if (!isfinite(threshold)) {
+          debug("could not get threshold.\n");
+          abort();
+        }
+        */
+        break;
+      case 'a':
+        averaging = 1;
+        break; 
+			case '?': 	/* unknown options */
+				usage(stderr, 1);
+        break;
+			case -1: 		/* done with options */
+				break;
+			default: 		/*something else unexpected */
+				abort ();
+		}
+	}
+	while (next_option != -1);
+
+	if (input_filename != NULL) {
+		errmsg ("Input file : %s\n", input_filename );
+	} else if (input_filename != NULL && output_filename != NULL) {
+		errmsg ("Input file : %s\n", input_filename );
+		errmsg ("Output file : %s\n", output_filename );
+	} else {
+		if (JACK_SUPPORT)
+		{
+			errmsg ("Jack input output\n");
+			usejack = 1;
+		} else {
+			errmsg ("Error: Could not switch to jack mode\n   aubio was compiled without jack support\n");
+			exit(1);
+		}
+	}	
+	return 0;
+}
+
Index: examples/utils.h
===================================================================
--- examples/utils.h	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
+++ examples/utils.h	(revision 96fb8ad625b1b62c2551bd98a7af1aa3f00307f6)
@@ -0,0 +1,31 @@
+/*
+	 Copyright (C) 2003 Paul Brossier
+
+	 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+	 
+*/
+
+#define debug(...) if (verbose) fprintf (stderr, __VA_ARGS__)
+#define errmsg(...) fprintf (stderr, __VA_ARGS__)
+#define outmsg(...) fprintf (stdout, __VA_ARGS__)
+
+extern int verbose;
+extern int usejack;
+extern const char * output_filename;
+extern const char * input_filename;
+/* defined in utils.c */
+void usage (FILE * stream, int exit_code);
+int parse_args (int argc, char **argv);
+
