Discussion:
Port Audio Java Bindings
(too old to reply)
Sam Proctor
2018-03-17 17:59:15 UTC
Permalink
Hi,
I am new to Port Audio but have been pointed to this as a solution for my project. I am a (relatively new) java developer, and have only very basic knowledge of other languages, however Java cannot handle my requirements for accessing multiple streams of audio from different audio interfaces.
I have downloaded the pa_stable_v190600_20161030.tgz<http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz> folder from the website. I have followed through what I can, however I am still confused how to set this up for a java app running on osx.

I have read within the jportaudio.dox comments that the project should be opened with eclipse and exported as a JAR file labelled jportaudio and then add this as a library to the java project I am building. In theory simple enough (if I am doing it correctly), however every time I try and run my project ( which is currently just querying the PortAudio Release build), the application will not build, and returns ‘unknown file type’ for the jportaudio.jar file. It is initialising the portaudio class and where the OS architecture type is queried and pointed to a Library to load, it struggles to load the jportaudio library.

Am I missing step here? I ended up going through installing portaudio via homebrew through terminal, but unsure how that helps me as from what I can see I want to make it a jar file to package as a java library and then all of the applicable files will be access through that.

Any help would be much appreciated, as I am keen to get up and running with this any way I can,

Regards,

Sam Proctor
Phil Burk
2018-03-17 19:24:48 UTC
Permalink
Hello Sam,

> however Java cannot handle my requirements for accessing multiple streams
of audio from different audio interfaces.

Are you sure? JPortAudio was written back in 2012 because JavaSound used to
crackle, only supported 16-bit audio, and only supported mono and stereo.
JavaSound no longer crackles and may have had other improvements.

If you still need JPortAudio, there is a precompiled version here for Mac
and Windows:

http://www.softsynth.com/jsyn/developers/download.php

> every time I try and run my project ( which is currently just querying
the PortAudio Release build),

Are you trying to use JPortAudio from Eclipse or from XCode?

Note that you can either use the jportaudio.jar or just add the JPortAudio
source to your Java project.

> the application will not build, and returns ‘unknown file type’ for the
jportaudio.jar file.

You want the jportaudio.jar to be in your CLASSPATH. There are several ways
to do that depending on which IDE you are using.

> It is initialising the portaudio class and where the OS architecture type
is queried and pointed to a Library to load, it struggles to load the
jportaudio library.

Is this the code you are referring to?


https://app.assembla.com/spaces/portaudio/git/source/master/bindings/java/jportaudio/src/com/portaudio/PortAudio.java

The jportaudio.jnilib needs to be in your library path. That is the key.
The JSyn download has instructions for that.

To use JPortAudio with any Java application:
>
> 1. Place the jportaudio.jar and libjportaudio.jnilib files in your
> "~/Library/Java/Extensions" folder.
>
>
Phil Burk


On Sat, Mar 17, 2018 at 10:59 AM, Sam Proctor <***@hotmail.com> wrote:

> Hi,
> I am new to Port Audio but have been pointed to this as a solution for my
> project. I am a (relatively new) java developer, and have only very basic
> knowledge of other languages, however Java cannot handle my requirements
> for accessing multiple streams of audio from different audio interfaces.
> I have downloaded the pa_stable_v190600_20161030.tgz
> <http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz> folder
> from the website. I have followed through what I can, however I am still
> confused how to set this up for a java app running on osx.
>
> I have read within the jportaudio.dox comments that the project should be
> opened with eclipse and exported as a JAR file labelled jportaudio and then
> add this as a library to the java project I am building. In theory simple
> enough (if I am doing it correctly), however every time I try and run my
> project ( which is currently just querying the PortAudio Release build),
> the application will not build, and returns ‘unknown file type’ for the
> jportaudio.jar file. It is initialising the portaudio class and where the
> OS architecture type is queried and pointed to a Library to load, it
> struggles to load the jportaudio library.
>
> Am I missing step here? I ended up going through installing portaudio via
> homebrew through terminal, but unsure how that helps me as from what I can
> see I want to make it a jar file to package as a java library and then all
> of the applicable files will be access through that.
>
> Any help would be much appreciated, as I am keen to get up and running
> with this any way I can,
>
> Regards,
>
> Sam Proctor
>
>
> _______________________________________________
> Portaudio mailing list
> ***@lists.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/portaudio
>
Sam Proctor
2018-03-18 10:26:22 UTC
Permalink
Hi Phil,

