Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Incorrect Playback of 24 bit Audio (data mismatch / unwanted processing)

960264Sep 6 2012 — edited Oct 6 2012
Hi all,

I'm trying to use Java to play audio files but I've noticed that it does not correctly play 24 bit files, in that the output data from the soundcard does not match the data input from the file. It works fine for 16 bit (and 8 bit) files - it's only 24 bit files where Java appears to do some extra (and unwanted) processing. I know it's Java that is the issue because if I use ASIO to play the file then the data does match as expected.

A bit more detail on the situation:
- I'm running the latest version of the Java JRE on Windows XP.
- The audio is played using an M-Audio soundcard, on the digital out (S/PDIF), which is then connected directly to a digital in on a Lynx soundcard (in the same PC), and recorded using Sony Sound Forge.
- The captured file is then compared with the input Wave file.

For the test, four input Wave files are used:
- 16 bit, 44.1 kHz
- 16 bit, 48 kHz
- 24 bit, 44.1 kHz
- 24 bit, 48 kHz

Using ASIO to play back the test files, all four of the files produce the correct output (the recorded data matches the input Wave file data byte for byte).

Using Java to play back the test files, the 16 bit ones (both 44.1 kHz and 48 kHz) produce the correct output, whereas the 24 bit ones (both sample rates) do not. Furthermore, the way in which the output is incorrect is inconsistent (I've run the test twice, and neither matched the input, nor even each other). So not only is Java playing the 24 bit files wrongly, it is doing it wrongly in a different way each time.

The easiest way to reproduce this issue is to use the player code [AudioPlayer on jsresouces.org|http://www.jsresources.org/examples/AudioPlayer.html] and try to play a 24 bit audio file, capturing the output from the soundcard (or re-routing it internally using the soundcard mixer). It's not wrong enough that you can hear it, but it does kind of defeat the purpose of hi-resolution audio if the data is being altered in some unexpected way.

So I guess my question is - how can I get Java to play back 24 bit audio correctly?

Thanks in advance for any help,

Alex

PS: A thorough search of the forum brings [this thread|https://forums.oracle.com/forums/thread.jspa?messageID=9361370] from over a year and a half ago which seems to be the same problem, but with no solution given ("use ASIO" isn't really a solution as it defeats the point of using Java - that it works cross-platform).
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 3 2012
Added on Sep 6 2012
5 comments
4,517 views