PortAudio  2.0
JPortAudio Java Binding

Note: this page has not been reviewed, and may contain errors.


9/4/12 JPortAudio is very new and should be considered an "alpha" release. The building of JPortAudio will eventually be integrated into the Makefile as an optional build.

Currently JPortAudio is only supported for Windows and Macintosh. Please contact us if you want to help with porting Linux.

For reference documentation of the JPortAudio API see: com.portaudio.PortAudio

For an example see: PlaySine.java

Building JPortAudio on Windows

Build the Java code using the Eclipse project in "jportaudio". Export as "jportaudio.jar".

If you modify the JNI API then you will need to regenerate the JNI .h files using:

cd bindings/java/scripts

Build the JNI DLL using the Visual Studio 2010 solution in "java/c/build/vs2010/PortAudioJNI".

Using JPortAudio on Windows

Put the "jportaudio.jar" in the classpath for your application. Place the following libraries where they can be found, typically in the same folder as your application.

Building JPortAudio on Mac

These are notes from building JPortAudio on a Mac with 10.6.8 and XCode 4.

I created a target of type 'C' library.

I added the regular PortAudio frameworks plus the JavaVM framework.

I modified com_portaudio_PortAudio.h and com_portaudio_BlockingStream.h so that jni.h could found.

#if defined(__APPLE__)
#include <JavaVM/jni.h>
#include <jni.h>

This is bad because those header files are autogenerated and will be overwritten. We need a better solution for this.

I had trouble finding the "libjportaudio.jnilib". So I added a Build Phase that copied the library to "/Users/phil/Library/Java/Extensions".

On the Mac we can create a universal library for both 32 and 64-bit JVMs. So in the JAR file I will open "jportaudio" on Apple. ON WIndows I will continue to open "jportaudio_x64" and "jportaudio_x86".