I want to know if it is possible to access the audio that is currently playing on the Android device.
Example: if Spotify is running in the background, I want to access the audio to control some LEDs that are connected to my RaspberryPi.
I want to create some sort of equalizer that changes colors depending on the sound that is currently playing. I appreciate if some one could tell me if accessing the main audio output is possible or not.
Unless you are using a rooted phone, it's not possible to capture output of a random app on Android.
You can however create an app that plays media files and captures the output for the purpose of visualization with "Visualizer" effect. You can take a look on the sample here: https://android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/media/AudioFxDemo.java
(look for "Visualizer").
If you are using Raspberry Pi anyway, you can just play all your music through it, capture and analyze it there. You will need an external USB sound card though. See for example this post: http://www.g7smy.co.uk/2013/08/recording-sound-on-the-raspberry-pi/
There they just record and play audio back, but you can insert an analysis phase in between.
Related
I am creating a chat application where the user can send audio and video files.
For my video files I have successfully created an embedded video player in my app which will play any video.
But for my audio files I don't want to use an embedded video player with options vout=dummy instead I want to be optimized and use an DirectAudioPlayer for my purposes. I took a look at the MediaFactory create but i don't understand how am I suppose to retrieve these parameters for an specific file.
What I want is just one direct audio player in my application which I can reuse for multiple audio files or is this not possible?
You can use a HeadlessMediaPlayer.
This is basically the same as the EmbeddedMediaPlayer that you're already using, but with no API to do with displaying the video.
A word of caution though if you play a video through the HeadlessMediaPlayer, rather than just an audio file, LibVLC will open a native window and play the video - you can suppress this by passing "--no-video" via the MediaPlayerFactory.
The DirectAudioPlayer is used when you want to access the audio buffer in your application - i.e. "direct" access to the native audio buffer. You would then have to use JavaSound or something to actually play the audio. So I don't think this is what you want.
I am currently trying to implement android voice recognition for a research project that I am currently working on. I was able to follow a guide and I am able to correctly receive input but I want the phone to continuously look for input instead of telling me to try again after a while. I want to use it to control a moving robot connected to the phone meaning that I won't be able to physically touch the screen. Right now I made it so that if speech is recognized and converted then it immediately calls promptSpeechInput() again but I can't seem to find a way to do that when it runs out of time.
I am busy with a movie/video-clip player/library.
I want to do this in JavafX. Almost 90% of the video clips is in AVI format. I cannot for several reasons covert the movies/video-clips.
I also want the program to mark the video files that were played, from start to complete, so that I will know what have been watched. So the program needs to be able to interact with the video player to know when the video has played to the end.
JavafX doesn't allow playback for AVI files. What's the alternative to be able to use this with? And how will I know if the video has fully played from beginning to end.
I read the following
Adding other video codecs / DVD support to JavaFX 2.2
Where they suggest I use portable VLC player. Is this the best way to use it in JavafX and if possible does the API have register hooks to register a method that can be triggered to know when the video has stopped?
I've read somewhere that it isn't still possible to record Audio while using the Camera function on Android phones. But this source was kind of outdated.
I've also read, that this is possible on Iphone.
But I need this function for Android to create an App.
Can anybody say more to that?
Is there a possibility on Android to archive that in an Application?
I don't see why not. They don't share the same hardware. Even if not, you could easily fake it by recording video (which also records sound) and just taking the first still image of the video as your photo.
I would like to build an Android App to take audio data from two microphones, mix the sound with some from memory, and play the sound through headphones. This needs to be done in real-time. Could you please refer me to some tutorials or any references, for real-time audio input, mixing, and output with Java eclipse?
So far, I am able to record sound, save it, and then play it, but I cannot find any tutorials for real-time interfacing with sound-hardware this way.
Note: One microphone is connected to the 3.5 mm headphone jack of the Android through a splitter and the other is connected through a USB port.
Thanks!
There are two issues that I see here:
1) Audio input via USB.
Audio input can be done using android 3.2+ and libusb but it is not easy (You will need to get the USB descriptors from libusb, parse them yourself and send the right control transfers to the device etc). You can get input latency via USB in the order of 5-10 mS with some phones.
2) Audio out in real-time.
This is a perennial problem in Android and you are pretty much limited to the Galaxy Nexus at the moment if you want to approach real-time (using Native Audio output). However, if you master the USB you may be able to output with less latency as well.
I suppose if you go to the trouble of getting the USB to work, you can get a USB audio device with stereo in. If you had connected one mono mic to each of the input channels, then output via USB you would be very close to your stated goal. You might like to try "USB Audio Tester" or "usbEffects" apps to see what is currently possible.
In terms of coding the mixing and output etc, you will probably want one thread reading each separate input source and writing to a queue in small chunks (100-1000 samples at a time). Then have a separate thread reading off the queue(s) and mixing, placing the output onto another queue and finally a thread (possibly in native code if not doing output via USB) to read the mixed queue and do output.
The following Link http://code.google.com/p/loopmixer/ has a flavor for dealing with the audio itself.