Recording Audio
You can record audio from the device's microphone using the RecorderNode
audio graph sink node.
Instantiating
You can instantiate an RecorderNode
with the following parameters:
sampleRate
: Sample rate of the recording.numberOfChannels
: The number of the desired recording channels.
note
You also have to enable microphone access in the audio engine for the recording to work.
- JSON
- Swift
- Kotlin
- C++
- JavaScript
{
"nodes": {
{ "id": "recorderNode", "type": "RecorderNode" }
},
"connections": {
{ "sourceNode": "inputNode", "destinationNode": "recorderNode" }
},
"tracks": {
"recorderNode": "recording.mp3"
}
}
import SwitchboardSDK
let recorderNode = SBRecorderNode(
sampleRate: 44100,
numberOfChannels: 1
)
let audioEngine = SBAudioEngine()
audioEngine.microphoneEnabled = true
import com.synervoz.switchboard.sdk.AudioEngine
import com.synervoz.switchboard.sdk.audiographnodes.RecorderNode
val recorderNode = RecorderNode(
sampleRate = 44100,
numberOfChannels = 1
)
val audioEngine = AudioEngine(context)
audioEngine.enableMicrophone(true)
#include "RecorderNode.hpp"
RecorderNode recorderNode(44100, 1);
Coming soon...
Recording Functions
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