需要有关声音处理的帮助
如何从立体声文件(.mp3)获取样本数据并将它们推入缓冲区? 有没有特定的库具有该功能? 抱歉,如果这个问题真的很菜鸟,我对音频编程很陌生。
预先感谢 =)
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 =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“通过直接 Android API 播放 MP3 文件的唯一方法是 MediaPlayer,它重量级、速度慢并且仅提供高级 API。如果您需要混合或修改音频流或以低延迟管理它们,那么您可以”
(通过:http://mindtherobot.com/blog/624/android-audio-play-an-mp3-file-on-an-audiotrack/ )
所以这是不幸的。 JLayer 是免费的,用 Java 编写,因此您可以使用它:
http://www.javazoom.net /javalayer/javalayer.html
它是否足够快取决于您想要进行多少分析,以及手机中的处理器类型以及正在运行的其他应用程序。所有平常的事情。
如果您有 CPU 密集型任务,您可以编写本机代码并使用 C/C++ 库,这将使您有更好的机会进行实时分析:
http://developer.android.com/sdk/ndk/overview.html
一些 ARM 处理器具有矢量指令等,如果可用,您可以利用它们,这可以提高速度:
http://www.arm.com/products/processors/technologies/neon.php
如果您所做的事情不能是纯实时的,您可能会考虑进行全部或部分预处理。然后缓存分析信息,这样用户只需第一次等待...或者让他们选择让您的应用程序过夜分析所有文件或类似的事情。
"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.