Direct Monitoring for Mic to Speaker on Mobile

Greetings all :slight_smile:

We’re working on a Unity Mobile app that allows for the recording of music and vocal tracks. We have fought with latency issues with recording and developed a solution of how to deal with this i.e. adding a latency value to adjust the recorded audio with the original audio track.

However there is now also a requirement to have the option for what is called Direct Monitoring, that, when NOT recording, you can hear the input e.g. Mic, in real time, passing straight through to the device speaker / headphones. This is possible on some other mobile apps, but i am unsure of what tech stacks they use.

Is this possible in Unity with ZERO latency?

Once example for this might be to have visual feedback of the volume of the Mic.

All help much appreciated.

What you could do here is use the Microphone API, start a recording and compute the volume on the latest samples gathered. I think that’s the closest of zero latency you can get with Unity by itself.

Microphone.GetPosition will get you number of the next audio frame to be written, so you should be able to gather the last n frames and get an idea of the volume from their root-mean-square. Here’s a small exchange on that math.

Cheers!