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

AudioInputStream.getFrameLength() returns wrong value for floating-point WAV

XMLWordPrintable

    • b110
    • x86_64
    • windows_7

      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 :
      For WAV files containing floating-point audio data, AudioInputStream.getFrameLength() returns the number of bytes instead of the number of 32-bit sample frames.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test program below with a WAV file containing floating-point audio data.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      AudioInputStream.getFrameLength() should return the number of sample frames, as it does for WAV files containing integer PCM data.
      ACTUAL -
      AudioInputStream.getFrameLength() returns the number of bytes, when the WAV file contains floating-point audio data.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class TestWavFloatBug1 {

      public static void main(String[] args) throws Exception {
         String inputFileName = args[0];
         AudioInputStream stream = AudioSystem.getAudioInputStream(new File(inputFileName));
         System.out.println(stream.getFrameLength());
         }

      }

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

            serb Sergey Bylokhov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: