Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Recording audio files in PCM_FLOAT format

966377Oct 5 2012 — edited Oct 12 2012
Hello!

I'm trying to record voice sample and I've got a problem with my .wav format. With:
AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100.0F, 16, 1, 2, 44100.0F, false);
everything works fine. But what I need (because of further analysis of this audio file in Matlab) is PCM_FLOAT format:
AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_FLOAT, 8000.0F, 32, 1, 4, 8000.0F, true);
which unfortunately returns an error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
 No line matching interface TargetDataLine supporting format PCM_FLOAT 8000.0 Hz, 32 bit, mono, 4 bytes/frame,  is supported.
I've tried a lot of different combinations with PCM_FLOAT but every one of them returns same exception. I'm probably missing something but the question is: what? How can I find what audio formats could work with my sound card? If I can only use PCM_SIGNED or UNSIGNED how can I convert recorded .wav file to PCMFLOAT?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 9 2012
Added on Oct 5 2012
3 comments
1,784 views