PvRecorder
Node.js API
API Reference for the Node.js PvRecorder SDK (npmjs).
PvRecorder
Class for the PvRecorder.
PvRecorder can be initialized using the class constructor()
.
Resources should be cleaned when you are done using the release()
method.
PvRecorder.constructor()
constructor
method for PvRecorder
.
Parameters
frameLength
number : Length of the audio frames to receive per read call.deviceIndex
number : The audio device index to use to record audio. A value of (-1) will use machine's default audio device.bufferedFramesCount
number : The number of audio frames buffered internally for reading - i.e. internal circular buffer will be of sizeframeLength
*bufferedFramesCount
. If this value is too low, buffer overflows could occur and audio frames could be dropped. A higher value will increase memory usage.
Returns
PvRecorder
: An instance of PvRecorder.
Throws
Error
: If an error occurs while initializing PvRecorder.
PvRecorder.start()
Starts recording and buffering audio frames.
Throws
Error
: If an error occurs while starting audio device.
PvRecorder.stop()
Stops recording audio.
Throws
Error
: If an error occurs while stopping audio device.
PvRecorder.read()
Asynchronous call to read a frame of audio data.
Returns
Promise<Int16Array>
: An audio frame with sizeframeLength
.
Throws
Error
: If an error occurs while reading audio frame.
PvRecorder.readSync()
Synchronous call to read a frame of audio data.
Returns
Int16Array
: An audio frame with sizeframeLength
.
Throws
Error
: If an error occurs while reading audio frame.
PvRecorder.setDebugLogging()
Enables or disables debug logging for PvRecorder
. Debug logs will indicate when there are overflows in the internal
frame buffer and when an audio source is generating frames of silence.
PvRecorder.getSelectedDevice()
Returns the name of the selected device used to capture audio.
Returns
string
: The name of the selected audio device.
PvRecorder.release()
Releases resources acquired by PvRecorder
.
PvRecorder.frameLength
Length of the audio frames to receive per read call.
PvRecorder.sampleRate
Audio sample rate used by PvRecorder
.
PvRecorder.version
Version of the PvRecorder
.
PvRecorder.isRecording
Whether PvRecorder
is currently recording audio or not.
PvRecorder.getAvailableDevices()
Gets the list of available audio devices.
Returns
string[]
: An array of the available device names.
Throws
Error
: If an error occurs while getting available audio devices.