0

Is it possible to get the audio output from an android system into Unity? So that I can get audio data running from other apps on the phone into the unity system for use.

I've tried searching, and the only thing I can find is about android visualizer, which would be fine, as I don't need to record the audio, just format it into a couple of floats.

However, I have no idea how to implement visualizer as a plugin for unity to use, nor if there is any other way to get audio. People say it is the only way to get audio from android speakers, but I cannot find any aid or help as how to implement it into unity (other than people writing "make a plugin").

If visualizer cannot be implemented into Unity, is there any other way (apart from recording with the microphone) to get audio data from system output. To clarify, I do not need to record audio, so it does not need to be high quality, I only need basic analysis from it so I can get volume and/or pitch.

  • The closest thing to this is the [`AudioSource.GetSpectrumData`](https://docs.unity3d.com/ScriptReference/AudioSource.GetSpectrumData.html) function but it looks like it works with Unity sound system only and not the system sound. I don't know but give that a try and see what happens. – Programmer Sep 27 '17 at 16:17
  • For system sound, see [this](https://stackoverflow.com/questions/37688002/sound-visualization-library-for-android) post. If you can get it to work on Android with any of those then you can make a Java plugin for Android you can invoke from Unity. – Programmer Sep 27 '17 at 16:18
  • `AudioSource.GetSpectrumData` does only work with specific AudioSources inside of Unity, as such, you have to load any audio into unity first. As for the link, it is precisely the part of "make a java plugin" which I am stuck on. – Luke Meppem Sep 28 '17 at 08:32
  • Saying you are just stuck on it is not helpful. You have to post your Java and C# code and tell us where exactly you are stuck. Please Google *"How to call C# function from Java in Unity"* and *"how to call Java function from C# in Unity"*. There are many information out there. Before you event do this you should just build simple Android app to make sure it works before converting it into a plugin. You will probably need to ask a new question with these information – Programmer Sep 28 '17 at 08:45

0 Answers0