cyndilib.audio_frame#
AudioFrame#
- class cyndilib.audio_frame.AudioFrame#
Bases:
objectBase class for audio frames
- reference_converter#
Converter to match the input (for
AudioSendFrame) or output (forAudioRecvFrameandAudioFrameSync) data to what the NDI library expects. The desiredAudioReferencelevel can be set using thereference_levelproperty.- Type:
AudioReferenceConverter, read-only
- 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
- reference_level#
The current
AudioReferenceof thereference_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:
AudioFrameAudio 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_channelsnum_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
memoryviewis expeted. When used this way, the view will contain the same information as theget_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_channelsand the second should be at leastread_length.The timestamps array should be of at least
read_lengthsizeReturns 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, 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 datatimestamps: An array of timestamps for eachcolumn in
data
- 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_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:
AudioFrameAudio frame for use with
framesync.FrameSyncUnlike
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
ndarrayof float32 with shape (num_channels,num_samples)
AudioSendFrame#
- class cyndilib.audio_frame.AudioSendFrame#
Bases:
AudioFrameAudio frame for use with
sender.SenderNote
Instances of this class are not intended to be created directly nor are its methods. They are instead called from the
sender.Senderwrite methods.- max_num_samples#
The maximum
num_samplesto be used.- Type:
int, readonly
- destroy(self)#
- get_write_available(self)#
- set_max_num_samples(self, n: int)#
Set the
max_num_samples, altering theshapeexpected for data writesNote
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