Discussion:
How to record voice using Java Sound in ALAW format
(too old to reply)
Udipta
2004-07-22 09:57:05 UTC
Permalink
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.
Roedy Green
2004-07-22 14:27:46 UTC
Permalink
Post by Udipta
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.
Knute Johnson
2004-07-22 15:43:04 UTC
Permalink
Post by Udipta
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.
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/
Loading...