質問

I'm trying to build an app that uses a digital filter to process audio playing from other (stock music player and spotify etc) apps.

So far I've been able to create the filter for audio input from the mic in OpenSL ES. The filtered audio is then sent to the hardware output. The app was based on this toutorial http://audioprograming.wordpress.com/2012/03/03/android-audio-streaming-with-opensl-es-and-the-ndk/

How do I get a similar input buffer from other apps so that I can process it before its sent to the hardware output?

Its not a requirement to use OpenSL ES or other native code. To clarify; the app should apply the custom filter effect in a similar way as android.media.audiofx.AudioEffect before it was deprecated could be attached to the global audio output mix (audio session 0).

役に立ちましたか?

解決

An app can't modify (or even read, if you discount the Visualizer API) the audio output from other apps.

Just a note about audio session 0: it's still possible to use it (as of JB / JB MR1), but that possibility might go away in future Android versions. There's one important detail to keep in mind though, which is that effects added on session 0 will be suspended if an app adds an effect on a session other than 0.

The audio HAL keeps track of the (estimated) CPU usage for all enabled audio effects and will deny new effects to be enabled if doing so would cause the CPU cycle budget to be exceeded. This means that if apps were allowed to freely stack up effects on session 0 without being suspended, they could mess up apps like Spotify by denying them the ability to choose which effects to enable on their own audio session because the CPU cycle budget has been exceeded.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top