import first version from aubio 920
authorPaul Brossier <piem@piem.org>
Thu, 5 Nov 2009 16:26:16 +0000 (17:26 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 5 Nov 2009 16:26:16 +0000 (17:26 +0100)
Makefile.am [new file with mode: 0644]
aubio.i [new file with mode: 0644]
configure.ac [new file with mode: 0644]
main.java [new file with mode: 0644]

diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..c4d4244
--- /dev/null
@@ -0,0 +1,29 @@
+NOWARN_CFLAGS = -Wno-strict-aliasing
+
+AM_CFLAGS = @AUBIO_CFLAGS@ $(NOWARN_CFLAGS) $(SWCFLAGS) \
+       -I/usr/lib/jvm/java-6-sun-1.6.0.04/include \
+       -I${prefix}/lib/jvm/java-6-sun-1.6.0.04/include \
+       -I/usr/lib/jvm/java-6-sun-1.6.0.04/include/linux \
+       -I${prefix}/lib/jvm/java-6-sun-1.6.0.04/include/linux \
+       -I/usr/include \
+       -I${prefix}/include
+
+SWLDFLAGS = -shared
+
+AUBIO_LDFLAGS = $(SWLDFLAGS) @AUBIO_LIBS@ 
+
+pkgjavadir = ${libdir}/java/aubio
+
+pkgjava_LTLIBRARIES = libaubiowrapper.la
+
+libaubiowrapper_la_LDFLAGS = -module -avoid-version $(AUBIO_LDFLAGS) 
+libaubiowrapper_la_SOURCES = aubio_wrap.c
+
+aubio_wrap.c:
+       $(SWIG) -outdir . -o aubio_wrap.c -java $(top_srcdir)/aubio.i
+
+CLEANFILES = aubio_* SWIGTYPE_* *aubiowrapper* midi_* 
+
+simple_test:
+       javac *.java
+       LD_LIBRARY_PATH=.libs java main 
diff --git a/aubio.i b/aubio.i
new file mode 100644 (file)
index 0000000..7a4be2a
--- /dev/null
+++ b/aubio.i
@@ -0,0 +1,109 @@
+%module aubiowrapper
+
+%{
+#include <aubio/aubio.h>
+%}
+
+/* type aliases */
+typedef unsigned int uint_t;
+typedef int sint_t;
+typedef float smpl_t;
+
+/* fvec */
+fvec_t * new_fvec(uint_t length, uint_t channels);
+void del_fvec(fvec_t *s);
+smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position);
+void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position);
+smpl_t * fvec_get_channel(fvec_t *s, uint_t channel);
+void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel);
+smpl_t ** fvec_get_data(fvec_t *s);
+
+/* cvec */
+cvec_t * new_cvec(uint_t length, uint_t channels);
+void del_cvec(cvec_t *s);
+void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
+void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
+smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
+smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
+void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
+void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
+smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
+smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
+smpl_t ** cvec_get_norm(cvec_t *s);
+smpl_t ** cvec_get_phas(cvec_t *s);
+
+
+/* fft */
+aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels);
+void del_aubio_fft(aubio_fft_t * s);
+void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum);
+void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output);
+void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec);
+void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output);
+void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum);
+void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec);
+void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum);
+void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec);
+void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum);
+void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec);
+
+/* filter */
+aubio_filter_t * new_aubio_filter(uint_t order, uint_t channels);
+void aubio_filter_do(aubio_filter_t * b, fvec_t * in);
+void aubio_filter_do_outplace(aubio_filter_t * b, fvec_t * in, fvec_t * out);
+void aubio_filter_do_filtfilt(aubio_filter_t * b, fvec_t * in, fvec_t * tmp);
+void del_aubio_filter(aubio_filter_t * b);
+
+/* a_weighting */
+aubio_filter_t * new_aubio_filter_a_weighting (uint_t channels, uint_t samplerate);
+uint_t aubio_filter_set_a_weighting (aubio_filter_t * b, uint_t samplerate);
+
+/* c_weighting */
+aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate);
+uint_t aubio_filter_set_c_weighting (aubio_filter_t * b, uint_t samplerate);
+
+/* biquad */
+aubio_filter_t * new_aubio_filter_biquad(lsmp_t b1, lsmp_t b2, lsmp_t b3, lsmp_t a2, lsmp_t a3, uint_t channels);
+uint_t aubio_filter_set_biquad (aubio_filter_t * b, lsmp_t b1, lsmp_t b2, lsmp_t b3, lsmp_t a2, lsmp_t a3);
+
+/* mathutils */
+fvec_t * new_aubio_window(char * wintype, uint_t size);
+smpl_t aubio_unwrap2pi (smpl_t phase);
+smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_miditobin(smpl_t midi, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_freqtobin(smpl_t freq, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_freqtomidi(smpl_t freq);
+smpl_t aubio_miditofreq(smpl_t midi);
+uint_t aubio_silence_detection(fvec_t * ibuf, smpl_t threshold);
+smpl_t aubio_level_detection(fvec_t * ibuf, smpl_t threshold);
+smpl_t aubio_zero_crossing_rate(fvec_t * input);
+
+/* mfcc */
+aubio_mfcc_t * new_aubio_mfcc (uint_t win_s, uint_t samplerate, uint_t n_filters, uint_t n_coefs);
+void del_aubio_mfcc(aubio_mfcc_t *mf);
+void aubio_mfcc_do(aubio_mfcc_t *mf, cvec_t *in, fvec_t *out);
+
+/* pvoc */
+aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels);
+void del_aubio_pvoc(aubio_pvoc_t *pv);
+void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t *in, cvec_t * fftgrain);
+void aubio_pvoc_rdo(aubio_pvoc_t *pv, cvec_t * fftgrain, fvec_t *out);
+
+/* pitch detection */
+aubio_pitch_t *new_aubio_pitch (char *pitch_mode,
+    uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate);
+void aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
+uint_t aubio_pitch_set_tolerance(aubio_pitch_t *p, smpl_t thres);
+uint_t aubio_pitch_set_unit(aubio_pitch_t *p, char * pitch_unit);
+void del_aubio_pitch(aubio_pitch_t * p);
+
+/* tempo */
+aubio_tempo_t * new_aubio_tempo (char_t * mode,
+    uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
+void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo);
+uint_t aubio_tempo_set_silence(aubio_tempo_t * o, smpl_t silence);
+uint_t aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold);
+smpl_t aubio_tempo_get_bpm(aubio_tempo_t * bt);
+smpl_t aubio_tempo_get_confidence(aubio_tempo_t * bt);
+void del_aubio_tempo(aubio_tempo_t * o);
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..59eb1e5
--- /dev/null
@@ -0,0 +1,34 @@
+dnl Process this file with autoconf to produce a configure script
+
+dnl Init autoconf
+AC_INIT([java-aubio], [0.2])
+AC_CONFIG_SRCDIR([aubio.i])
+
+dnl Init automake
+AM_INIT_AUTOMAKE([dist-bzip2 no-define])
+
+dnl Check for pkg-config
+AC_PATH_PROG(PKG_CONFIG,pkg-config,no)
+
+dnl Check for aubio
+PKG_CHECK_MODULES(AUBIO, aubio >= 0.4.0, HAVE_AUBIO=1)
+
+dnl Check for swig 
+AC_PATH_PROG(SWIG,swig,no)
+AM_CONDITIONAL(SWIGFOUND, test "${SWIG}" != "no")
+
+dnl Check for Java
+AC_CHECK_HEADER(jni.h,JAVAHEADERS=y,AC_MSG_ERROR([Java header jni.h not found.]))
+AM_CONDITIONAL(JAVAFOUND, test "${JAVAHEADERS}" = "y")
+
+dnl Check for libtool
+AC_LIBTOOL_DLOPEN
+dnl AC_DISABLE_STATIC
+dnl allow cross compiling
+AC_LIBTOOL_WIN32_DLL
+AC_PROG_LIBTOOL
+
+dnl Create Makefiles
+AC_OUTPUT([
+    Makefile
+])
diff --git a/main.java b/main.java
new file mode 100644 (file)
index 0000000..f315387
--- /dev/null
+++ b/main.java
@@ -0,0 +1,19 @@
+// main.java
+
+public class main {
+  static {
+    System.loadLibrary("aubiowrapper");
+  }
+
+  public static void main(String argv[]) {
+    float freq = (float)440.;
+    float midi = aubiowrapper.aubio_freqtomidi( (float)440.);
+    if (midi != (float) 69.0) {
+      throw new Error((String) "Error: aubio_freqtomidi(440.) != 69.", null);
+    }
+    System.out.print(freq);
+    System.out.print(" Hz corresponds to midi note ");
+    System.out.println(midi);
+  }
+}
+