NatCorder Tutorial: Audio Workflows
Hi all! In this tutorial, I will be discussing NatCorder’s audio API and different workflows for working with audio when recording video. First, I will go over NatCorder’s audio API, then I will discuss how to use it for recording game audio.
The Audio API
NatCorder offers a very simple API for recording PCM audio with video. There are two things that NatCorder will need from you:
- A description of the audio. NatCorder needs to know some things ahead of time. How many audio channels are there, and how often will you be providing samples (sample rate)?
- Actual audio! As you record, you will need to provide NatCorder the actual audio to be recorded as an array of single-precision floating point PCM samples (a.k.a,
To provide this information, the client (you) is expected to use an
AudioFormat. Let’s look at the definition:
Recording Unity Audio
Unity provides access to PCM audio samples through the
This is incredibly convenient for use with NatCorder. What this means is that when we want to record audio from the scene (using an
AudioListener ) or from a particular game object (using an
AudioSource), we simply need to attach the script to the source/listener and in
OnAudioFilterRead , call
There is one last step. When we actually start recording, we need to provide NatCorder with an
AudioFormat so that it knows what audio data to expect during recording, if any. To do this, we can construct an
AudioFormat and pass it in to
And that’s it! Just make sure to destroy the
AudioRecorder when you stop recording. In the next tutorial, I will go over advanced recording using the
NatCorder API. Till next time!
— Lanre Olokoba.