java/: added first draft for a java interface to aubio, includes simple test
authorPaul Brossier <piem@piem.org>
Wed, 6 Feb 2008 15:28:31 +0000 (16:28 +0100)
committerPaul Brossier <piem@piem.org>
Wed, 6 Feb 2008 15:28:31 +0000 (16:28 +0100)
.bzrignore
configure.ac
java/Makefile.am [new file with mode: 0644]
java/aubio/Makefile.am [new file with mode: 0644]
java/aubio/main.java [new file with mode: 0644]

index 8d7217073153b061b751b3da5699743437e87f89..4746d488ce6d0ee662b60dbb36b498d2e21734db 100644 (file)
@@ -26,6 +26,12 @@ doc/*.1
 **/cachegrind.out.[0-9]*
 **/callgrind.out.[0-9]*
 
+# swig and java stuff
+**/*.class
+java/**/SWIG*.java
+java/**/aubio*.java
+java/**/midi_*.java
+
 # autoreconf -f -i will create these
 INSTALL
 aclocal.m4
index ac299f8247c684ef7a8375947e0b1c873c576635..1b326bd0ae3b6d36bc9b4ba38175c84c6d3c8af8 100644 (file)
@@ -257,6 +257,8 @@ AC_OUTPUT([
     swig/Makefile
     python/Makefile
     python/aubio/Makefile
+    java/Makefile
+    java/aubio/Makefile
     plugins/Makefile
     plugins/audacity/Makefile
     plugins/audacity/plug-ins/Makefile
diff --git a/java/Makefile.am b/java/Makefile.am
new file mode 100644 (file)
index 0000000..a093006
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = aubio
diff --git a/java/aubio/Makefile.am b/java/aubio/Makefile.am
new file mode 100644 (file)
index 0000000..2f81094
--- /dev/null
@@ -0,0 +1,32 @@
+NOWARN_CFLAGS = -Wno-strict-aliasing
+
+AM_CFLAGS = @AUBIO_CFLAGS@ $(NOWARN_CFLAGS) $(SWCFLAGS) \
+       -I$(top_builddir)/src -I$(top_srcdir)/src -I$(top_srcdir)/ext \
+       -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) \
+       -L$(top_builddir)/ext -laubioext \
+       -L$(top_builddir)/src -laubio
+
+pkgjavadir = /usr/local/lib/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)/swig/aubio.i
+
+CLEANFILES = aubio_* SWIGTYPE_* *aubiowrapper* midi_* 
+
+simple_test:
+       javac *.java
+       LD_LIBRARY_PATH=.libs java main 
diff --git a/java/aubio/main.java b/java/aubio/main.java
new file mode 100644 (file)
index 0000000..f315387
--- /dev/null
@@ -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);
+  }
+}
+