PvRecorder
Go API
API Reference for the PvRecorder Go SDK (pkg.go.dev).
pvrecorder.Version
The version string of the PvRecorder
library.
pvrecorder.SampleRate
The audio sample rate used by PvRecorder
.
pvrecorder.PvRecorder
Struct for the PvRecorder
pvrecorder.PvRecorder.FrameLength
Length of each frame returned from read command.
pvrecorder.PvRecorder.DeviceIndex
Index of the audio device to use for recording.
pvrecorder.PvRecorder.BufferedFramesCount
Number of audio frames buffered internally for reading - i.e. internal circular buffer
will be of size FrameLength
* BufferedFramesCount
.
If this value is too low, buffer overflows could occur and audio frames could be dropped.
A higher value will increase memory usage.
pvrecorder.PvRecorder.Init()
Init function for PvRecorder
. Must be called before trying to record audio.
Returns
error
: Error produced by thePvRecorder
.nil
if no error was encountered.
pvrecorder.PvRecorder.Delete()
Releases resources acquired by PvRecorder
.
pvrecorder.PvRecorder.Start()
Starts recording and buffering audio frames.
Returns
error
: Error produced while trying to start recording.nil
if no error was encountered.
pvrecorder.PvRecorder.Stop()
Stops recording audio.
Returns
error
: Error produced while trying to stop recording.nil
if no error was encountered.
pvrecorder.PvRecorder.Read()
Reads a frame of audio.
Returns
[]int16
: An audio frame with sizeFrameLength
.error
: Error produced while trying to read audio frame.nil
if no error was encountered.
pvrecorder.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.
Parameters
isDebugLoggingEnabled
bool : Boolean indicating whether the debug logging is enabled or disabled.
pvrecorder.PvRecorder.IsRecording()
Whether the recorder is currently recording audio or not.
Returns
bool
: Boolean value indication if the instance is recording.
pvrecorder.PvRecorder.GetSelectedDevice()
Current selected audio input device name
Returns
string
: The name of the audio device the instance is currently using.
pvrecorder.NewPvRecorder()
Creates a PvRecorder
struct with default parameters.
Parameters
frameLength
int : The length of audio frame to get for each read call.
Returns
PvRecorder
: An instance ofPvRecorder
struct.
pvrecorder.GetAvailableDevices()
Gets the currently available input audio devices.
Returns
[]string
: A list of strings, indicating the names of audio devices.error
: Error produced while trying to get available audio devices.nil
if no error was encountered.