Cabbage Logo
Back to Cabbage Site

Record synchronized Audio with Unity from Microphone?

The Microphone API in Unity allows to record audio, but I cannot get the exact timestamp of the recorded Audio.
I am building a music app where you can record to a playback, where this is essential! The latency is not much of a problem as long as I knew the exact timestamp of the recorded audio.
So, I need the exact AudioSettings.dspTime when the recorded clip started.
Can fmod / csound do this?

Hi @klauskobald, welcome to the forum!
Csound has several ways to record buffers, have a look here:

You can implement one of those techniques using CsoundUnity.
There is already a sample that gathers the microphone input and sends the samples to Csound for further processing:

You could start there!

Thank you.
Before I dig into that: can you confirm it will work with Android and iOS ?
I am a single developer and can not make studies :smirk:.
I already spent 2 days implementing the Unity Microphone thing, which does work now, but I am not happy with the uncertainty of latency.

Yes Csound works on Android and iOS.
The current version of CsoundUnity supports Android 64bit only, but if needed we could build and add the 32 bit version.
It also builds fine for iOS, but I haven’t tried it on a device yet (I have no iOS dev account), the Csound iOS library has been added recently to CsoundUnity, but there are plenty of iOS apps based on Csound.
Btw I will offer support if you run into any issue!