Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8038138

Writing a floating-point WAV file stores the wrong encoding type in the header

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_51"
      Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      When writing a WAV file with floating-point audio data, the incorrect encoding type for integer PCM data is written to the WAV file header.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The test program below can be used to copy a floating-point WAV file. The output file written by the program will have the wrong encoding. When the output file is opened with an audio editor, a corrupt audio signal is displayed, because the floating point audio data is interpreted as integer data.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import javax.sound.sampled.AudioFileFormat;
      import javax.sound.sampled.AudioInputStream;
      import javax.sound.sampled.AudioSystem;

      public class TestWavFloatBug2 {

      public static void main(String[] args) throws Exception {
         String inputFileName = args[0];
         String outputFileName = args[1];
         AudioInputStream stream = AudioSystem.getAudioInputStream(new File(inputFileName));
         AudioSystem.write(stream, AudioFileFormat.Type.WAVE, new File(outputFileName));
         }

      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                serb Sergey Bylokhov
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: