Skip to content

Python API — Streams, Blocks & Plan Reports

Covers session planning (CaptureRequest.inspect()), real-time safe streaming (ManagedStream, AudioStream), zero-copy PEP 3118 PcmBlock buffers, and mixer diagnostics.


Immutable session specification supporting side-effect-free .inspect(), permission preflights, and .open().

Property Type
allow_reroute bool
backends Backends
budgets AggregateManagerBudgets
combine_mode CombineMode
input_conversion InputConversionPolicy
mixer_config MixerConfig
on_format_change OnFormatChange
output_converter OutputConverter | None
permission_policy PermissionPolicy
targets list[CaptureTarget]
timing TimingRequirement
tree_strategy ProcessTreeRange
def check_permissions() -> PermissionReport
def inspect() -> CapturePlanReport
def inspect_for_os(os: PlatformOs | str) -> CapturePlanReport
def open(overflow: Overflow | str=..., timing: TimingRequirement | str | None=None) -> ManagedStream
def request_permissions(timeout_ms: SupportsIndex=30000, open_settings_if_denied: bool=False) -> PermissionReport
async def request_permissions_async(timeout_ms: SupportsIndex=30000, open_settings_if_denied: bool=False) -> PermissionReport
def with_permission_policy(policy: PermissionPolicy | str) -> CaptureRequest

Primary multi-target/pass-through session supporting with / async with, read, 0-alloc read_into, read_async, callbacks, and live update_targets hot-swap.

Property Type
active_reader_count int
callback_invocations int
is_software_mix bool
last_callback_error str | None
last_cleanup_error str | None
output_format Format | None
plan CapturePlanReport | None
segment_id int
selected_backend BackendId
session_id int
targets list[CaptureTarget]
working_format Format | None
async def __aenter__() -> ManagedStream
def __aiter__() -> ManagedStream
def __enter__() -> ManagedStream
def __iter__() -> ManagedStream
def input_handles() -> list[InputStatusHandle]
def read(frames: SupportsIndex=480, timeout_ms: SupportsIndex=200, cancel: Cancellation | None=None) -> ReadOutcome
async def read_async(frames: SupportsIndex=480, timeout_ms: SupportsIndex=200, cancel: Cancellation | None=None) -> ReadOutcome
def read_into(destination: bytearray | memoryview | Any, frames: SupportsIndex, timeout_ms: SupportsIndex=200, cancel: Cancellation | None=None) -> ReadOutcome
def start_callback(callback: Any, frames: SupportsIndex=480, timeout_ms: SupportsIndex=50) -> None
def stop(mode: StopMode | str=...) -> None
def stop_callback() -> None
def update_targets(target: CaptureTarget | Sequence[CaptureTarget]) -> int
def wait_cleanup() -> bool

Lightweight single-session backend stream without discovery watchers, process-tree monitoring, or automatic device-follow.

Property Type
active_reader_count int
format Format
last_callback_error str | None
last_cleanup_error str | None
def __enter__() -> AudioStream
def __iter__() -> AudioStream
@staticmethod
def open(target: CaptureTarget, tree_strategy: ProcessTreeRange | ProcessTreeStrategy | str | None=None, backends: Backends | None=None, overflow: Overflow | str=..., timing: TimingRequirement | str=..., cleanup_timeout_ms: SupportsIndex=2000, permission_policy: PermissionPolicy | str | None=None, request_permissions: bool | None=None) -> AudioStream
def read(frames: SupportsIndex=480, timeout_ms: SupportsIndex=200, cancel: Cancellation | None=None) -> ReadOutcome
def read_into(destination: bytearray | memoryview | Any, frames: SupportsIndex, timeout_ms: SupportsIndex=200, cancel: Cancellation | None=None) -> ReadOutcome
def stop(mode: StopMode | str=...) -> None
def wait_cleanup() -> bool

Ref-counted zero-copy PCM buffer supporting PEP 3118 memoryview(block) and to_numpy(copy=False) even after stop().

Property Type
byte_len int
byte_order ByteOrder
channels int
data_ptr int
frames int
generation int
materialized_copies int
rate int
sample_format SampleType
segment int
sequence int
def __buffer__(flags: int, /) -> memoryview
def to_bytes() -> bytes
def to_numpy(copy: bool=False, unpack_i24: bool=False) -> Any

Result of read, read_into, or read_async carrying frames, blocks, reason, boundary_kind, and mixed_metadata.

Property Type
blocks list[PcmBlock]
boundary_kind BoundaryKind | None
copy_bytes int
copy_destinations int
failure FailureKind | None
frames int
mixed_metadata MixedBlockMetadata | None
reason PartialReason
segment int
session int

Explicit PCM stream format (rate, channels, sample_format, byte_order, speaker layout, bytes_per_frame).

class Format(rate: SupportsIndex=48000, channels: SupportsIndex=2, sample_format: SampleType | str=..., byte_order: ByteOrder | str=..., layout: SupportsGetItem[int, Channel | str] | None=None) -> Format
Property Type
byte_order ByteOrder
bytes_per_frame int
channels int
layout list[Channel] | None
rate int
sample_format SampleType

Side-effect-free execution plan detailing combine_resolution, target_plans, stream count, and PCM byte budget.

Property Type
allow_reroute bool
backends Backends
combine_backend BackendId | None
combine_mode CombineMode
combine_resolution CombineResolutionKind
duplicate_target_ids list[str]
estimated_active_streams int
estimated_pcm_bytes int
input_conversion InputConversionPolicy
os PlatformOs
overlap_semantics OverlapSemantics
permission_policy PermissionPolicy
requires_discovery_subscription bool
selected_backend BackendId | None
target_plans list[TargetPlan]
tree_strategy ProcessTreeRange
uses_output_converter bool
uses_software_mixer bool

Resolved per-target backend, acquisition mode, and candidate evaluation trace inside CapturePlanReport.

Property Type
acquisition TargetAcquisitionKind
attempts list[TargetCandidateAttempt]
process_tree_strategy ProcessTreeStrategy | None
resolved_backend BackendId
target_id str
target_index int

Single backend candidate evaluation record (accepted or PlanErrorCode rejection).

Property Type
accepted bool
acquisition TargetAcquisitionKind | None
backend BackendId
process_tree_strategy ProcessTreeStrategy | None
rejection PlanErrorCode | None

Read-only per-input diagnostic handle exposing BYPASS/SYNC normalizer state, participation, and drift-slip counters.

Property Type
backend BackendId
clipped_samples int
drift_slips int
dropped_frames int
failure_code int | None
is_identity_bypass bool
is_resampled bool
mixer_format Format
native_format Format
nonfinite_samples int
participation_state ParticipationState
queued_packets int
target_id str
target_index int

Per-block software mixer telemetry (contributing_mask, synthesized_silence, clock-domain skew_estimate_ns, drift_slips).

Property Type
clipped_samples int
contributing_mask int
drift_slips int
failed_inputs int
late_inputs int
membership_version int
nonfinite_inputs int
nonfinite_samples int
skew_estimate_ns int | None
skew_uncertainty_ns int | None
synthesized_silence bool

Thread-safe cooperative cancellation token waking blocked read, read_into, or read_async calls immediately.

class Cancellation() -> Cancellation
def cancel() -> None
def is_cancelled() -> bool