Felix PK
Felix PK

Reputation: 154

Read current audio output - Android

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.

Upvotes: 2

Views: 2703

Answers (1)

Mikhail Naganov
Mikhail Naganov

Reputation: 6861

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.

Upvotes: 1

Related Questions