Multiple Audio Inputs from DAC

23 views
Skip to first unread message

Emily Meuer

unread,
Nov 15, 2016, 11:44:03 AM11/15/16
to JAudioLibs

Hi, all,

I am working on a live music visualization project in Java (technically Processing, but we're using Eclipse) that requires audio input from multiple mics at the same time. We had a good system going with Beads and JACK, but I would like to be independent of JACK -- it has been flaky and I simply don't trust it in a professional setting.

However, I haven't been able to access multiple lines from my DAC within Java. I can get the Mixer that corresponds to it, open a TargetDataLine, get the data from an AudioInputStream into a buffer, but this all corresponds to the first mic only. Is there a way that I can grab a different line while remaining in Java, or will I have to do some combination of C/PortAudio-or-equivalent with JNI?


Thanks!

 - Emily M.

Neil C Smith

unread,
Nov 15, 2016, 11:58:53 AM11/15/16
to jaudi...@googlegroups.com
Hi Emily,

On 15 November 2016 at 16:39, Emily Meuer <emily...@gmail.com> wrote:
> I am working on a live music visualization project in Java (technically Processing, but we're using Eclipse) that requires audio input from multiple mics at the same time. We had a good system going with Beads and JACK, but I would like to be independent of JACK -- it has been flaky and I simply don't trust it in a professional setting.

Interesting! What OS are you on? JACK is probably the most
professionally targeted option available, but has got a bit flaky on
some systems recently. It might be better to follow up with the JACK
team though around this - I know there are various builds flying
around that aren't strictly public.

> However, I haven't been able to access multiple lines from my DAC within Java. I can get the Mixer that corresponds to it, open a TargetDataLine, get the data from an AudioInputStream into a buffer, but this all corresponds to the first mic only. Is there a way that I can grab a different line while remaining in Java, or will I have to do some combination of C/PortAudio-or-equivalent with JNI?

Without knowing which OS there's not a direct answer to your first
question. Targeting PortAudio with JNA might be an option, and it's
something I've considered for an AudioServer implementation. There's
an ASIO audioserver implementation flying around GitHub somewhere too.

Incidentally, without a hint of bias ;-), you should check out Praxis
LIVE (www.praxislive.org) if you want to do music visualization with
Processing. Default Processing has a terrible architecture for this
sort of thing.

Best wishes,

Neil

--
Neil C Smith
Artist & Technologist
www.neilcsmith.net

Praxis LIVE - hybrid visual IDE for creative coding - www.praxislive.org

Oliver Bown

unread,
Nov 16, 2016, 6:02:50 PM11/16/16
to jaudi...@googlegroups.com
Yeah Java has never properly handled integration with devices and the only successful solution I’ve found is to work with Jack. Currently on a Mac Jack is a really random mixed bag and is in quite a state of disarray in its development. I found myself having to fiddle with different legacy versions, then someone actually posted me a working zip on FB! 

If there is a community need to do a whip round and commission the production of an awesome general purpose Java IO then I’d certainly chip in. I think a JNA interface to RTAudio or PortAudio, like Neil has done with Jack, would be killer. The user installs the required libraries via a package manager, and Java finds them in standard system locations. Seems like a better strategy than trying to package and link libraries in jars or something horrible like that.

Ollie

--
You received this message because you are subscribed to the Google Groups "JAudioLibs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jaudiolibs+...@googlegroups.com.
To post to this group, send email to jaudi...@googlegroups.com.
Visit this group at https://groups.google.com/group/jaudiolibs.
For more options, visit https://groups.google.com/d/optout.

Neil C Smith

unread,
Nov 17, 2016, 6:08:59 AM11/17/16
to jaudi...@googlegroups.com
Hi,

On 16 November 2016 at 23:02, Oliver Bown <ol...@icarus.nu> wrote:
> Yeah Java has never properly handled integration with devices and the only successful solution I’ve found is to work with Jack.

Or use Linux! Both JavaSound and JACK work pretty well here. Unless
you need a particular bit of commercial software I'd never use a
consumer OS for building performance or interactive tools.

> Currently on a Mac Jack is a really random mixed bag and is in quite a state of disarray in its development. I found myself having to fiddle with different legacy versions, then someone actually posted me a working zip on FB!

Yes, I don't know what's going on there at the moment. But worth
following up on the JACK mailing list. As you say, there are
definitely working options around so I don't know why they're not
official downloads.

> If there is a community need to do a whip round and commission the production of an awesome general purpose Java IO then I’d certainly chip in. I think a JNA interface to RTAudio or PortAudio, like Neil has done with Jack, would be killer. The user installs the required libraries via a package manager, and Java finds them in standard system locations. Seems like a better strategy than trying to package and link libraries in jars or something horrible like that.

I've looked at building some audio server implementations using
PortAudio and JNA in the past, but the stumbling block IMO is the lack
of official binary downloads. RTAudio might be harder with JNA - not
sure if it exports a C API. Mapping C++ with JNA, or JNI, is more
awkward. Incidentally, both already have Java bindings and don't seem
to have got much traction.

I disagree with you on the package manager approach. There's not just
the problem that consumer OS's are moving away from this approach to
the self-contained application. JAR files are actually pretty good
for this - look at how JNA and lots of other native mappings do
automatic extraction and loading of native libraries from JARs. IIRC
JNA actually includes a library to do this for any additional
libraries.

The other option might be to map audio API's directly as AudioServers
using JNA - this might actually be better as it doesn't require
additional native libs at all.

Emily Meuer

unread,
Nov 18, 2016, 12:00:35 AM11/18/16
to jaudi...@googlegroups.com
Hi,

Thank you both!

I'm on a Mac; I didn't get much response on the JACK mailing list, but might try it again now that I've narrowed things down a little.  

More below:

On Thu, Nov 17, 2016 at 5:08 AM 'Neil C Smith' via JAudioLibs <jaudi...@googlegroups.com> wrote:
Hi,

On 16 November 2016 at 23:02, Oliver Bown <ol...@icarus.nu> wrote:
> Yeah Java has never properly handled integration with devices and the only successful solution I’ve found is to work with Jack.

Or use Linux!  Both JavaSound and JACK work pretty well here.  Unless
you need a particular bit of commercial software I'd never use a
consumer OS for building performance or interactive tools.

Didn't even think of Linux!  Will definitely give this a shot. 

> Currently on a Mac Jack is a really random mixed bag and is in quite a state of disarray in its development. I found myself having to fiddle with different legacy versions, then someone actually posted me a working zip on FB!

Yes, I don't know what's going on there at the moment.  But worth
following up on the JACK mailing list.  As you say, there are
definitely working options around so I don't know why they're not
official downloads.

> If there is a community need to do a whip round and commission the production of an awesome general purpose Java IO then I’d certainly chip in. I think a JNA interface to RTAudio or PortAudio, like Neil has done with Jack, would be killer. The user installs the required libraries via a package manager, and Java finds them in standard system locations. Seems like a better strategy than trying to package and link libraries in jars or something horrible like that.

I've looked at building some audio server implementations using
PortAudio and JNA in the past, but the stumbling block IMO is the lack
of official binary downloads.  RTAudio might be harder with JNA - not
sure if it exports a C API.  Mapping C++ with JNA, or JNI, is more
awkward.  Incidentally, both already have Java bindings and don't seem
to have got much traction.

Hmm... Didn't realize that these Java bindings existed.  Will check that out.
 
I disagree with you on the package manager approach.  There's not just
the problem that consumer OS's are moving away from this approach to
the self-contained application.  JAR files are actually pretty good
for this - look at how JNA and lots of other native mappings do
automatic extraction and loading of native libraries from JARs.  IIRC
JNA actually includes a library to do this for any additional
libraries.

The other option might be to map audio API's directly as AudioServers
using JNA - this might actually be better as it doesn't require
additional native libs at all.

This sounds fascinating, but I don't really know how I would go about it.  Any pointers?

Thanks again!
 - Emily

 
Best wishes,

Neil

--
Neil C Smith
Artist & Technologist
www.neilcsmith.net

Praxis LIVE - hybrid visual IDE for creative coding - www.praxislive.org

Neil C Smith

unread,
Nov 21, 2016, 5:31:23 AM11/21/16
to jaudi...@googlegroups.com
Hi,

On 18 November 2016 at 05:00, Emily Meuer <emily...@gmail.com> wrote:
>> The other option might be to map audio API's directly as AudioServers
>> using JNA - this might actually be better as it doesn't require
>> additional native libs at all.
>>
> This sounds fascinating, but I don't really know how I would go about it.
> Any pointers?
>

Well, first step if you don't know it is learn JNA :-)

Try and find a basic C example for doing playback as you want. You
want to create a JNA interface that mirrors the required native calls.
One option is to run JNAearator over the header files - this is how
the JACK bindings were initially done, although have been manually
updated since.

You then need to implement the JAudioLibs AudioServer interface.

https://github.com/jaudiolibs/audioservers/blob/master/audioservers-api/src/main/java/org/jaudiolibs/audioservers/AudioServer.java

The JACK implementation for reference is here

https://github.com/jaudiolibs/audioservers/blob/master/audioservers-jack/src/main/java/org/jaudiolibs/audioservers/jack/JackAudioServer.java

This old blog post may be useful too -
https://praxisintermedia.wordpress.com/2013/11/06/jaudiolibs-audioservers-a-portaudio-esque-java-api/

Neil C Smith

unread,
Dec 5, 2016, 5:41:00 AM12/5/16
to jaudi...@googlegroups.com
On 17 November 2016 at 11:08, Neil C Smith
<neilcsm...@googlemail.com> wrote:
> I've looked at building some audio server implementations using
> PortAudio and JNA in the past, but the stumbling block IMO is the lack
> of official binary downloads.

OK, not official, but this is interesting if it lasts -

https://github.com/spatialaudio/portaudio-binaries

Emily Meuer

unread,
Feb 11, 2017, 4:12:37 AM2/11/17
to jaudi...@googlegroups.com
Thank you for all your help!  Someone else is taking over this question for me, so you may hear from her in the future, but this much has been immensely helpful, and I appreciate it.
 - Emily M.


Reply all
Reply to author
Forward
0 new messages