Get audio as float[] from mixer group? (like OnAudioFilterRead?)


I’m making a music-based game and I need to stream audio from one client to all the other clients. I
need the audio as a float buffer so that I can stream it using Photon Voice.

I believe that using OnAudioFilterRead() on an audio source will let me get the audio from that one audio source, and using it on an audio listener will allow me to get the whole mix. But I do not want the whole mix, as there are other sounds like voice chat etc and I only want to stream the musical clips.

Is there a similar function I can use for just one mixer group instead?


Any luck with this one?

For those opening this page more recently, I’ll say everything I know about it:

The native code which runs on the mixer group is not on the same thread as the C# scripts. So as far as I know there’s nothing you can do in C# to get audio from a mixer group without also adding a native unity audio plugin to the mix.

You can get around this by creating a native C++ library for your platform which routes audio from the mixer group back into unity. You can find the audio SDK in the unity docs here:

This demo package includes code for routing audio from a mixer group back into unity. It doesn’t run natively on all platforms and needs to be custom compiled based on your platform… for instance Android. I do know that it’s possible to build for android, but I’ve heard it’s challenging.