cyndilib.audio_frame
#
AudioFrame#
- class cyndilib.audio_frame.AudioFrame(*args, **kwargs)#
Bases:
object
Base class for audio frames
- channel_stride#
The number of bytes in the data pointer between channels
Typically calculated as
num_samples * sizeof(float32_t)
- num_channels#
Number of audio channels
- num_samples#
Number of samples available for read or write
- sample_rate#
The current sample rate
- timecode#
The frame’s current ndi-timestamp
- timestamp#
The per-frame ndi-timestamp
AudioRecvFrame#
- class cyndilib.audio_frame.AudioRecvFrame(size_t max_buffers=8, *args, **kwargs)#
Bases:
AudioFrame
Audio frame to be used with a
receiver.Receiver
- Parameters:
max_buffers (int, optional) – The maximum number of items to store in the buffer. Defaults to
8
Incoming data from the receiver is placed into temporary buffers so it can be read without possibly losing frames. Each buffer will be of shape (
num_channels
num_samples
).The buffer items retain both the data frames and their corresponding timestamps. They can be read using the methods
get_read_data()
,get_all_read_data()
,fill_read_data()
andfill_all_read_data()
.This object also implements the buffer protocol meaning it can be used anywhere a
memoryview
is expeted. When used this way, the view will contain the same information as theget_read_data()
method.- fill_all_read_data(self, float32_t[:, :] dest, int64_t[:] timestamps)#
Copy all available read data into the given dest array and the item timestamps into the given timestamps array.
The shape of the dest array on the first axis should equal
num_channels
and the second should be at leastread_length
.The timestamps array should be of at least
read_length
sizeReturns a tuple of
nbfrs
: The number of buffer items filledcol_idx
: The index of the last column (last axis) filled on the result
- fill_read_data(self, float32_t[:, :] dest)#
Copy the first available read item in the buffer into the given array
The array must equal that of
get_read_shape()
Returns the timestamp of the data
- get_all_read_data(self)#
Get all available data in the read buffer as a 2-d array
The shape of the result will be (
num_channels
,read_length
)
- get_buffer_depth(self) size_t #
The current number of frames available in the read buffer
- get_frame_timestamps(self) list[int] #
Get a list of the frame timestamps in the read buffer
- get_read_data(self)#
Get the first available item in the read buffer
Returns a tuple of
frame_data
: A 2-d array of float32 with shape ofget_read_shape()
timestamp
: The timestamp of the data
- get_read_length(self) size_t #
- get_read_shape(self)#
Get the read array shape as
(num_channels, num_samples)
- read_length#
int The total number of samples in the read buffer
(not multiplied by
num_channels
)- Type:
AudioRecvFrame.read_length
AudioFrameSync#
- class cyndilib.audio_frame.AudioFrameSync#
Bases:
AudioFrame
Audio frame for use with
framesync.FrameSync
Unlike
AudioRecvFrame
, this object does not store or buffer any data. It will always contain the most recent audio data after a call toframesync.FrameSync.capture_audio()
orframesync.FrameSync.capture_available_audio()
.This is by design since the FrameSync methods utilize buffering from within the NDI® library.
Data can be read using the
get_array()
method or by using the buffer protocol.- get_array(self)#
Get the current data as a
ndarray
of float32 with shape (num_channels
,num_samples
)
AudioSendFrame#
- class cyndilib.audio_frame.AudioSendFrame(size_t max_num_samples=1602, *args, **kwargs)#
Bases:
AudioFrame
Audio frame for use with
sender.Sender
Note
Instances of this class are not intended to be created directly nor are its methods. They are instead called from the
sender.Sender
write methods.- max_num_samples#
The maximum
num_samples
to be used.- Type:
int, readonly
- destroy(self)#
- get_write_available(self)#
- set_max_num_samples(self, size_t n)#
- write_data(self, float32_t[:, :] data)#