Converting audio files to different encodings, sample size, channels, sample rate

Purpose. Converts audio files, changing the sample rate of the audio data.

Usage. 

java AudioConverter -h

java AudioConverter -l

java AudioConverter [ -c channels ] [ -s sample_size ] [ -e encoding ] [ -f sample_rate ] [ -t file_type ] [[ -B ] | [ -L ]] [ -D ] sourcefile targetfile

Parameters. 

-h

prints usage information

-l

lists available file types

channels

the number of channels to convert to, for instance 1 for mono or 2 for stereo

sample_size

the sample size in bits to convert to, for instance 8 for 8 bit samples

encoding

the encoding name to convert to, for instance PCM_SIGNED, ULAW or VORBIS

sample_rate

the sample rate to convert to, for instance 44100 or 8000. Fractional values are allowed, for instance 8192.76

file_type

the file type to write the target file, for instance WAVE or AU.

sourcefile

the file name of the audio file that should be read to get the source audio data

targetfile

the file name of the audio file that the converted audio data should be written to

Bugs, limitations. Sample rate conversion can only be handled natively by Tritonus. If you want to do sample rate conversion with the Sun jdk1.3/1.4/1.5, you have to install Tritonus' sample rate converter. Converting number of channels and sample size is only partly supported by the Sun JDK. To get more options, install Tritonus's PCM2PCM converter. Both are part of the 'Tritonus miscellaneous' plug-in. See Tritonus Plug-ins.

Source code.  AudioConverter.java, AudioCommon.java, gnu.getopt.Getopt