You can record audio from the device's microphone using the
RecorderNode audio graph sink node.
You can instantiate an
RecorderNode with the following parameters:
name: You have to provide a unique name for each recorder node you wish to use, for a temporary file.
recordingSampleRate: Sample rate of the recording.
numberOfRecordedChannels: The number of the desired recording channels.
You also have to enable microphone access in the audio engine for the recording to work.
let recorderNode = SBRecorderNode(
let audioEngine = SBAudioEngine()
audioEngine.microphoneEnabled = true
val recorderNode = RecorderNode(
name = "UniqueNameForRecorder",
recordingSampleRate = 44100,
numberOfRecordedChannels = 1
val audioEngine = AudioEngine()
For controlling the recording, you have the following functions:
start(): Starts recording.
stop(filePath: String, Codec): Stops the recording and saves the recorded audio to a specified path with the Codec given.
Listening to the Recording
You can input the
filePath in the
stop function to an
AudioPlayerNode to listen to your recorded audio. See how to do it here