jdxi_editor.audio.audio_buffer

A preallocated stereo ring.

The capture callback is the only writer. The analysis worker is the only reader. Neither side allocates, and the reader copies out so a later write cannot change a buffer the worker is still using.

Classes

SampleRing

The most recent stereo frames, overwriting the oldest.

Module Contents

class jdxi_editor.audio.audio_buffer.SampleRing(capacity: int)[source]

The most recent stereo frames, overwriting the oldest.

capacity is the number of frames kept. Writes larger than that keep only the tail; capture blocks are far smaller, so the callback never takes that path.

capacity[source]
buffer[source]
_write = 0[source]
written() → int[source]

Frames accepted since the ring was created.

Returns:

int

write(frames: numpy.ndarray) → None[source]

Copy frames in. Shape (n,) or (n, 1) is written to both channels. Shape (n, 2) is stereo.

Parameters:

frames – np.ndarray samples

Returns:

None

latest(count: int) → numpy.ndarray[source]

A copy of the newest count frames, shape (n, 2).

Parameters:

count – int frames wanted

Returns:

np.ndarray