NatMic - Native Microphone API


Get NatMic on the Asset Store.

Hi all! I’m very happy to introduce an API that the Unity ecosystem has needed for years. If you’ve ever tried to record audio with Unity’s Microphone class, you have likely run into unfixable bugs, like stuttering and unbearable latency. Now, we have created an API from scratch so that you don’t have to face these issues any longer.

NatMic is a lightweight cross-platform microphone API for Unity. NatMic has support for iOS, Android, macOS, and Windows.

NatMic Features include:

  • Realtime low-latency recording, with microphone data being provided in a dedicated thread.
  • Configurable microphone sample rate and channel count.
  • Recorders. NatMic comes with a WAV recorder and AudioClip recorder.
  • Cross platform support for iOS, Android, macOS, Windows.

__

Check Out a More Detailed Introduction Here.

2 Likes

Yes! It will make NatCam complete. You can separate it into a new product. I bet there are many people that are willing to pay for this. If you google “Unity Read Mic data”, you will see many posts with no solution. Unity’s Mic API is extremely slow.

I do not own NatCam yet but the videos you made about them are awesome. What I need is a fast camera + audio API so that that I can read them and send them over network.

What this can be used for:

Online Game Voice Chat
WebCam Apps
Video(Front Camera) and Audio live calls
Waveform Visualization
Record Audio from the System Sound(Not just sound playing from Unity).
Record phone call

I see that the Asset store is full of Voice Chat plugins but those are crappy. Only looking for low access API to read from the Mic hardware.

NatMic API Structure:

  • API to read Mic data as byte array.
  • API to play the read data byte array.
  • API that reads the Mic and returns the data in a way that be used to construct a waveform.

The idea is to allocate memory once and re-use them. Usually the read function does not return an array but fills an array that is passed in then returns how many bytes there were filled in. This prevents memory allocation.

What I plan to do:

Read audio bytes with NatMic, send to network with TCP/UDP. Server. On my TCP/UDP client, read bytes from server then use NatMic to play received data. I will use other network protocol on WebGL. Hopefully that makes sense. It would be good if NatMic can be used in another Thread as this will improve performance over-all.

I plan to buy NatCam but since there is no audio plugin yet, I am worried that trying to implement my own audio plugin will conflict with NatCam on Android since I need to extend UnityPlayer. I will wait to see if NatMic will become a thing. Hopefully, it will.

If you have question, please don’t hesitate to ask.

We would make it separate from NatCam, but completely compatible.

Interesting. I will look into this.

Only the microphone input will be supported. Unity’s sounds will not at all be recorded.

This will be done using Unity’s Audio API’s.

We’ll take care of optimizations. No worries here.

Playback will be done with Unity API’s.

NatCam does not extend UnityPlayer, so you are completely safe here.

1 Like

What we have in mind for the API is this:

  • Record audio data for file saving (record to waveform directly from native layer)
  • Record audio data for streaming (audio data will be sent to Unity and then propagated through a callback)
  • A Waveform class handy for visual animations

Abstractions will be made for the purposes above to make the process much easier for developers.

That’s nice.

Yes, That sums it up. Recording for file saving is also useful. It will be good if you keep me updated in this.

Sure will. I hope other devs also express interest in this. So far there are 3 developers on board (including you and me).

One of the projects I’m working on is an online multiplayer VR game for PC that will need voice chat over Unity native multiplayer networking (UNet). If this NatMic would have a plugin that would that would easily integrate with UNet and instantly give me voice chat, then hell yes I would be all over this. I have no clue how to integrate voice chat for a PC VR game.

For my game I would be getting to the networking part in probably two months.

I’ll be taking a look at the UNet API; I haven’t had to use it before.

I am still doing a feasibility study for this plugin. I’m eager to see what we conclude.

I really don’t care about UNet. Only care about reading and writing Mic data as fast as possible. Since UNet support has been requested, it looks like it will help many others who don’t know how to use TCP/UDP with another Thread.

One thing to know is that if you decide to support Unet is that there is LLAPI and HLAPI, use the Low level (transport layer) API. LLAPI deals with byte arrays and that makes it very fast. Although nothing beats direct TCP/UDP protocol in terms of performance so I won’t be using LLAPI for this unless for WebGL.

Going off what the majority of developers need, not you alone.

Thanks for the tip!

Just chiming in again to say that if you did include voice chat support, you would be one of the only working voice chat plugins on the unity asset store which would make your plugin pretty popular.

I’m looking now for a plugin and all the ones I find, the reviews either say doesn’t work in unity 5, not UNet compatible, or reviews saying it doesn’t work period.

Not necessarily. Exclusivity is not equal to prominence. We are still waiting and watching to see if there is a large-enough volume of developers that would want such a plugin.

Any update on if you are doing this and what it might entail?

Thanks.

Due to the amount of work we have to do, we have decided not to develop the project at this time. This might change, but not anytime soon.

hello,
any progress on this?
looking for mic input waveform visualisation…
thx
M.

We decided not to move forward with the project.

Hi all. It’s almost a year after my last post. We’ve restarted the NatMic project since it has become a huge roadblock in our progress with some of our projects. We needed a reliable microphone API, and since there are no good options, we have decided to create one ourselves.

I will edit my first post at the top of this thread, and publish an article describing what we have planned. But to keep you without the suspense, NatMic 1.0 will natively support iOS, Android, Windows, and macOS (all have already been implemented). In the next release, we will add support for WebGL and possibly WinRT. NatMic 1.0 will also support mixing microphone audio with game audio (from an AudioSource or AudioListener). The API will be really simple, consisting of one callback that is provided with PCM audio data. Finally, NatMic will come with Recorders, which when given this audio data, will create an audio file. NatMic 1.0 will come with one recorder for recording waveform (WAV) files. In subsequent releases, we’ll be looking at adding recorders for M4A, OGG, and MP3.

Sorry it’s taken over a year to get this done!

Hi @ , do you have an ETA on when NatMic will be coming out?

Not yet. We are working on getting the iOS implementation finalized. Once we do this, we’ll be offering free beta access for a few weeks before releasing it.

NatMic is now in open beta.

If you would like to test the API, say so here or PM me your email address so I can share the build with you.

1 Like