<Sound Dev> [9] Review Request: 8152501 closed/javax/sound/sampled/FileWriter/WaveBigEndian.java failing

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Tue Mar 29 11:33:53 UTC 2016

Please review the fix for jdk9.

  After the jigsaw integration the closed test WaveBigEndian fails. The 
reason is that the order of service providers is not specified in the 
jigsaw(I guess it will be changed in the future).
The test verify that the audio data(pcm signed) during conversion is not 
changed corrupted. The java sound has two codecs which can convert pcm 
signed: PCMtoPCMCodec(base on int) and AudioFloatConverter(based on 
float). It was found that the test fails when AudioFloatConverter is 
used. This is because PCMtoPCMCodec converts data of 
pcm_signed/pcm_unsigned directly, and AudioFloatConverter converts data 
to the intermediate floats[-1.0; 1.0] and then converts it to the target 

Example of formulas are used by AudioFloatConverter.
  - Signed byte to/from float: byte / 127.0f <--> byte * 127. Has a 
problem with a minimum byte "-128". it is outside of "(float) -1"
  - Signed byte to/from unsigned: byte + 127 <--> byte - 127. Converts 
"-128" to "-1" instead of zero, and 127 to "254" instead of 255.

Similar issues exists for 16 bits/32bits.
The code was change to:
  - Signed byte to/from float: byte > 0 ? byte / 127.0f : byte / 128.0f
  - Signed byte to/from unsigned: byte + 128 <--> byte - 128.

Note that for 32 bits only the second step is changed, 
division/multiplication error is quite tiny in this case.

Also note that PCMtoPCMCodec can be removed after this fix, I'll do that 
later if the performance of two codecs is similar. I guess other 
conversions(LSB, 24 bit, 32+) in AudioFloatConverter should be 
investigated also, I'll do that later.

Bug: https://bugs.openjdk.java.net/browse/JDK-8152501
Webrev can be found at: http://cr.openjdk.java.net/~serb/8152501/webrev.00

Best regards, Sergey.

More information about the sound-dev mailing list