LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
livekit::AudioFrame Class Reference

Represents a raw PCM audio frame with interleaved int16 samples. More...

#include <audio_frame.h>

Public Member Functions

 AudioFrame (std::vector< std::int16_t > data, int sample_rate, int num_channels, int samples_per_channel)
 Construct an AudioFrame from raw PCM samples.
 
const std::vector< std::int16_t > & data () const noexcept
 
std::vector< std::int16_t > & data () noexcept
 
std::size_t totalSamples () const noexcept
 Number of samples in the buffer (per all channels).
 
int sampleRate () const noexcept
 Sample rate in Hz.
 
int numChannels () const noexcept
 Number of channels.
 
int samplesPerChannel () const noexcept
 Samples per channel.
 
double duration () const noexcept
 Duration in seconds (samplesPerChannel / sampleRate).
 
std::string toString () const
 A human-readable description.
 

Static Public Member Functions

static AudioFrame create (int sample_rate, int num_channels, int samples_per_channel)
 Create a new zero-initialized AudioFrame instance.
 
static AudioFrame fromOwnedInfo (const proto::OwnedAudioFrameBuffer &owned)
 Construct an AudioFrame by copying data out of an OwnedAudioFrameBuffer.
 

Protected Member Functions

proto::AudioFrameBufferInfo toProto () const
 

Friends

class AudioSource
 

Detailed Description

Represents a raw PCM audio frame with interleaved int16 samples.

AudioFrame holds decoded audio data along with metadata such as sample rate, number of channels, and samples per channel. It is used for capturing and processing audio in the LiveKit SDK.

Constructor & Destructor Documentation

◆ AudioFrame()

livekit::AudioFrame::AudioFrame ( std::vector< std::int16_t >  data,
int  sample_rate,
int  num_channels,
int  samples_per_channel 
)

Construct an AudioFrame from raw PCM samples.

Parameters
dataInterleaved PCM samples (int16).
sample_rateSample rate (Hz).
num_channelsNumber of channels.
samples_per_channelNumber of samples per channel.
Exceptions
std::invalid_argumentif the data size is inconsistent with num_channels * samples_per_channel.

The documentation for this class was generated from the following file: