Need help about sound processing

浪子不回头ぞ 提交于 2019-12-11 01:51:29

问题


How to get the sample data from stereo sound file (.mp3) and push them into the buffer? Is there any specific library with that function? Sorry if the question is really noob, I'm very new to audio programming.

Thanks in advance =)


回答1:


"The only way you can play an MP3 file via direct Android API is MediaPlayer which is heavyweight, slow and presents only high-level API. If you need to mix or modify audio streams or manage them with low latency, you are on your own."

(Via: http://mindtherobot.com/blog/624/android-audio-play-an-mp3-file-on-an-audiotrack/ )

So that is unfortunate. JLayer is free and written in Java, so you can use that:

http://www.javazoom.net/javalayer/javalayer.html

Whether it's going to be fast enough depends on how much analysis you want to do, and what kind of processor is in the phone, what other apps are running. All the usual things.

You can write native code and use C/C++ libraries if you have something CPU intensive, which will give you a better chance at doing real-time analysis:

http://developer.android.com/sdk/ndk/overview.html

Some ARM processors have vector instructions and the like you could exploit if they're available, which can give a speed boost:

http://www.arm.com/products/processors/technologies/neon.php

If what you're doing can't be pure real-time, you might consider doing full or partial pre-processing. Then cache the analysis info so the user only has to wait the first time...or give them the option to let your app analyze all the files overnight or somesuch.



来源:https://stackoverflow.com/questions/7833335/need-help-about-sound-processing

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