I want to create simple equalizer for android. How can I do it?
Try to find some methods in MediaPlayer class. But all my attempts failed.
Android has built-in qualizer engine, though it isn't located in MediaPlayer class, becouse it's a class itself located in android.media.audioFx package.
http://developer.android.com/reference/android/media/audiofx/Equalizer.html
Simple answer... you can't do it with the framework or with Java (because there is no JMF support in Android). You have to use the NDK and JNI to compile a native library with equalizer support. If you know C/C++ there are plenty of libraries around that will provide this functionality but if you don't know C/C++ or have the means to pay someone that does I would recommend you move on to something else within your means... There are even some working examples for Android, if you look around, that use libmpg123... but libmpg123 only provides an equalizer interface for mp3's. I found that it's pretty buggy in general and compromised the stability of the app in such a way that it would lock up android and I would have to pull the battery to reboot the phone. In addition, there was alot of audio clipping even with the equalizer flatlined. That is my experience...
I hope that below link is useful for you.
https://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/AudioFxDemo.html
Related
I'm writing a small call recording library for my rooted phone.
I saw in some application that recording is done through ALSA or CAF on rooted phones.
I couldn't find any example / tutorial on how to use ALSA or CAF for call recording (or even for audio recording for that matter).
I saw tinyAlsa lib project, but I couldn't figure how to use it in an android app.
Can someone please show me some tutorial or code example on how to integrate ALSA or CAF in an Android application?
Update
I managed to wrap tinyAlsa with JNI calls. However, calls like mixer_open(0) returns null pointers, and calls like pcm_open(...) returns a pointer but subsequent call to is_pcm_ready(pcm) always returns false.
Am I doing something wrong? Am I missing something?
Here's how to build ALSA lib using the Android's toolchain.
and here you can find another repo mentioning ALSA for android
I suggest you to read this post on order to understand what are your choices and the current platform situation.
EDIT after comments:
I think that you need to implement your solution with tinyalsa assuming by you are using the base ALSA implementation. If the tiny version is missing something then you may need to ask the author (but it sounds strange to me, because you are doing basic operations).
After reading this post, we can get some clues about why root is needed (accessing protected mount points).
Keep us updated with your progress, it's an interesting topic!
I want to integrate libspotify as sound/player service and integrate spotify in more then one java applications.
Can anyone suggest me any lib or any code example to get me started?
Disclaimer: I work for Spotify
At the moment, Spotify doesn't have a nice Java wrapper for libspotify, but this is definitely something we are thinking about doing in the future. I can't offer an estimate on when this will be available, so if you are dying to get started writing apps which integrate with Spotify, you should use the natively-compiled libspotify for Android rather than waiting for a Java wrapper.
The current preferred way of doing Android work with libspotify is to use the natively-compiled library which can be found on the libspotify website. You'll have to write your own JNI wrappers around it, which can be a bit tricky, but is definitely not an impossible task. :) Unfortunately the documentation for using libspotify under Android is a bit lacking. Again, this is something that Spotify is working to improve.
There is a third-party project called jlibspotify which offers a Java wrapper around libspotify. I personally have not used it before, so I can't comment on how good the project is, but if I recall correctly it is based on an older version of libspotify, so you might be better off going the JNI route detailed above.
I noticed that there is also libjahspotify out there, which seems newer than jlibspotify. I haven't tried it though.
I'm looking for a way to use an equalizer within my app which does not rely on the
android.media.audiofx package especially android.media.audiofx. Equalizer class because these are only available for api level > 9.
Does anybody know about native libraries which work well under android? I've found mpg123 but it seems that this library is very slow. Or is there even another way to implement an equalizer without native librarys?
I did quite a bit of research on this and found that you would have to likely rewrite the entire AudioTrack library in order to accomplish this.
It would require heavy DSP which would be best accomplished using the NDK, if you really want to do it.
Otherwise, I would just write a wrapper that tells the application which API level you're in, and disable those features.
Here is the abstract I wrote on this problem:
http://isthisonthetest.com/?q=node/12
Hope this helps!
EDIT:
This link has been getting a few hits (and the link was broken), so I redirected it to a blog post I just made with the original text. The URL above should work now.
Is there anyway I could write 100% native C code for Android? I know there are ways to write some C code inside Java code, but I don't know any Java and I hate Java anyway.
Is there anyway I could write pure C code that will run under Android?
There is, as of Android 2.3: NativeActivity. But you don't get access to any of the niceties of Android's Java libraries; you're on your own in the wild west. This is really intended for people writing high-performance games.
Yes, there is support for writing completely native activities. You can check out the native-activity sample application.
I would not recommend this path, though, as in my experience applications that are heavy in NDK code are very difficult to debug. I would rate the Android native debugging experience as lacking.
Edit - one caveat is that you will still be doing plently of Java--just through the JNI.
Might be more trouble than it's worth, you could possibly write your logic in C code and import that to java using extern or external (I forget which now) and then do the GUI in java. There's really no point to using straight C in android unless you want to REALLY optimized your logic. Most of the calls you can make are wrapped anyways so you would have to make those calls to access certain things on an android device. Long story short : not a good idea unless you need faster logic.
You can write most of the application in C around a NativeActivity. However, some Android features can only be used from Java, so you'll need to use JNI instead of pure native. See the official overview.
I want to use the codecs in Android from my application. For now I just want to use the H.264 codec for testing, unless the mp3 or aac codecs provide functions for sending the audio to the device's speaker in which case I would prefer one of those.
I have the NDK installed along with Cygwin, GNU Make, and GNU Awk. I can't figure out what I need to do from here though. I'm downloading the entire OpenCORE tree right now but I don't even know how to build it or make Eclipse plugin know it needs to include the files.
An example or a tutorial would be much appreciated.
EDIT:
It looks like I can use JNI like P/Invoke which would mean I don't have to build the OpenCORE libraries myself. However, I can't find any documentation on the names of the libraries I need to load.
I'm also confused as to how to do it. I'm looking at http://www.koushikdutta.com/2009/01/jni-in-android-and-foreword-of-why-jni.html and I don't understand what the purpose of writing a library to access a library is. Couldn't you just use something like System.loadLibrary("opencore.so")?
You cannot build opencore seperately. It has to be built with whole source code. What are you trying to acheive. If you just want to play a video/audio, use VideoView or MediaPlayer object.
Build the Android source and use the headers and the static library from it. This will propel you straight to the zone of unsupported APIs.