cyndilib.audio_frame#

AudioFrame#

class cyndilib.audio_frame.AudioFrame#

Bases: object

Base class for audio frames

reference_converter#

Converter to match the input (for AudioSendFrame) or output (for AudioRecvFrame and AudioFrameSync) data to what the NDI library expects. The desired AudioReference level can be set using the reference_level property.

Type:

AudioReferenceConverter, read-only

channel_stride#

The number of bytes in the data pointer between channels

Typically calculated as num_samples * sizeof(float32_t)

get_timecode_posix(self)#

Get the current timecode converted to float seconds (posix)

get_timestamp_posix(self)#

Get the current timestamp converted to float seconds (posix)

num_channels#

Number of audio channels

num_samples#

Number of samples available for read or write

reference_level#

The current AudioReference of the reference_converter

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#

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() and fill_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 the get_read_data() method.

fill_all_read_data(self, dest: float32_t[:,_:], timestamps: int64_t[:])#

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 least read_length.

The timestamps array should be of at least read_length size

Returns a tuple of

  • nbfrs: The number of buffer items filled

  • col_idx: The index of the last column (last axis) filled on the result

fill_read_data(self, dest: float32_t[:,_:])#

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)

Returns a tuple of

  • data: The sample data

  • timestamps: An array of timestamps for each

    column in data

get_buffer_depth(self) int#

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

get_read_length(self) int#
get_read_shape(self) (size_t,_size_t)_#

Get the read array shape as (num_channels, num_samples)

read_length#

The total number of samples in the read buffer (not multiplied by num_channels)

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 to framesync.FrameSync.capture_audio() or framesync.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#

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

attached_to_sender#

True if the frame has been added to a Sender

destroy(self)#
get_write_available(self)#
set_max_num_samples(self, n: int)#

Set the max_num_samples, altering the shape expected for data writes

Note

This method may only be called before calling sender.Sender.set_audio_frame()

shape#

The expected shape for data being written to the frame as a tuple of (num_channels, num_samples)

write_data(self, data: float32_t[:,_:])#

Write audio data to the internal buffer

The buffered data will then be sent on the next call to sender.Sender.send_audio()

Parameters:

data – A 2-d array or memoryview of 32-bit floats with shape (num_channels, num_samples)

Note

This method is available for flexibility, but using sender.Sender.write_audio() may be more desirable as the audio data will be buffered and sent immediately