USB multichannel recording with Java Sound API?

I am trying to record / process some sound from three USB microphones using Java Sound on Snow Leopard (but can switch to Windows if it fixes everything). The problem is that when I try to use a mixer that matches the usb microphone, Java Sound tells me that the line is not supported. In particular, this speaks of this ...

Available faucets:

Java Sound Audio Engine

USBMIC Serial # 041270067

Built-in built-in microphone input

Soundflower (2ch)

Soundflower (16ch)

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: String is not supported: interface TargetDataLine support format PCM_SIGNED 96000.0 Hz, 8 bits, stereo, 2 bytes / frame,

... when I ask to choose a USBMIC mixer:

Mixer mixer = AudioSystem. getMixer(mixerInfo[1]); 

I tried to match the audio format with the exact characteristics of the microphones (16 bit, 44100 Hz, stereo), and it did not matter.

The problem arises here:

  final TargetDataLine line = (TargetDataLine) mixer.getLine(info); 

It would seem that the mixer and TargetDataLine do not like each other. Is there a way to make these two play and get along?

The microphones that I use are admittedly a bit weird. They were made for use in a karaoke video game called SingStar. The microphones themselves have standard mono-linear connectors that connect to a small hub (from two to a hub) that converts them into one male USB connector. Strange aside, however, they seem to work fine with Audacity as separate channels, so multi-channel recording with them is clearly possible, maybe not in Java.

I also considered using a program such as Soundflower, which shares sound between different programs. However, I am not sure if this will work, as I cannot figure out how to make the USB microphone inputs in Soundflower, and then connect them to Java. A quick experiment showed me that I can record audio in Audacity from microphones, stream it through Soundflower, and then process it in my Java program. However, I would like all this to happen in real time in Java.

Is anyone familiar with this problem?

+44
java record usb javasound microphone
Nov 21 '10 at 19:06
source share
3 answers

I think an easy way to do this is to use Soundflower and Soundflowerbed.

I don’t see how to make USB microphone inputs in Soundflower, and then connect them to Java.

Sounds like you already have Soundflower installed. Soundflowerbed is located on the same disk image as Soundflowerbed and is a text application. It allows you to route sound between applications that do not have built-in controls for selecting audio devices. Install it from the disk image and click on it to start.

All of the following will use my Echo Audiofire 4, but in principle should work on any sound device.

Using Soundflowerbed

Open Soundflower and check the audio device you want to use in Soundflower (16ch). Since I am a new user, I cannot post images, but they are linked below. If I get a reward, I will edit the message to include the images in a row.

one

Here you should use Soundflower (16ch) as an audio input device in Java sound.

Create an aggregate audio device

An alternative way to solve this, if that does not work, is to create an aggregate device. Go to Applications> Utilities> Midi Audio Settings and click the plus sign to create a new aggregate device.

2 Check the device you want to combine. You only need your USBMIC (since I'm a new SO user, I can only send two images for each answer, so the next two are related here).

3

The key part that can cause problems is the watch on the device. If you choose a Mac as the sync source, it may be more stable. four

If this still does not work, you can try adding Mac built-in sound to the aggregate device and make it the main clock by right-clicking on the device you want to become the master.

5

Other options

Finally, I have not used this before, but Pulse Audio (Google, I can’t insert more links in this post) may be a possible solution for mixing your audio streams. However, he looks rather heavyweight.

+4
Oct. 15 '11 at 20:35
source share

According to my research, especially topics such as this , the microphone you use is most likely causing the problem. The thread says that the microphone is even a problem when it comes to switching games, so I assume it will be a problem when switching platforms.

My suggestion - if you haven't tried it yet - is to use a different microphone! Most of the microphones I've come across have special chip controllers that convert data into data compatible for the gaming system. Since you use this in the operating system for the computer, you are likely to get some very strange effects that you could not get in a gaming system such as Playstation or others.

Hope this helps! Happy coding!

+2
Oct. 15 2018-11-11T00:
source share

AudioFormat does not match the format supported by TargetDataLine. I don’t know if it was a typo or not, but the exception was that TargetDataLine supports 8-bit sound and right below what you said you were using 16-bit AudioFormat. It also supports up to 2 bytes per frame, how fast and in what sizes are you trying to read data? Sorry if this does not help, but I thought I would point it out if this is missed.

0
Apr 17 '13 at 12:53 on
source share



All Articles