Python Capabilities Types
The records that describe the loaded library: capabilities() returns a Capabilities, capability_catalog() a CapabilityCatalog, and the mastering catalog functions return the processor, preset and insert-parameter records. The functions are on Python Analysis API (capabilities), Python Realtime Engine API (capability_catalog) and Python Mastering API (mastering_processor_catalog, mastering_amp_preset_catalog, mastering_insert_param_info, mastering_insert_timing). The documents these records mirror are described on Capability Catalog.
All of these are frozen dataclasses, so a catalog read once is safe to share.
Build and runtime
Capabilities.features has one field for every compile-time option, False when the option was off. An entry point of a feature that was not built stays exported and raises NotSupported, so probing for a symbol tells a host nothing; these fields are the probe. decode.builtin and decode.ffmpeg list file extensions; ffmpeg is empty without FFmpeg. abi holds the project document and realtime engine ABI versions. Read encode.builtin and encode.ffmpeg for writable formats.
# Build and runtime descriptor returned by :func:`libsonare.capabilities`.
@dataclass(frozen=True)
class Capabilities:
version: str
abi: CapabilitiesAbi
platform: str
features: CapabilitiesFeatures
decode: AudioFormatCapabilities
encode: AudioFormatCapabilities
simd: str
hardware_concurrency: int
# ABI versions reported by :func:`libsonare.capabilities`.
@dataclass(frozen=True)
class CapabilitiesAbi:
project: int
engine: int
# Build options reported by :func:`libsonare.capabilities`.
@dataclass(frozen=True)
class CapabilitiesFeatures:
mastering: bool
mixing: bool
mixing_assistant: bool
graph: bool
fx: bool
ffmpeg: bool
instrument_param_automation: bool
arrangement: bool
project: bool
acoustic_sim: bool
playback: bool
live_devices: bool
pitch_editor: bool
vocal_edit: bool
voice_changer: bool
assist: bool
# Formats available through the built-in implementation and through FFmpeg.
@dataclass(frozen=True)
class AudioFormatCapabilities:
builtin: tuple[str, ...]
ffmpeg: tuple[str, ...]Catalog
CapabilityCatalog is the machine-readable catalog: every processors entry, the flat chain description, built-in presets identifiers and mastering_presets with their loudness targets.
chain describes every flat mastering chain key. A stage's keys are <prefix>.<leaf> and are the parameters of its processor, which is None when every key of the stage is chain-only. An indexed list's <key>.<i> is the chain parameter key when processor is None; otherwise <key>.<i>.<field> is that processor's field. chain.params holds the keys no processor describes, with bounds measured through the chain's own validator. presets.playback_room is always present.
MasteringPresetCatalogEntry.kind is "mastering" or "restoration". The three numeric fields (target_lufs, true_peak_ceiling_dbtp, max_limiter_gain_reduction_db) are None for a restoration preset, which carries no loudness stage.
# Machine-readable catalog returned by :func:`capability_catalog`.
@dataclass(frozen=True)
class CapabilityCatalog:
version: str
abi: CapabilitiesAbi
encode: AudioFormatCapabilities
processors: tuple[MasteringProcessorCatalogEntry, ...]
chain: CapabilityCatalogChain
presets: CapabilityCatalogPresets
mastering_presets: tuple[MasteringPresetCatalogEntry, ...]
# Built-in preset identifiers grouped by public feature family.
@dataclass(frozen=True)
class CapabilityCatalogPresets:
mastering: tuple[str, ...]
synth: tuple[str, ...]
mixing_scene: tuple[str, ...]
voice_changer: tuple[str, ...]
playback_room: tuple[str, ...]
# How each flat mastering chain key is described.
@dataclass(frozen=True)
class CapabilityCatalogChain:
stages: tuple[CapabilityCatalogChainStage, ...]
lists: tuple[CapabilityCatalogChainList, ...]
params: tuple[MasteringInsertParamInfo, ...]
# One flat chain stage; ``<prefix>.<leaf>`` keys are ``processor``'s parameters.
@dataclass(frozen=True)
class CapabilityCatalogChainStage:
prefix: str
processor: str | None
form: Literal['offline'] | None
enabled_key: str
# An indexed chain list.
@dataclass(frozen=True)
class CapabilityCatalogChainList:
key: str
processor: str | None
form: Literal['offline'] | None
min_items: int
max_items: int
# One mastering preset's kind and loudness targets.
@dataclass(frozen=True)
class MasteringPresetCatalogEntry:
name: str
kind: MasteringPresetKind
target_lufs: float | None
true_peak_ceiling_dbtp: float | None
max_limiter_gain_reduction_db: float | NoneProcessors and insert parameters
mastering_processor_catalog() returns MasteringProcessorCatalogEntry records. kind is "realtime" (builds as a scene insert), "offline" (whole-file only) or "pair" (two inputs). realtime_insertable is true exactly for ids that always succeed as a realtime scene insert. latency_samples and tail_samples are for the default 48 kHz / 512-sample probe and are 0 for offline processors; realtime_cost is None when the processor is not an insert. causal is whether the output at a sample depends only on input up to it, plus the reported latency. slots lists an insert's conditional key groups in declaration order. forms lists every way the id runs, realtime first, and offline_params is None unless the offline form's parameters differ from params.
MasteringInsertParamInfo describes one key of an insert. Entries come in two runs: the realtime automation targets in id order, then, sorted by name, the keys construction reads that are not automation targets, with id None and rt_safe false. Reading a descriptor:
min/maxareNonewhen no limit is stated orchoicesis set;min_exclusive/max_exclusivesay whether the bound itself is rejected.max_relative_tois"nyquist"when the ceiling follows the processing rate.ui_min/ui_maxare the range a control should draw, inside[min, max];Nonemeans the bound.scaleis the axis,"linear"or"log".depends_onlists siblings whose live values bound this key; eachMasteringInsertParamDependencyreads asthis <relation> factor * sibling, so"le"withfactor0.5 means at most half the sibling's value.coupled_withnames other siblings that move the range in a waydepends_oncannot state.choicesis a closed set. AMasteringInsertParamChoice.nameis a lowerCamelCase display label that is not accepted as input;valueis the number construction takes. An"enum"key is sent as that number.slotnames theMasteringInsertSlota key belongs to, orNonefor a key that always exists. A slot is a group of keys that exists only under a condition (an EQ band, a multiband crossover band, a dynamic sub-band):nameis the key prefix without the trailing dot,parentnames the enclosing slot,activationis"anyKey"(exists once any of its keys is supplied) or"always", andmin_crossover_cutoffsis the number of crossovercutoff<i>Hzkeys needed in effect.
MasteringInsertTiming is what mastering_insert_timing returns for an insert built from given parameters at a given rate. MasteringAmpPresetCatalogEntry.params holds a rig's resolved starting values under the insert's camelCase keys, with enum keys as their choice tokens; the DSP is still driven by the rig index plus sparse overrides.
# Capabilities exposed by :func:`mastering_processor_catalog`.
@dataclass(frozen=True)
class MasteringProcessorCatalogEntry:
id: str
description: str
kind: MasteringProcessorKind
forms: tuple[Literal['realtime', 'offline'], ...]
realtime_insertable: bool
stereo_only: bool
latency_samples: int
tail_samples: int
realtime_cost: Literal['low', 'moderate', 'high'] | None
channel_policy: MasteringChannelPolicy
category: MasteringProcessorCategory
causal: bool
params: tuple[MasteringInsertParamInfo, ...]
slots: tuple[MasteringInsertSlot, ...]
offline_params: tuple[MasteringInsertParamInfo, ...] | None = None
# Metadata for one key an insert processor's construction or automation reads.
@dataclass(frozen=True)
class MasteringInsertParamInfo:
name: str
id: int | None
rt_safe: bool
type: Literal['boolean', 'number', 'enum', 'string', 'array']
min: float | None
max: float | None
min_exclusive: bool
max_exclusive: bool
max_relative_to: Literal['nyquist'] | None
default: float | bool | None
unit: MasteringInsertParamUnit | None
ui_min: float | None
ui_max: float | None
scale: MasteringInsertParamScale
depends_on: tuple[MasteringInsertParamDependency, ...]
coupled_with: tuple[str, ...]
choices: tuple[MasteringInsertParamChoice, ...] | None
slot: str | None
domain_min: float | None = None
domain_min_exclusive: bool | None = None
domain_max: float | None = None
domain_max_exclusive: bool | None = None
# One accepted value of a closed-set insert parameter.
@dataclass(frozen=True)
class MasteringInsertParamChoice:
name: str
value: int
# A sibling key whose value bounds this parameter's.
@dataclass(frozen=True)
class MasteringInsertParamDependency:
key: str
relation: MasteringInsertParamRelation
factor: float
# A group of an insert's keys that exists only under a condition.
@dataclass(frozen=True)
class MasteringInsertSlot:
name: str
parent: str | None
activation: Literal['anyKey', 'always']
min_crossover_cutoffs: int
# Latency and tail of one insert built from given params, at a given rate.
@dataclass(frozen=True)
class MasteringInsertTiming:
latency_samples: int
tail_samples: int
# One built-in amp-sim rig, as returned by :func:`mastering_amp_preset_catalog`.
@dataclass(frozen=True)
class MasteringAmpPresetCatalogEntry:
index: int
name: str
params: dict[str, float | int | bool]