Skip to content

sadda.live

Live audio recording with streaming pitch / formants / intensity / meter subscribers. PROVISIONAL tier — may change in minor versions after a deprecation cycle.

See the quickstart for a worked example. Design rationale lives in the 2026-05-22 DEVLOG entry "Live recording (E1)".

start_session builtin

start_session(project, *, device=Ellipsis, sample_rate=44100, channels=1, name=None, analysis_window_ms=30.0, analysis_hop_ms=10.0, num_formants=4, min_pitch_hz=75.0, max_pitch_hz=500.0)

Constructs a new live-recording session. device is a device name from [list_input_devices] or "default". The cpal stream is not built here — call session.start() to actually begin capture.

list_input_devices builtin

list_input_devices()

Returns the names of available cpal input devices on the default host. Names may not be unique across hosts; for stable identifiers across reboots, hold onto the string returned by [default_input_device] and pass it back to [start_session].

default_input_device builtin

default_input_device()

Returns the default input device's name, or None if there isn't one.

LiveSession

Live recording session. Construct via [start_session]; register callbacks via on_meter / on_pitch / on_intensity / on_formants; then start()stop()commit() or discard().

frames_written property

frames_written

Number of samples (post-downmix mono frames) written to disk.

dropped_samples property

dropped_samples

Number of samples dropped due to consumer back-pressure. Non-zero means the recording is imperfect.

duration_seconds property

duration_seconds

Duration of the recording in seconds. 0.0 while still capturing.

in_progress_dir property

in_progress_dir

Path to the .in_progress/<uuid>/ directory as a string.

start method descriptor

start()

Begins capture. Builds the cpal input stream against the requested device and starts the audio thread. Idempotent: a second call returns Ok without rebuilding the stream.

stop method descriptor

stop()

Stops the capture, joins the cpal-stream and dispatch threads, and flushes the WAV writer. After stop() the session waits for commit() or discard(). Idempotent.

commit method descriptor

commit(project)

Atomically commits the recording into the parent project. Returns the new bundle id. Errors if the session has not been stopped, or if a bundle named name already exists.

discard method descriptor

discard()

Discards the in-progress recording (deletes the directory). Errors if the session has not been stopped.

on_meter method descriptor

on_meter(callback)

Registers a callable invoked once per drained chunk with (peak, rms, rms_db, time_seconds). Returns the callable unchanged so the method can be used as a decorator.

on_pitch method descriptor

on_pitch(callback)

Registers a callable invoked once per analysis hop with (frequency_hz, voiced: bool, time_seconds). voiced is voicing >= 0.45 (Boersma's recommended threshold).

on_intensity method descriptor

on_intensity(callback)

Registers a callable invoked once per analysis hop with (db_fs, time_seconds).

on_formants method descriptor

on_formants(callback)

Registers a callable invoked once per analysis hop with (frequencies: list[float], bandwidths: list[float], time_seconds). Both lists are co-indexed and the same length (which varies per frame).