1

I am trying to record audio in Java using my RaspBerry Pi 3 and Raspbian Jessie. My app works on my Mac both with internal and external USB micro. On the Raspberry Pi, with whatever format I use, I always get:

javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian not supported.

javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 8000.0 Hz, 8 bit, mono, 1 bytes/frame,  not supported.

...

Any idea what the problem may be?

Edited: 8000Hz and 16 bits (a combination I hadn't tried) throws no exception, but I need 16000Hz/16 bits for my app. The problem is rephrased to ask how to record at that rate with Java in my Raspberry. Thanks.

Second edit: I am using Kinobo USB mic. I just noticed that the problem maybe that as if I try to record using the native arecord command I get:

pi@raspberrypi:~ $ arecord -r 16000 -f S16_LE output2.wav -d 5
Recording WAVE 'output2.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
Warning: rate is not accurate (requested = 16000Hz, got = 11025Hz)
         please, try the plug plugin (-Dplug:default)

With -Dplug plugin suggested I get it to work, but with a extremely low signal level and a lot of noise. May be the problem is that Java cannot record more than 11025 with this Mic?

1
  • Throwing the USB mic into the mix complicates matters. There's no documentation for any of the Kinobo mics on their site and they'll be acting as their own sound card. As such, there's no way to tell what they'll support unless you have some documentation that might shed some light on things.
    – goobering
    Apr 6 '16 at 13:00
1

See this discussion on the raspberrypi.org forums. I think your issue is likely to be that the Pi doesn't support the big-endian audio format that Java is attempting to record. I'm stabbing in the dark a little here without more code to look at, but I think the relevant section from that discussion is xranby's comment:

When you create the AudioInputStream you need to use the constructor that takes an AudioFormat. You pass false to the big endian argument of the AudioFormat constructor.

1
  • Hello, I think the problem is with the sampling rate. I have configured 8000 as sampling rate and now I get no exception, so the problem is probably not big-endian. My big problem now is that I need this for an audio streaming solution and the voice recognition software that receives that stream requires 16000 sampling rate minimum, so I need to find a way for Raspberry Java to accept that 16000 value.
    – icordoba
    Apr 6 '16 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.