By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,778 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,778 IT Pros & Developers. It's quick & easy.

How to record voice using Java Sound in ALAW format

P: n/a
I am making a java application where I am required to record voice in
a-law format. The program i have written starts perfectly without
giving any error or warning, but as soon as i start recording an
exception is thrown.

java.lang.IllegalArgumentException: No line matching interface
TargetDataLine supporting format ALAW, 8000.0 Hz, 16 bit, mono,
little-endian, audio data is supported.

The AudioFormat object is created using the following code:

public static final AudioFormat DEFAULT_AUDIO_FORMAT = new
AudioFormat(AudioFormat.Encoding.ALAW,8000,16,1,2, 8000,true);

I want to know whether voice can be recorded in ALAW format on
computer using Java Sound Api. And if so what has to be done or from
where I could get some help. Please let me know ASAP.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 22 Jul 2004 02:57:05 -0700, ud****@rediffmail.com (Udipta) wrote or
quoted :

public static final AudioFormat DEFAULT_AUDIO_FORMAT = new
AudioFormat(AudioFormat.Encoding.ALAW,8000,16,1,2 ,8000,true);


you need to dump out the list of supported formats and pick from one
of them.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Jul 17 '05 #2

P: n/a
Udipta wrote:
I am making a java application where I am required to record voice in
a-law format. The program i have written starts perfectly without
giving any error or warning, but as soon as i start recording an
exception is thrown.

java.lang.IllegalArgumentException: No line matching interface
TargetDataLine supporting format ALAW, 8000.0 Hz, 16 bit, mono,
little-endian, audio data is supported.

The AudioFormat object is created using the following code:

public static final AudioFormat DEFAULT_AUDIO_FORMAT = new
AudioFormat(AudioFormat.Encoding.ALAW,8000,16,1,2, 8000,true);

I want to know whether voice can be recorded in ALAW format on
computer using Java Sound Api. And if so what has to be done or from
where I could get some help. Please let me know ASAP.


I believe that A-Law and uLaw are 8 bit formats.

Try creating a line in 8 bit PCM and then convert it to A-Law before you
write it to disk.

--

Knute Johnson
email s/nospam/knute/
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.