Extract amplitude array from a wav File using JAVA

后端 未结 2 557
[愿得一人]
[愿得一人] 2021-01-08 00:21

I am trying to extract amplitude array from an audio file(WAV file). I will be using this amplitude array to plot amplitude vs time graph for the given wav file. I am able t

2条回答
  •  再見小時候
    2021-01-08 00:45

    I tried your code and with a few minor changes it created a result. Whats wrong with the data the code puts out?

    I Changed the following lines:

    // create file input stream
          DataInputStream fis = new DataInputStream(new FileInputStream(wavFile));
          // create byte array from file
          arrFile = new byte[(int) wavFile.length()];
          fis.readFully(arrFile); // make sure you always read the full file, you did not check its return value, so you might be missing some data
    

    The second thing I changed was:

    System.out.println(Arrays.toString(s.extractAmplitudeFromFile(f)));
    

    In your Main method, since you were only printing out the adress of the arary. After those changes the code put out an array that had values, that seemed to correlate with the desired data.

    what excatly are you missing, or what do you expect of the data? Could you please clarify the question a bit more?

提交回复
热议问题