How to divide a wav file into 1 second pieces with Java?

旧街凉风 提交于 2019-12-04 11:11:18

The API you reference will return a double[] array containing the sample data from the original WAV file. All you have to do then is create a bunch of smaller arrays (each one second long) and copy from the appropriate position in the original array into each of the smaller arrays (so that all the original data is copied into the smaller ones). Then just use the writing methods of your API to create actual WAV files from each smaller array.

Using that API means you shouldn't have to worry about the headers yourself (which is a good thing, because they're easy to write but very complicated to read, potentially).

The size of each smaller array is dependent upon the format of the original. If the original WAV file is mono with a 44.1 KHz sample rate, then a 1-second array would contain 44,100 elements.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!