Steven Pongidin
Steven Pongidin

Reputation: 153

Need help about sound processing

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 =)

Upvotes: 2

Views: 1482

Answers (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.

Upvotes: 1

Related Questions