Python リアルタイムエンジン API
RealtimeEngine は、ライブ再生とオフラインレンダーを支えるサンプル精度のエンジンです。このページには、ライフサイクルの規則と、構築、トランスポートとタイミング、クリップとパラメータ、キャプチャ・レンダー・テレメトリのシグネチャを載せています。ガイドは リアルタイムエンジン です。トラックレーン、バス、ストリップ、クリップページプロバイダは Python エンジンミキシング API に、インストゥルメントとライブ MIDI は インストゥルメントとライブ MIDI にあります。
タスク別の参照先
| やりたいこと | API | ガイド |
|---|---|---|
| ライブエンジンへ MIDI クリップをサンプル精度でスケジュールする | EngineMidiClipSchedule / EngineMidiEvent を渡す RealtimeEngine.set_midi_clips([...])、RealtimeEngine.sample_at_ppq(ppq)。ppq は音楽的時間の単位で、四分音符あたりのパルス数です | リアルタイムエンジン |
| トラック単位のキューモニタリングを設定する | RealtimeEngine.set_track_monitor_mode(track_id, mode, render_frame=None)。EngineTrackMonitorMode(off/pfl/afl、綴りは厳密)を使い、track_id は set_track_lanes で宣言したトラックです。PFL はフェーダー前、AFL はフェーダー後を試聴します。process() は有効なキューをプログラム出力に折り込みますが、オフラインのレンダリング、バウンス、フリーズには含まれません | リアルタイムエンジン |
| ワイドメーターとスコープを読む | drain_meter_telemetry(...)(レコードがチャンネルごとのプレーンを持ちます)、configure_scope_telemetry(...)、drain_scope_telemetry(...) | リアルタイムエンジン |
| エンジンのクリップ集合を 1 クリップずつ編集する | RealtimeEngine.upsert_clip、remove_clip | リアルタイムエンジン |
| プロセッサのリセット、繰り返しレンダリングの準備、テールとレイテンシの読み取り | reset_processor_state、prime_offline_parameters、tail_samples、graph_latency_samples | リアルタイムエンジン |
| エンジンの音声を配列で受け取る、レーン数の上限 | RealtimeEngine.process(with_monitor=True も含む)と render_offline は float32 の NumPy 配列(チャンネルごとの配列のリスト)を返し、EngineBounceResult.interleaved は float32 配列です。set_track_lanes は MAX_TRACK_LANES(32)レーンまでで、それより長いリストは SonareValueError です | リアルタイムエンジン |
| エンジンのトラックをライブミックス/自動化する | レーン/ストリップ操作に加え、set_track_sends(track_id, sends)、set_track_output_bus(track_id, bus_id)、set_bus_insert_param(bus_id, insert_index, name, value)、set_bus_insert_bypassed(bus_id, insert_index, bypassed)、resolve_strip_insert_automation_id(ref, insert_index, param_name)、resolve_bus_insert_automation_id(...)、set_param_smoothing_ms(...) | リアルタイムエンジン |
| サイドチェイン接続が受理されるか、されないならなぜかを尋ねる | RealtimeEngine.can_set_strip_sidechain、can_set_bus_sidechain(SidechainCheck を返す) | リアルタイムエンジン |
| フェーダー・パン・ウィズのオートメーションをトラック、バス、マスターで指定する | resolve_strip_automation_id(ref, kind)(トラック ID または "master")、resolve_bus_automation_id("faderDb"・"pan"、マスターのみ "width")。resolve_instrument_automation_id(destination_id, param_name) を含むすべての resolve_*_automation_id は、未知のトラック・バス・インサート・デスティネーション・パラメータ、またはリアルタイム安全でないパラメータに SonareValueError を送出します | リアルタイムエンジン |
ライフサイクル
作成
RealtimeEngine(sample_rate, max_block_size=None, *, command_capacity=None, telemetry_capacity=None, max_channels=None) でエンジンを作り、prepare(...) は同じ引数でキューとスクラッチを取り直します。MAX_TRACK_LANES(32)は set_track_lanes が受け付ける最大のレーン数です。
使用
コントロール呼び出しはコマンドをキューに積み、オーディオ側が次のブロックの先頭で適用します。process() はリアルタイムのホストが呼ぶブロック単位の呼び出しで、チャンネルごとの float32 NumPy 配列を返します。render_offline、bounce_offline、freeze_offline はオフラインでレンダーし、prepare と settle_parameters と合わせて、ライブのオーディオコールバックの外で呼びます。コマンドキューやペイロードリングが満杯になるとエラーになり、黙って落とされることはありません。
解放
close() は冪等で、エンジンはコンテキストマネージャとして使えます(with sonare.RealtimeEngine(48000) as engine:)。ネイティブハンドルの解放 を参照してください。close() の後に呼び出すと INVALID_STATE の SonareError が上がります。
エラー
引数そのものが拒否される場合(範囲外の値、未知またはトラック種別の違う id や名前、不正なパッチやストリップ、MAX_TRACK_LANES を超えるレーンリスト)は SonareValueError です。以前の呼び出しが残した状態が原因なら INVALID_STATE の SonareError、キューの満杯やアロケーション失敗は OUT_OF_MEMORY、ビルドに含まれない機能は NOT_SUPPORTED です。表全体は エラー契約 にあります。
構築とライフサイクルのメンバー
def __init__(
self,
sample_rate: int,
max_block_size: int | None = None,
*,
command_capacity: int | None = None,
telemetry_capacity: int | None = None,
max_channels: int | None = None,
) -> None: ...
# Release the native engine; idempotent. Any later
def close(self) -> None: ...
# Return the engine for use as a context manager.
def __enter__(self) -> RealtimeEngine: ...
# Close the engine on leaving the ``with`` block.
def __exit__(self, *_exc: object) -> None: ...
def prepare(
self,
sample_rate: int,
max_block_size: int | None = None,
command_capacity: int | None = None,
telemetry_capacity: int | None = None,
max_channels: int | None = None,
) -> None: ...トランスポート、タイミング、マーカー
# Start the transport; ``render_frame`` is a non-negative integer frame
def play(self, render_frame: int | None = None) -> None: ...
def stop(self, render_frame: int | None = None) -> None: ...
def seek_sample(self, timeline_sample: int, render_frame: int | None = None) -> None: ...
def seek_ppq(self, ppq: float, render_frame: int | None = None) -> None: ...
def settle_parameters(self) -> None: ...
def prime_offline_parameters(self, num_channels: int, block_size: int | None = None) -> None: ...
@property
def max_block_size(self) -> int: ...
@property
def tail_samples(self) -> int: ...
@property
def graph_latency_samples(self) -> float: ...
def flush_control_commands(self) -> None: ...
def settle_insert_parameters(self) -> None: ...
def apply_commands_due_now_preserving_future(self) -> None: ...
def apply_project_timeline(self, timeline: ProjectTimeline) -> None: ...
# Queue a reset at the next block head when ``render_frame`` is None;
def reset_master_loudness_meter(self, render_frame: int | None = None) -> None: ...
# Queue a reset of every lane, bus, master and graph processor state at the
def reset_processor_state(self, render_frame: int | None = None) -> None: ...
def set_tempo(self, bpm: float) -> None: ...
# Set the time signature, e.g. 3/4 as ``numerator`` 3, ``denominator`` 4.
def set_time_signature(self, numerator: int, denominator: int) -> None: ...
def set_tempo_segments(self, segments: Sequence[Mapping[str, float]]) -> None: ...
def set_time_signature_segments(self, segments: Sequence[Mapping[str, float]]) -> None: ...
def sample_at_ppq(self, ppq: float) -> int: ...
def set_loop(self, start_ppq: float, end_ppq: float, enabled: bool = True) -> None: ...
def transport_state(self) -> TransportState: ...
# Replace the whole marker set and return the stored markers in the order given.
def set_markers(
self,
markers: Sequence[EngineMarker | EngineMarkerInput],
) -> list[EngineMarker]: ...
def markers(self) -> list[EngineMarker]: ...
# Return the marker with the given ``id``.
def marker(self, id: int) -> EngineMarker: ...
# Move the playhead at the next block head when ``render_frame`` is None;
def seek_marker(self, marker_id: int, render_frame: int | None = None) -> None: ...
# Set the loop region from a start and an end marker id.
def set_loop_from_markers(self, start_marker_id: int, end_marker_id: int) -> None: ...
# Configure the metronome.
def set_metronome(self, config: EngineMetronomeConfig) -> None: ...
# Return the current metronome configuration.
def metronome(self) -> EngineMetronomeConfig: ...
def count_in_end_sample(self, start_sample: int, bars: int) -> int: ...クリップ、パラメータ、オートメーション
# Replace the whole audio clip set; a refused clip raises and leaves the published set
def set_clips(self, clips: Sequence[EngineClip]) -> None: ...
def upsert_clip(self, clip: EngineClip) -> None: ...
def remove_clip(self, clip_id: int) -> None: ...
# Number of audio clips currently installed.
@property
def clip_count(self) -> int: ...
# Register an automatable parameter; a duplicate id is refused.
def add_parameter(self, info: ParameterInfo) -> None: ...
def clear_parameters(self) -> None: ...
def parameters(self) -> list[ParameterInfo]: ...
# Return the registered parameter with the given ``id``.
def parameter_info(self, id: int) -> ParameterInfo: ...
def set_parameter(
self,
param_id: int,
value: float,
render_frame: int | None = None,
*,
smoothed: bool = False,
) -> None: ...
def set_param_smoothing_ms(self, smoothing_ms: float) -> None: ...
def set_automation_lane(self, param_id: int, points: Sequence[AutomationPoint]) -> None: ...
# Number of automation lanes currently installed.
@property
def automation_lane_count(self) -> int: ...
# Set the clip-page look-ahead window in timeline frames.
def set_clip_page_prefetch_frames(self, frames: int) -> None: ...
# Clip-page look-ahead window in timeline frames.
@property
def clip_page_prefetch_frames(self) -> int: ...
# Pop the next clip-page request the host should service, or None when none is pending.
def pop_clip_page_request(self) -> ClipPageRequest | None: ...
@property
def clip_page_request_overflow_count(self) -> int: ...
@property
def warp_stretch_overflow_count(self) -> int: ...
def set_warp_voice_capacity(self, voices: int) -> None: ...
def warp_voice_capacity(self) -> int: ...キャプチャ、グラフ、レンダー、テレメトリ
configure_capture ではバッファ、ソース、録音オフセット、パンチ範囲を設定します。ドライ入力モニターは set_input_monitor(EngineInputMonitorInput(...)) で別に設定します。capture_status() の dropped_frames はバッファ満杯で破棄されたフレーム数です。
# Configure capture as a whole; an omitted setting takes its default.
def configure_capture(
self,
*,
capacity_frames: int,
num_channels: int = 2,
source: EngineCaptureSource = 'output',
record_offset_samples: int = 0,
punch: CapturePunch | None = None,
) -> None: ...
# Turn the dry input monitor on or off at ``monitor.gain``.
def set_input_monitor(self, monitor: EngineInputMonitor | EngineInputMonitorInput) -> None: ...
# Return the dry input monitor, both fields from one write.
def input_monitor(self) -> EngineInputMonitor: ...
# Arm (or disarm) recording into the capture buffer.
def arm_capture(self, armed: bool = True) -> None: ...
# Reset the capture state.
def reset_capture(self) -> None: ...
# Return the current capture state.
def capture_status(self) -> EngineCaptureStatus: ...
# Return the captured audio, one array per channel.
def captured_audio(self) -> list[np.ndarray]: ...
# Install the engine processing graph from ``spec``.
def set_graph(self, spec: EngineGraphSpec) -> None: ...
# Number of nodes in the installed graph.
@property
def graph_node_count(self) -> int: ...
# Number of connections in the installed graph.
@property
def graph_connection_count(self) -> int: ...
# Render one block and return the processed channel copies; inputs are not modified.
@overload
def process(
self,
channels: PlanarChannels,
*,
with_monitor: Literal[False] = False,
) -> list[np.ndarray]: ...
# Render one block and return the program planes and the monitor planes.
@overload
def process(
self,
channels: PlanarChannels,
*,
with_monitor: Literal[True],
) -> EngineProcessWithMonitorResult: ...
@overload
def process(
self,
channels: PlanarChannels,
*,
with_monitor: bool,
) -> list[np.ndarray] | EngineProcessWithMonitorResult: ...
# Render one offline span from the current transport position; ``block_size`` None is the
def render_offline(
self,
channels: PlanarChannels,
*,
block_size: int | None = None,
finalize: bool = True,
) -> list[np.ndarray]: ...
# End a chunked offline render, releasing held notes and flushing delay lines; required
def finish_offline_render(self) -> None: ...
# Render the whole span in one call and return the interleaved mix.
def bounce_offline(self, options: EngineBounceOptions) -> EngineBounceResult: ...
# Render the source layer over the span and install it as the only clip.
def freeze_offline(self, options: EngineFreezeOptions) -> EngineFreezeResult: ...
# Drain up to ``max_records`` engine telemetry records; the rest stay queued.
def drain_telemetry(self, max_records: int = 1024) -> list[EngineTelemetry]: ...
# Drain meter records with one measurement per plane and no right value for mono.
def drain_meter_telemetry(self, max_records: int = 1024) -> list[MeterTelemetryRecord]: ...
# Return per-insert gain reduction in dB (<= 0) for a meter target's strip.
def meter_target_insert_gain_reduction(self, target_id: int) -> np.ndarray: ...
# Enable scope telemetry and return the applied band count.
def configure_scope_telemetry(self, interval_frames: int, band_count: int) -> int: ...
# Drain up to ``max_records`` scope telemetry records.
def drain_scope_telemetry(self, max_records: int = 1024) -> list[ScopeTelemetryRecord]: ...ビルドとホストの情報
abi_version() は C ABI の集約バージョンを返します。すべてのサブシステムの ABI 番号をひとつの 32 ビット値にまとめているので、ビルド済みのバインディングが互換性のないネイティブライブラリを検出できます。capability_catalog() は、読み込まれたライブラリのプロセッサとプリセットのカタログ全体を返します(ケイパビリティカタログ)。プロセッサがディスクリプタを公開していないパラメータの範囲や既定値は None です。system_info() は、ライブラリが動作しているホストを dict で返します。キーは cpu(logical_cores、physical_cores)、memory(total_gb、available_gb)、parallel(enabled、workers、strategy)で、プラットフォームが報告できない項目は含まれません。
# Return the aggregate libsonare C ABI version.
def abi_version() -> int: ...
# Return the loaded library's complete processor and preset catalog.
def capability_catalog() -> CapabilityCatalog: ...
# Return the host this library runs on: CPU cores, memory and parallelism.
def system_info() -> dict[str, Any]: ...