jdxi_editor.audio.audio_buffer ============================== .. py:module:: jdxi_editor.audio.audio_buffer .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: jdxi_editor.audio.audio_buffer.SampleRing Module Contents --------------- .. py:class:: SampleRing(capacity: int) 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. .. py:attribute:: capacity .. py:attribute:: buffer .. py:attribute:: _write :value: 0 .. py:method:: written() -> int Frames accepted since the ring was created. :return: int .. py:method:: write(frames: numpy.ndarray) -> None Copy ``frames`` in. Shape ``(n,)`` or ``(n, 1)`` is written to both channels. Shape ``(n, 2)`` is stereo. :param frames: np.ndarray samples :return: None .. py:method:: latest(count: int) -> numpy.ndarray A copy of the newest ``count`` frames, shape ``(n, 2)``. :param count: int frames wanted :return: np.ndarray