Skip to main content

audio

1 reply [Last post]
javaandcoffee
Offline
Joined: 2007-12-13
Points: 0

Hi!
I want to run all au files but only the ones which have the proporties below are allowed:
ulaw,8000,8,signed,big endian,mono
How can i change this state?

I suppose, ok, I use this format then...But I can't convert any file to this format.

AudioFormat newFormat = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED, 8000 8,
1,2,8000
true);
AudioInputStream newStream = AudioSystem.getAudioInputStream(newFormat, audioInputStream);
audioFormat = newFormat;
audioInputStream = newStream;

AudioSystem.write(audioInputStream,AudioFileFormat.Type.AU, fout);

The error:
java.lang.IllegalArgumentException: Unsupported conversion: ULAW 8000.0 Hz, 8 bit, mono, 2 bytes/frame, from PCM_SIGNED 8000.0 Hz, 8 bit, mono, 1 bytes/frame,

at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:955)

How can i solve this problem?Thanks...

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sfitzjava
Offline
Joined: 2003-06-15
Points: 0

Wanted to make sure you had this posted in the right place. Are you working on a CDC device, or is this for a Desktop application? In either case what is the underlying OS and device, meaning Linux, Windows, Mac, and is it a desktop, or something like the SE P900?

If you are on a desktop system running linux or Mac you may need to reconfigure the port to accept other audio formats. This will be dependent on your audio driver (OSS, ALSA, ESD..). You might also check using the AudioSystem calls to getTargetLineInfo() to check for supported types, and there is also a method isConversionSupported() that might help identify if you can go from one format to another. (my assumptions, as I have not used this particular API set).

If you are on a mobile device then you need to find out what codecs they support on the device within the Java VM you are using. Just because the device supports MP3 or the like, does not mean that the codec is supported in the JVM. With the mobile device you are mostly fixed to what the JVM supports, unless you have something running Linux in which case you might be able to do the same trick as the desktop side by reconfiguring the audio port.

Best wishes,
-Shawn