How to split wav file for 1 second with Java?

I had a question earlier: Reading a wav file in Java

First of all, I want to read a wav file from Java and get its bytes for processing into an array.

Secondly, I will remove his silence (this is another topic of the question).

After that, I will split this wav file for 1 second (I have to handle the header problem for these small wav files, this is one of the main problems)

I tried to read a wav file with Java with this API, the answer to my previous question. However, with this API, I have to do something for the header, or the API does it myself, and how can I split this wav file for 1 second with Java. Another API or something else is fine for me too.

+4
source share
1 answer

The API you are referring to will return a double[] array containing data samples from the original WAV file. All you have to do is create a bunch of smaller arrays (every second) and copy from the corresponding position in the original array to each of the smaller arrays (so that all the original data is copied to smaller ones). Then, just use your API writing methods to create real WAV files from each smaller array.

Using this API means you don’t have to worry about the headers yourself (which is good because they are easy to write, but very difficult to read, potentially).

The size of each smaller array depends on the size of the original. If the original WAV file is monophonic with a sampling frequency of 44.1 kHz, then the 1-second array will contain 44,100 elements.

+2
source

All Articles