mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

Example for using miniaudio in Unity 3D on Android #598

Closed ludzeller closed 1 year ago

ludzeller commented 1 year ago

Hi,

I am thinking about using miniaudio to capture audio from the microphone of Meta Quest headsets from a native library for a Unity project.

Is there a similar example somewhere, maybe for Android in general?

How are the permissions to be handled?

Is low latency possible in that context?

mackron commented 1 year ago

I have no experience at all with using miniaudio with Unity so I won't be able to help you there.

I've not tested miniaudio with any kind of headset so not sure how that would work. What audio backends do they typically use? If they coincidentally use any of the backends that miniaudio already supports I'd be happy to make some tweaks to make it work cleanly if it doesn't already. I would need to help and advice from the community for testing though because I don't have the hardware to test with.

The general process for capturing should be the same everywhere. You can check the simple_capture example to get an idea on what's going on. In terms of latency, it's all up to the backend, but miniaudio supports the ability to give the backend a hint as to what the latency should be (periodSizeInMilliseconds/Frames in the device config).

Out of curiosity, is there any reason in particular you don't want to use Unity directly for this? I would think that would already support capturing and would also have explicit support for headsets.

Sorry I can't be of more help.

(Moving this to the discussion section.)