How to calculate FrameLength without using AudioSystem?

匆匆过客 提交于 2020-01-16 18:03:30

问题


I'm porting Java project to Android.

As you know, the Android does not have javax.sound package.

I need to calculate frameLength.

My sound file size is 283KB. And frame size is 4 and frame rate is 44100 and sample size in bits is 16.

The frame length was 69632 when I used just pure Java.

Do you know any equation to get this?

Thank you.


回答1:


For the raw PCM data, basically, you have 4 bytes per sample.

((283 KB) * (1024 bytes per KB)) / (4 bytes per frame) ==> 72448

But a wav can include a lot besides the raw PCM, e.g., song title or artist info.

Here's some more info about wav format. You might have to load the file as raw bytes to parse the header, but the header has the frame size in a predictable location.

Maybe someone else with Android experience has already concocted a method. Maybe Google should treat Java as an intact entity and properly license and implement it.



来源:https://stackoverflow.com/questions/7124709/how-to-calculate-framelength-without-using-audiosystem

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