How can I get a SourceDataLine or TargetDataLine in μ-law format?
TargetDataLines are supposed to act as a “direct” way to communicate with the audio hardware device, i.e. your soundcard. When your soundcard does not support μ-law directly, the TargetDataLine won’t either. The way to go is to open a TargetDataLine in pcm format and route it through a format converter. See doc of AudioSystem to get converted Streams. The converted stream you get provides μ-law samples then. There is no drawback in this approach: all PC soundcards that I know of deliver only PCM, so it has to be rendered to μ-law anyway in software. Whether in the soundcard’s driver, the operating system layer or in the application (your java program) doesn’t matter. You get maximum portability when only using pcm for TargetDataLines.