Hi all! Today, I’m pretty excited to introduce a new API that solves a problem that the Unity ecosystem has struggled with for years now. For some background, I developed the NatCorder video recording API for Unity Engine and one thing that a lot of developers have had need for is a reliable way to record the user’s voice with gameplay. We have always pointed them to the
Microphone API provided by Unity, but they’ve expressed their frustration with its shortcomings.
Microphone API often lags and stutters. This has become a huge problem for us, because it means that developers who want to do something as simple as recording replays with voice-overs have no way of doing so. We finally decided to fix it ourselves by building a native microphone API from the ground up.
Say Hello to NatMic API
NatMic is a minimal cross-platform microphone API for realtime recording. NatMic 1.0 will have native support for iOS, Android, macOS, and Windows. The API is built on a simple paradigm: There are
IAudioDevice instances which provide clean abstractions for hardware- and software-based audio input devices. These
IAudioDevice instances can be told to start and stop recording:
Once recording is started, the
IAudioProcessor instance is provided with sample buffers from the microphone. Each sample buffer contains audio samples recorded by the microphone over short intervals of time:
NatMic comes with
IAudioRecorders which are lightweight classes for recording audio data to a persistent format, like audio files. We expect this to be one of the more common use cases of NatMic, so NatMic 1.0 will feature a
WAVRecorder for recording Waveform audio files.
Here is an example demonstrating recording the microphone to a WAV file:
What the Future Holds
In later releases, we expect to add support for spectral analysis of the audio data (specifically, the Fast Fourier Transform). We are also looking into adding support for VoIP applications, so that you can make your own Skype ;). Finally, we are considering adding support for WebGL and Windows RT. Till then, happy recording!
— Lanre Olokoba.