Thank you so much for your quick response. I appreciate you taking the time to respond.
I have followed your instructions and downloaded JSyn. I did not previously have the libjportaudio.jnilib file. The minute I downloaded that and placed in my java extensions folder everything worked as expected. I can now start looking into using jportaudio.

For my project I am looking at realtime audio analysis, and came across a couple of weird behaviours using the java sound API. I can access multiple channels and deinterleave, however for some reason my the audio buffer was taking varying times to fill for each 'pass.' I thought it may be an issue with how I had setup my threads so started a new application with no gui which just started a targetdataline stream into a buffer and timestamped when the buffer was full each time. Code copied directly from the oracle website. ie, if I had a 48kHz mono stream at 16 bits, filling a buffer of size of 48000 bytes, I would expect that to take 500ms to fill. In reality this varies by up to 10ms on each pass, and then every now and then will only take 127ms to fill (which is impossible). This is the entire code with no callbacks, no processing or anything other than simply filling a buffer.
Still something weird is going on, and whilst the handling of devices is good on JavaSound I still do not entirely trust it. Nobody has managed to provide an explanation for this. Most of the information I have found has pointed me towards doing my device implementation in C, and use callbacks to the processing each time the buffer has filled.
The only major requirement is it is cross platform and as stable as possible. As Port Audio is tried and tested (if a little old), I feel at least learning a bit more about it will help me with my project.

Thanks for your help,

Sam
________________________________
From: portaudio-***@lists.columbia.edu <portaudio-***@lists.columbia.edu> on behalf of Phil Burk <***@mobileer.com>
Sent: 17 March 2018 19:24
To: portaudio list
Subject: Re: [Portaudio] Port Audio Java Bindings

Hello Sam,

> however Java cannot handle my requirements for accessing multiple streams of audio from different audio interfaces.

Are you sure? JPortAudio was written back in 2012 because JavaSound used to crackle, only supported 16-bit audio, and only supported mono and stereo. JavaSound no longer crackles and may have had other improvements.

If you still need JPortAudio, there is a precompiled version here for Mac and Windows:

http://www.softsynth.com/jsyn/developers/download.php

> every time I try and run my project ( which is currently just querying the PortAudio Release build),

Are you trying to use JPortAudio from Eclipse or from XCode?

Note that you can either use the jportaudio.jar or just add the JPortAudio source to your Java project.

> the application will not build, and returns ‘unknown file type’ for the jportaudio.jar file.

You want the jportaudio.jar to be in your CLASSPATH. There are several ways to do that depending on which IDE you are using.

> It is initialising the portaudio class and where the OS architecture type is queried and pointed to a Library to load, it struggles to load the jportaudio library.

Is this the code you are referring to?

https://app.assembla.com/spaces/portaudio/git/source/master/bindings/java/jportaudio/src/com/portaudio/PortAudio.java

The jportaudio.jnilib needs to be in your library path. That is the key. The JSyn download has instructions for that.

To use JPortAudio with any Java application:

1. Place the jportaudio.jar and libjportaudio.jnilib files in your "~/Library/Java/Extensions" folder.

Phil Burk


On Sat, Mar 17, 2018 at 10:59 AM, Sam Proctor <***@hotmail.com<mailto:***@hotmail.com>> wrote:
Hi,
I am new to Port Audio but have been pointed to this as a solution for my project. I am a (relatively new) java developer, and have only very basic knowledge of other languages, however Java cannot handle my requirements for accessing multiple streams of audio from different audio interfaces.
I have downloaded the pa_stable_v190600_20161030.tgz<http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz> folder from the website. I have followed through what I can, however I am still confused how to set this up for a java app running on osx.

I have read within the jportaudio.dox comments that the project should be opened with eclipse and exported as a JAR file labelled jportaudio and then add this as a library to the java project I am building. In theory simple enough (if I am doing it correctly), however every time I try and run my project ( which is currently just querying the PortAudio Release build), the application will not build, and returns ‘unknown file type’ for the jportaudio.jar file. It is initialising the portaudio class and where the OS architecture type is queried and pointed to a Library to load, it struggles to load the jportaudio library.

Am I missing step here? I ended up going through installing portaudio via homebrew through terminal, but unsure how that helps me as from what I can see I want to make it a jar file to package as a java library and then all of the applicable files will be access through that.

Any help would be much appreciated, as I am keen to get up and running with this any way I can,

Regards,

Sam Proctor
Loading...