JavaScript/TypeScript リアルタイムエンジン API
RealtimeEngine はライブ再生を支えるサンプル精度のエンジンで、クリップ、MIDI インストゥルメント、トラックミキサー、オートメーションをブロック単位またはオフラインでレンダーします。このページには生成されたシグネチャとライフサイクルの規則を載せています。ガイドは リアルタイムエンジン です。インストゥルメントとライブ MIDI 入力は インストゥルメントとライブ MIDI、AudioWorklet ファサードは SonareEngine にあります。
タスク別の参照先
| 目的 | 使う API | ガイド |
|---|---|---|
| ライブエンジンへ MIDI クリップをサンプル精度でスケジュールする | engine.setMidiClips(...)、engine.sampleAtPpq(ppq) | リアルタイムエンジン |
| ライブ MIDI CC バインディングと件数を読む | engine.midiCcBindings()、または engine.midiCcBindings().length | インストゥルメントとライブ MIDI |
| キャプチャを設定し、ライブ入力をモニターして、状態を読む | configureCapture(...)、setInputMonitor(...)、captureStatus()。droppedFrames は破棄フレーム数 | 録音とテイク |
トラック単位のキューモニタリングを設定する(ライブの process() 出力では聞こえ、オフラインレンダー、バウンス、フリーズには含まれない) | `engine.setTrackMonitorMode(laneIndex, 'off' | 'pfl' |
| エンジンのトラックをレーン・バス・センド・ストリップでライブミックスする | engine.setTrackLanes(...)(最大 MAX_TRACK_LANES、32 レーン)、engine.setTrackBuses(...)、engine.setStrip(...) | リアルタイムエンジン |
| トラックを外部 MIDI ハードウェアへ送り、必要ならクロック/トランスポートも転送する | engine.setMidiDestinationExternal(...)、engine.setExternalMidiClockEnabled(...)、engine.drainExternalMidi(...)。Worklet ファサードでは onMidiOut(...) | リアルタイムエンジン |
| コンパイル済みプロジェクトを取り込む | engine.applyProjectTimeline(timeline) | リアルタイムエンジン |
ライフサイクル
作成
new RealtimeEngine({ sampleRate, ... }) は設定オブジェクトを受け取り、sampleRate は必須です。未知のキーは TypeError になります。prepare(config) は同じオブジェクトと同じ拒否規則でキューとスクラッチを取り直します。エンジンをオーディオスレッドで動かすには、代わりに SonareEngine ファサードから作成します。
使用
コントロール呼び出しはコマンドをキューに積み、オーディオスレッドが次のブロックの先頭で適用するので、オーディオスレッドをブロックしません。process() はリアルタイムのホストが呼ぶブロック単位の呼び出しです。新しく公開したレーン、オートメーション、グラフのセットは、ブロックごとに 1 度だけ、ロックもアロケーションもなしで取り込まれます。rtSafe: false で登録したパラメータは最初から拒否されます。prepare、renderOffline、bounceOffline、freezeOffline、settleParameters はコントロールスレッド用で、ライブのオーディオスレッドでは呼びません。コマンドキューやペイロードリングが満杯になるとエラーになり、黙って落とされることはありません。
解放
destroy() は冪等で、[Symbol.dispose]() により using が使えます(ネイティブハンドルの解放)。破棄済みのエンジンへの呼び出しは InvalidState を投げます。適用済みの ProjectTimeline は独立して破棄でき、ClipPageProvider は独自の destroy() を持ちます。
エラー
規則はどのメソッドでも 1 つです。引数そのものが拒否される場合(範囲外の値、未知またはトラック種別の違うトラック・バス・インサート・出力先・パラメータの id や名前、不正なパッチやストリップ、未知のリクエストキー)は RangeError で、値の型が違う場合や未知のキーは TypeError です。以前の呼び出しが残した状態が原因の拒否(バインドテーブルが満杯、マスターストリップ未設定、破棄済みのエンジン)は InvalidState の SonareError、コマンドキューの満杯やアロケーション失敗は OutOfMemory、ビルドに含まれない機能は NotSupported です。バインディング間の表は エラー規約 にあります。
パートリグ
setPartRig は { destinationId, part, mode: 'chain', inserts } のようなリクエストオブジェクトを 1 つ受け取ります。part は必須で、省略すると TypeError になります。デスティネーションの既定のリグには PART_RIG_ALL_PARTS を指定します。チェーンには、プロセッサ名と任意の params を持つインサートが 1〜8 個必要です。形の誤り、プロセッサ名の欠落、未知のパラメータキーは TypeError になります。未知のプロセッサ名や範囲外の値は RangeError になります。
RealtimeEngine
class RealtimeEngine {
constructor(config: RealtimeEngineConfig);
// Size the engine's queues and scratch for a sample rate and block size. It takes the same object, defaults and refusals as the constructor.
//
// `commandCapacity` must not exceed 65536 and `telemetryCapacity` must not exceed 16384; a larger value throws and leaves the engine untouched. The telemetry number is not a queue depth paid for one-for-one: the engine reserves that many meter records per metered lane, so its memory cost is far larger than the number given here.
prepare(config: RealtimeEngineConfig): void;
setParameter(
paramId: number,
value: number,
renderFrame?: number,
options?: EngineSetParameterOptions,
): void; // Queue a sample-accurate parameter change. A reserved mixer id (`0x4d58xxxx`) other than a master id names no strip and throws a `RangeError`; resolve ids with resolveStripAutomationId, resolveBusAutomationId and resolveStripInsertAutomationId. A non-boolean `smoothed` or an unknown key is a `TypeError`.
setParamSmoothingMs(smoothingMs: number): void; // Set the ramp time (ms) of `setParameter` with `smoothed: true` on every target, reserved ones included; it retimes ramps already running. The default is 20 ms, and `0` makes a smoothed change a step. The time is one time constant: about 63% of the way at the set time. MIDI-CC mappings apply their values directly. A reserved target — fader, pan, width, insert or instrument parameter — keeps its fixed 5 ms glide under the ramp whatever this is set to. A track, bus or master fader ramps its linear gain while its value stays in dB, so the time a fade takes does not depend on how far below audibility it starts; every other target ramps in its own unit.
// Queue a track's solo/mute state. An armed PFL/AFL cue (setTrackMonitorMode) is folded into the program output by `process()` / `processPrepared()` and kept separate by the `WithMonitor` variants; offline renders, bounces and freezes never include it.
//
// The track must be declared through setTrackLanes: an unknown id is a `RangeError`, and after applyProjectTimeline the call throws `InvalidState` until the lanes are declared again.
setTrackSoloMute(trackId: number, state: TrackSoloMuteState, renderFrame?: number): void;
// Queue a per-track PFL/AFL monitor tap mode change. `mode` is a string; an ordinal is a `TypeError`. The track must be declared through setTrackLanes, as for setTrackSoloMute.
//
// `process()` and `processPrepared()` fold the armed cue into the program output, so the tapped lane is counted twice there; the `WithMonitor` variants keep the cue separate. Offline renders, bounces and freezes never include the cue.
setTrackMonitorMode(trackId: number, mode: EngineTrackMonitorMode, renderFrame?: number): void;
setMidiClips(clips: readonly EngineMidiClipSchedule[]): void; // Replaces the realtime MIDI clip schedule. Failure leaves the previously accepted schedule in place.
setBuiltinInstrument(
destinationId?: number | null,
config?: Omit<BuiltinSynthConfig, 'destinationId'>,
): void; // Bind the built-in synth to a MIDI destination; `config` defaults to a sine patch. A binding is applied at a block boundary; for a frame-exact switch, bind both instruments ahead of time and switch with timed MIDI, or use a timed program change.
// Bind the patch-driven NativeSynth to a realtime MIDI destination. `patch` is a SynthPatch (a preset is named by its `preset` field, e.g. `{ preset: 'sawLead' }`; see synthPresetNames), resolving exactly like Project.bounce with `synthInstruments`. Live note/CC commands and scheduled MIDI clips routed to that destination render through the synth. Unknown preset names throw.
//
// An `engineMode: 'sample'` patch also carries the SampleBank its keymap names. The synth takes a share of the bank, so it may be released right after this call; a sample patch bound without one renders silence.
//
// Replacing a bound instrument takes effect at the next render block, whether or not the transport is rolling. The outgoing instrument's sounding notes fade out over 10 ms. The incoming instrument starts from its default channel state (program, bank, controllers); a host that needs the current position's state resends it with pushMidiUmp after this call. A binding is applied at a block boundary; for a frame-exact switch, bind both instruments ahead of time and switch with timed MIDI, or use a timed program change.
setSynthInstrument(destinationId?: number | null, patch?: SynthPatch): void;
loadSoundFont(data: Uint8Array): void; // Load (parse) SoundFont 2 bytes into the engine so SF2 instruments can be bound with setSf2Instrument. The host fetches the `.sf2` and passes the raw bytes; they are copied into linear memory for the call and not referenced afterwards. Replaces any previously loaded SoundFont.
// Bind a GS-compatible SoundFont player to a realtime MIDI destination, fed by the engine's loaded SoundFont (loadSoundFont). Live note/CC commands and scheduled MIDI clips routed to that destination render through the player (16 MIDI channels, channel 10 drums, GS NRPN part edits, GS/GM SysEx resets). Without a loaded SoundFont — or for programs the SoundFont does not cover — notes play through the built-in synthesizer GM fallback bank (the data-free floor).
//
// Replacing a bound instrument takes effect at the next render block, whether or not the transport is rolling. The outgoing instrument's sounding notes fade out over 10 ms. The incoming instrument starts from its default channel state (program, bank, controllers); a host that needs the current position's state resends it with pushMidiUmp after this call. A binding is applied at a block boundary; for a frame-exact switch, bind both instruments ahead of time and switch with timed MIDI, or use a timed program change.
setSf2Instrument(
destinationId?: number | null,
config?: Omit<Sf2InstrumentConfig, 'destinationId'>,
): void;
clearMidiInstrument(destinationId?: number | null): void; // Clears the instrument bound to `destinationId` (default 0). Its sounding notes are released and the output fades out over 10 ms. Do not call concurrently with process.
get midiInstrumentCount(): number; // Number of bound MIDI instruments.
bindMidiCc(binding: ProjectMidiCcBinding): void; // Bind a live MIDI controller (7/14-bit CC, RPN or NRPN) to an engine automation parameter. The MIDI event still reaches the destination instrument; when bound, its value is also mapped into `[minValue, maxValue]` for `paramId`.
clearMidiCcBindings(): void; // Removes every live MIDI CC / RPN / NRPN binding.
midiCcBindings(): Array<ProjectMidiCcBinding & { consume: boolean; }>; // Returns a detached copy of the MIDI CC, RPN and NRPN bindings. Order is unspecified.
setControllerProfile(destinationId: number, presetName: string): void; // Replace a destination instrument's controller profile with a named preset (see controllerProfileNames). Installing a profile drops every channel's accumulated axis values: the new bindings say nothing about what the old ones had reached. An unknown name throws, and so does a destination with no instrument or one whose instrument holds no profile.
bindController(destinationId: number, binding: ControllerBinding): void; // Add one ControllerBinding on top of the destination's current profile; `input` and `axis` are strings.
clearControllerBindings(destinationId: number): void; // Drop every binding of the destination's controller profile. The instrument keeps a profile; it resolves nothing until something is bound again.
controllerBindingCount(destinationId: number): number; // Number of bindings the controller profile of the instrument at `destinationId` currently holds.
setControllerVelocityMeaningful(
destinationId: number,
controllerVelocityMeaningful: boolean,
): void; // Whether note-on velocity is expression for this instrument. No fixed default is possible — a wind controller ships sending breath-derived velocity on one model and a constant on the next — so each preset states it and a host building its own profile sets it. When false the synth takes every note at full scale and the bound axes carry the dynamics alone.
controllerVelocityMeaningful(destinationId: number): boolean; // Reads back whether note-on velocity is expression for the instrument at `destinationId` (see setControllerVelocityMeaningful).
// Say which note a value addressed to a whole MIDI channel belongs to when several are sounding on it, for one per-note dimension (MPE_DIMENSIONS, NOTE_TRACKINGS).
//
// Set per dimension because the useful answers differ: pressure following the newest note while bend reaches every one is a real configuration, not a mistake. MPE poses this question and declines to answer it, so this is a choice rather than a rule — and it is read only inside an MPE zone, and only while more than one note is sounding on the channel, which an MPE sender avoids by giving each note its own member channel.
//
// Both arguments are required strings; an ordinal is a `TypeError` and an unknown spelling is refused rather than resolved to a default, as are a destination with no instrument and one whose instrument holds no controller profile.
setControllerNoteTracking(
destinationId: number,
dimension: MpeDimension,
tracking: NoteTracking,
): void;
controllerNoteTracking(destinationId: number, dimension: MpeDimension): NoteTracking; // Read back setControllerNoteTracking for one dimension.
// Set how one MIDI channel (0–15) of a destination's instrument treats a note-on while another note on that channel is still held: `'poly'` takes a new voice each time, `'monoRetrigger'` stops and restarts the note (what GS MONO MODE and CC126 mean), `'monoLegato'` carries the sounding voice and only moves its pitch — a wind player's slur, which no MIDI message can reach by design.
//
// `'monoLegato'` is a request, not a guarantee: an engine whose exciter is spent at the onset — anything struck or plucked — and a target pitch below what the engine's delay line can hold both fall back to an ordinary note, which legatoFallbackCount counts. A channel outside [0,15] and an articulation outside the enum are refused rather than clamped, and so is a destination with no instrument or one whose instrument has no articulation of its own. An ordinal is a `TypeError`.
//
// The setting belongs to the bound instrument: binding another one to the destination replaces it with that instrument's own (`'poly'` for a new one) and starts legatoFallbackCount from zero.
setArticulation(destinationId: number, channel: number, articulation: Articulation): void;
setPartRig(request: PartRigRequest): void; // Set the rig of one part (0-15), or of the destination's default with PART_RIG_ALL_PARTS, on the instrument bound to `destinationId`. A direct call, not a stored edit: a destination with no instrument is an invalid parameter, and an instrument without part rigs (a builtin, a host-callback instrument) is refused as not implemented rather than succeeding quietly. `'chain'` takes 1-8 `inserts`; no other mode does.
articulation(destinationId: number, channel: number): Articulation; // Read back setArticulation.
// How many times a legato continuation was asked for on this destination and refused, so the note started a voice of its own instead. Counted rather than inferred: a refusal sounds like an ordinary note, so nothing in the audio separates "this engine declines legato" from "the mode was never set". Saturates at 4294967295 rather than wrapping — matching the C ABI, so the same phrase reports the same number on every surface — after which it reads as "at least this many".
//
// Throws on a destination with no instrument, and on one whose instrument has no articulation of its own — the same two refusals setArticulation keeps apart. Reporting 0 for the second would read as "every slur took", which is the reading this counter exists to prevent.
legatoFallbackCount(destinationId: number): number;
setMidiFx(destinationId: number, config: MidiFxConfig): void; // Install/replace a live non-destructive MIDI-FX insert for one destination.
clearMidiFx(destinationId?: number): void; // Removes the live MIDI-FX insert of `destinationId` (default 0).
setMidiInputSource(destinationId?: number): void; // Enable the engine-owned live MIDI input source for a destination.
clearMidiInputSource(): void; // Disables the engine-owned live MIDI input source.
get midiInputPendingCount(): number; // Live MIDI input events queued and not yet drained.
setMidiDestinationExternal(destinationId: number, midiDestinationExternal: boolean): void; // Route a destination's (track lane's) MIDI to the external output queue instead of the internal instrument rack, so the track plays an external device. Clearing it restores internal-synth playback. Control-thread only. The change takes effect at the next processed block; switching a destination's route first releases its notes and resets its controllers through the old route, and drops its pending MIDI-FX events. Single writer.
setExternalMidiClockEnabled(externalMidiClockEnabled: boolean): void; // Enable/disable forwarding MIDI clock + transport (start/continue/stop) to the external output queue so external gear tracks the transport tempo.
get externalMidiDroppedCount(): number; // Count of external-MIDI events dropped because the output queue was full. A 64-bit count, exact up to `Number.MAX_SAFE_INTEGER`.
get externalMidiPendingCount(): number; // External-MIDI events queued and not yet drained.
// Drain queued external-MIDI events, already lowered to MIDI 1.0 byte messages ready to write to a Web MIDI output port. Call once per audio block / animation frame. `maxRecords` caps the number of output events returned — the shared unit across every surface. Events past the cap stay queued for the next call (lossless); call again to drain the rest.
//
// One queued record lowers to at most 4 MIDI 1.0 messages (a MIDI 2.0 registered or assignable controller becomes CC 101/100 or 99/98 plus Data Entry 6/38), so a positive `maxRecords` below 4 could never consume a record and is rejected with a `RangeError` instead of returning nothing forever.
drainExternalMidi(maxRecords?: number): ExternalMidiEvent[];
pushMidiInputNoteOn(
group: number,
channel: number,
note: number,
velocity: number,
offsetInBlockSamples?: number,
): void; // Push a live MIDI note-on to the engine-owned MIDI input source.
pushMidiInputNoteOff(
group: number,
channel: number,
note: number,
velocity?: number,
offsetInBlockSamples?: number,
): void; // Push a live MIDI note-off to the engine-owned MIDI input source.
pushMidiInputCc(
group: number,
channel: number,
controller: number,
value: number,
offsetInBlockSamples?: number,
): void; // Push a live MIDI control change to the engine-owned MIDI input source.
// Push a live MIDI pitch bend to the engine-owned MIDI input source.
//
// `bend14` is unsigned 14-bit with centre 8192 (0..16383) — the dimension is not 7-bit, so a value past 16383 is refused rather than narrowed. The input source must be enabled with setMidiInputSource first.
pushMidiInputPitchBend(
group: number,
channel: number,
bend14: number,
offsetInBlockSamples?: number,
): void;
pushMidiInputChannelPressure(
group: number,
channel: number,
pressure: number,
offsetInBlockSamples?: number,
): void; // Push a live MIDI channel pressure to the engine-owned MIDI input source. `pressure` is 7-bit (0..127). Under MPE this is the member channel's per-note pressure.
pushMidiInputPolyPressure(
group: number,
channel: number,
note: number,
pressure: number,
offsetInBlockSamples?: number,
): void; // Push a live MIDI polyphonic key pressure to the engine-owned MIDI input source. `note` and `pressure` are 7-bit (0..127).
pushMidiNoteOn(
destinationId: number,
group: number,
channel: number,
note: number,
velocity: number,
renderFrame?: number,
): void; // Queues a live MIDI note-on for a MIDI destination.
pushMidiNoteOff(
destinationId: number,
group: number,
channel: number,
note: number,
velocity?: number,
renderFrame?: number,
): void; // Queues a live MIDI note-off for a MIDI destination.
pushMidiCc(
destinationId: number,
group: number,
channel: number,
controller: number,
value: number,
renderFrame?: number,
): void; // Queue an immediate (live) MIDI control change to a MIDI destination (engine kMidiCcImmediate). `group`/`channel` are 0..15; `controller`/`value` are 7-bit (0..127). `renderFrame` is the frame to fire at (omit for immediate). Mirrors the Node/Python/C-ABI `pushMidiCc`.
pushMidiPitchBend(
destinationId: number,
group: number,
channel: number,
bend14: number,
renderFrame?: number,
): void; // Queue an immediate (live) MIDI pitch bend to a MIDI destination. `bend14` is unsigned 14-bit with centre 8192 (0..16383); `renderFrame` is the frame to fire at (omit for immediate). Mirrors the Node/Python/C-ABI `pushMidiPitchBend`.
pushMidiChannelPressure(
destinationId: number,
group: number,
channel: number,
pressure: number,
renderFrame?: number,
): void; // Queue an immediate (live) MIDI channel pressure to a MIDI destination. `pressure` is 7-bit (0..127); `renderFrame` is the frame to fire at (omit for immediate). Mirrors the Node/Python/C-ABI `pushMidiChannelPressure`.
pushMidiPolyPressure(
destinationId: number,
group: number,
channel: number,
note: number,
pressure: number,
renderFrame?: number,
): void; // Queue an immediate (live) MIDI polyphonic key pressure to a MIDI destination. `note` and `pressure` are 7-bit (0..127); `renderFrame` is the frame to fire at (omit for immediate). Mirrors the Node/Python/C-ABI `pushMidiPolyPressure`.
pushMidiUmp(destinationId: number, words: UmpWords, renderFrame?: number): void; // Queue an immediate (live) raw UMP message to a MIDI destination. `words` is 1 to 4 words, most significant first, and its length must match the message type of `words[0]`. MIDI 2.0 channel-voice messages (MT 0x4) arrive at full width; SysEx7 / data messages (MT 0x3 / 0x5) are refused, use pushMidiSysex. Throws when the slot ring or command queue is full (retry after a process block). `renderFrame` is the render-frame time to apply (omit for immediate).
pushMidiProgram(
destinationId: number,
group: number,
channel: number,
program: number,
bank?: MidiBank,
renderFrame?: number,
): void; // Queue a live MIDI 2.0 Program Change, with an optional bank, to a MIDI destination. `bank` carries `msb` and `lsb` (0..127); omit it to leave the bank unchanged. `group`/`channel` are 0..15 and `program` 0..127. The message takes the same receive path as pushMidiUmp. Which receivers select programs: the SoundFont player (`setSf2Instrument`) selects bank and program under its own RX PROGRAM CHANGE / RX BANK SELECT gates; a NativeSynth bound with `useGmPrograms: true` (`setSynthInstrument`) resolves each channel's voice from the bank and program; a NativeSynth whose patch plays the GM kit (the `drumKit` preset, or a percussion patch with `gmKit` on) takes the program as the GS drum-set select on every channel. Every other receiver accepts the message and ignores it: the built-in synth, any other NativeSynth patch, a part with RX PROGRAM CHANGE off, and an MPE member channel. Throws when the slot ring or command queue is full. `renderFrame` is the frame to fire at (omit for immediate).
pushMidiInputProgram(
group: number,
channel: number,
program: number,
bank?: MidiBank,
offsetInBlockSamples?: number,
): void; // Push a live MIDI 2.0 Program Change to the engine-owned MIDI input source. The arguments and refusals match pushMidiProgram; `offsetInBlockSamples` is an offset into the next block drained (clamped to its last frame, negative reads as 0), not an absolute clock position.
pushMidiInputUmp(words: UmpWords, offsetInBlockSamples?: number): void; // Push one raw UMP message (1 to 4 words) to the engine-owned MIDI input source. The message rules match pushMidiUmp. `offsetInBlockSamples` is an offset into the next block drained (clamped to its last frame, negative reads as 0), not an absolute clock position; exact here, because the caller drives the block.
pushMidiSysex(destinationId: number, data: Uint8Array, renderFrame?: number): void; // Queue an immediate (live) MIDI SysEx frame to a MIDI destination. `data` is the full message including the leading 0xF0 and trailing 0xF7 (1..512 bytes). `renderFrame` is the frame to fire at (omit for immediate). Throws a `RangeError` when the destination instrument cannot prepare the SysEx (retrying cannot help), and `OutOfMemory` when the payload slots or the command queue are full (retry after a processed block). Mirrors the Node/Python/C-ABI `pushMidiSysex`.
pushMidiPanic(renderFrame?: number): void; // Queue a MIDI panic (all-notes-off) releasing every sounding note at `renderFrame` (omitted = immediate). Mirrors the C-ABI `pushMidiPanic`.
clearParameters(): void; // Remove all registered parameters. Automation lanes stay in place, as they do on addParameter. Control-thread only; not realtime-safe. Mirrors the C-ABI `clearParameters`.
transportState(): EngineTransportState; // Read back the current transport state snapshot.
resetMasterLoudnessMeter(renderFrame?: number): void; // Queues an integrated-loudness reset; short-term and momentary windows are retained.
insertParameterConstructedValue(paramId: number): number; // Reads the immutable factory value for a resolved insert parameter id.
play(renderFrame?: number): void; // Starts transport playback, at `renderFrame` when given.
// Stops transport playback, at `renderFrame` when given.
//
// A loop wrap, seek or stop sends note-offs plus CC64=0, CC121, CC123 and a centred pitch bend on every channel played since the last reset. When playback next rolls, the controller, program, channel pressure and pitch bend values the clips set before the new position are sent again, so each loop pass and each seek starts from the state continuous playback reaches.
stop(renderFrame?: number): void;
seekSample(timelineSample: number, renderFrame?: number): void; // Moves the transport to `timelineSample`, a position in timeline samples.
settleParameters(): void; // Snaps every in-flight parameter ramp (engine-level smoothed params, mixer lane fader/pan/gate, bus gains) to its target value. It is one step of primeOfflineParameters; called alone it only snaps the smoothers and does not touch automation or processing state. Control-thread only: must not be called concurrently with process.
primeOfflineParameters(numChannels: number, blockSize?: number): void; // Runs the offline pre-roll that bounce and freeze run before rendering, without rendering anything: applies every queued command, resets the mixer and effect processors to their prepared state, adopts the published snapshots, resolves automation and lane gates at the transport position and snaps every smoother. A host that drives the engine block by block calls it once before the first chunk so a repeat render starts from the same state. Instruments are not reset. Control-thread only: must not be called concurrently with process.
resetProcessorState(renderFrame?: number): void; // Queues a reset of every mixer and effect processor to its prepared state. At `renderFrame` (omitted: the next block head) the lane, bus, master, monitor and graph processors drop their tails, delay lines and envelopes, automation is applied at the transport position and every smoother is snapped to its target, so playback queued after it starts from the state an offline bounce starts from. Strips the host bound to the engine, including host-owned ones, are reset too. Instruments are not reset. Called during playback it cuts running insert tails and delay lines mid-sound, like a seek.
get tailSamples(): number; // Longest audible tail after the last input, in samples: an upper bound made of the longest instrument tail plus the longest route through lane strips (channel delay included), buses, sends, the graph and the master strip. An instrument lane whose patch is not known yet (a drumKit lane or a General MIDI program lane before any note sounds) contributes a conservative worst-case bound that narrows once a patch has sounded. `2147483647` means the tail is unbounded. Control-thread only: must not be called concurrently with process.
get graphLatencySamples(): number; // Processing latency of the engine in samples, fractional.
get maxBlockSize(): number; // Largest block a process call accepts, as the native side resolved it (the library default when `maxBlockSize` was omitted); 0 before the engine is prepared.
settleInsertParameters(): void; // Snap only insert automation slots after structural replay.
flushControlCommands(): void; // Drains queued commands on an offline/control-only engine immediately.
applyCommandsDueNowPreservingFuture(): void; // Applies commands already due on a control-only mirror, retaining future commands.
seekPpq(ppq: number, renderFrame?: number): void; // Moves the transport to `ppq`, a position in quarter notes, in [0, 1e12].
setTempo(bpm: number): void; // Set a finite tempo in the range [1e-6, 100000] BPM.
setTempoSegments(segments: readonly EngineTempoSegment[]): void; // Installs a tempo map from ramp segments. Each segment needs a finite non-negative `startPpq` and a `bpm` in [1e-6, 100000]; a non-zero `endBpm` uses the same range. An empty array clears the map to the single tempo. Of two segments at one `startPpq`, the later-supplied one takes effect.
setTimeSignature(numerator: number, denominator: number): void; // Sets the time signature. `numerator` and `denominator` are positive integers (a `RangeError` otherwise).
setTimeSignatureSegments(segments: readonly EngineTimeSignatureSegment[]): void; // Installs a time-signature map. Each segment needs a finite non-negative `startPpq` and a positive `numerator` / `denominator`. Of two segments at one `startPpq`, the later-supplied one takes effect.
sampleAtPpq(ppq: number): number; // Converts a quarter-note position to a whole sample position on the engine timeline, through the tempo map.
setLoop(loop: EngineLoop): void; // Sets the loop region between two quarter-note positions and enables or disables it.
addParameter(info: EngineParameterInfo): void; // Registers a parameter's metadata (name, unit, range, default curve) for automation. A new `id` adds a parameter; omitted optional fields take the defaults documented on EngineParameterInfo. Control thread only; do not call concurrently with process.
parameters(): Required<EngineParameterInfo>[]; // Every registered parameter, in registration order.
parameterInfo(id: number): Required<EngineParameterInfo>; // One registered parameter by id; an unknown id is a `RangeError`.
setAutomationLane(paramId: number, points: EngineAutomationPoint[]): void; // Replaces the automation lane driving `paramId`. A reserved mixer id (`0x4d58xxxx`) other than a master id names no strip and throws a `RangeError`; resolve ids with resolveStripAutomationId. `curveToNext` is an AutomationCurve string; an ordinal is a `TypeError`.
get automationLaneCount(): number; // Number of automation lanes.
setMarkers(markers: ReadonlyArray<EngineMarkerInput>): EngineMarker[]; // Replaces the whole marker set. Entries without an `id` are assigned the lowest id above every id this engine has stored or assigned that the list does not carry; entries carrying an `id` keep it (positive, unique within the list). Returns the stored markers in the order given.
markers(): EngineMarker[]; // Every stored marker, in timeline order.
marker(id: number): EngineMarker; // One stored marker by id; an unknown id is a `RangeError`.
seekMarker(markerId: number, renderFrame?: number): void; // Moves the transport to the position of marker `markerId`. An unknown marker is a `RangeError`. `renderFrame` is the render-frame time to apply; omit it for immediate (a negative value is refused).
setLoopFromMarkers(startMarkerId: number, endMarkerId: number): void; // Sets the loop region from the positions of two markers (start, end) and enables it. An unknown marker id is a `RangeError`.
setMetronome(config: EngineMetronomeConfig): void; // Set a metronome config. The click length is `clickSamples` or `clickSec` (at most one second), never both; an explicit `0` is refused, so omit the field for the 2 ms default.
metronome(): EngineMetronomeConfig; // The metronome config, carrying only the click-length spelling that was set.
setInputMonitor(monitor: EngineInputMonitorInput): void; // Sets the dry input monitor: the live input passed straight to the output ahead of the master, switched in one step. Independent of the input track (setInputTrack); with both on, dry and wet sound together. A non-finite `gain` is a `RangeError`.
inputMonitor(): EngineInputMonitor; // The dry input monitor, both fields as one write left them.
countInEndSample(startSample: number, bars: number): number; // Sample at which a count-in of `bars` bars from `startSample` ends. Counting starts at the beginning of the bar containing `startSample` (a mid-bar start gets a short first bar), and every counted bar has the length of the time signature in effect at `startSample`. Returns `startSample` when `bars <= 0`.
setGraph(spec: EngineGraphSpec): void; // Replaces the audio processing graph (nodes and connections). Invalid specs are refused with a `TypeError` / `RangeError`. Control thread only; do not call concurrently with process.
get graphNodeCount(): number; // Number of nodes in the installed graph.
get graphConnectionCount(): number; // Number of connections in the installed graph.
setClips(clips: EngineClip[]): void; // Replaces the whole published clip set; every entry is validated and copied, and a refused entry leaves the previous set unchanged. Control thread only.
upsertClip(clip: EngineClip): void; // Replaces every published clip carrying `clip.id` with `clip`, or adds it when none does. Every other clip stays as published, so its audio is not copied again. Validated as setClips validates each entry; a refused clip leaves the published set unchanged.
removeClip(clipId: number): void; // Removes the clip carrying `clipId`.
prebakedClipChannels(clipId: number): Float32Array[] | null; // Returns the engine-owned PCM behind a clip: the audio generated for a tempo-sync clip by the control-thread setter, or the audio a freezeOffline produced. `null` for any other clip.
get clipCount(): number; // Number of published clips.
setTrackLanes(lanes: readonly EngineTrackLane[]): void; // Declares the mixer track lanes in their order. Throws a `RangeError` when the list holds more than MAX_TRACK_LANES lanes, and when a lane's `outputBusId` is an explicit `0` (omit it to stay on the master mix).
setTrackSends(trackId: number, sends: EngineTrackSend[]): void; // Replaces the sends of one lane, leaving its output bus, layout and every other lane unchanged; an empty array clears them. An unchanged send list keeps its in-flight level ramps. Throws for an unknown track id, an undeclared bus, a duplicate send bus or a level outside the send range. Unlike the worklet engine's `setTrackSends`, the lane must already be declared through setTrackLanes.
setTrackOutputBus(trackId: number, busId: number | null): void; // Sets the output bus of one lane, leaving its sends, layout and every other lane unchanged; `null` routes to the master mix and `0` is a `RangeError`. Throws for an unknown track id or an undeclared bus; the lane must already be declared through setTrackLanes.
setInputTrack(trackId: number): void; // Routes the live input into the lane of `trackId`, ahead of its strip, sends and fader, ramping over 5 ms; moving it crossfades the two lanes. An id no lane carries is a `RangeError` and leaves the routing as it was. The first two input channels feed the lane; the dry monitor (setInputMonitor) is not touched. May be set before `prepare` and survives it.
clearInputTrack(): void; // Stops routing the live input into a lane, ramping out over 5 ms.
get inputTrack(): number | undefined; // The track the live input is routed into, or `undefined`. A setTrackLanes call dropping that track's lane clears it.
setStripSidechain(ref: StripRef, insertIndex: number, source: SidechainSource | null): void; // Keys one insert of a strip from another source (ducking/sidechainRouter inserts); `null` removes the binding. A track ref accepts only a `'track'` source, the master strip a track or a bus. Lanes are processed in key order and the key is delay-compensated to the destination strip input, so the result depends on neither the lane order nor the block size. Throws, leaving the bindings unchanged, for a lane keying itself, a binding that would close a cycle over the lane bindings, a full binding table and an alignment past the delay ceiling. Not callable while a block is being processed.
// Installs a compiled project timeline into this stopped engine, all or nothing: tempo and time-signature segments, markers, track lanes, track automation, audio and MIDI clips, and the per-track strips of the project's mixer scene are replaced in full (a later low-level setter on those domains is overwritten by the next apply). Instruments, buses, the master strip, metronome, loop and capture are not touched; bind instruments separately.
//
// Throws while the transport is playing, for a timeline the engine cannot hold, and for a scene strip routed from several tracks. A validation failure leaves the engine unchanged. The engine keeps its own reference, so ProjectTimeline.destroy may follow immediately.
//
// Also throws on an unprepared engine and on a timeline whose sample rate differs from the engine's. Once a timeline is applied, a later prepare at another rate is refused until the timeline's clips are cleared.
applyProjectTimeline(timeline: ProjectTimeline): void;
setTrackBuses(buses: EngineBus[]): void; // Replaces the bus topology. Refuses (state unchanged) an output or send naming an undeclared bus or the bus itself, and any routing cycle. Control thread only; do not call concurrently with process.
setBusSidechain(busId: number, insertIndex: number, source: SidechainSource | null): void; // Keys one insert of a bus strip from a track lane or another bus (ducking/sidechainRouter inserts); `null` removes the binding.
canSetStripSidechain(ref: StripRef, insertIndex: number, source: SidechainSource): SidechainCheck; // Reports whether setStripSidechain would accept the binding, without changing anything. `reason` names the first check the setter would fail. Control-thread only: must not be called concurrently with process.
canSetBusSidechain(busId: number, insertIndex: number, source: SidechainSource): SidechainCheck; // Reports whether setBusSidechain would accept the binding, without changing anything.
setBusStrip(busId: number, settings: MixSceneBusInput): void; // Replaces a bus strip with `settings`, the object a scene holds at `buses[i]`.
setStrip(ref: StripRef, settings: MixSceneStripInput): void; // Replaces a strip (a track's, or the master) with `settings`, the object a scene holds at `strips[i]`.
setStripEqBand(ref: StripRef, bandIndex: number, band: EqBandInput): void; // Sets one EQ band of a strip (a track's, or the master).
setBusEqBand(busId: number, bandIndex: number, band: EqBandInput): void; // Sets one EQ band of a bus strip.
setStripInsertBypassed(ref: StripRef, insertIndex: number, state: InsertBypassState): void; // Bypasses or re-enables one insert of a strip; `resetOnBypass` defaults to `false`.
setBusInsertBypassed(busId: number, insertIndex: number, state: InsertBypassState): void; // Bus-strip counterpart of setStripInsertBypassed.
setStripInsertParam(ref: StripRef, insertIndex: number, param: InsertParamValue): void; // Changes one strip insert parameter in realtime, addressed by the processor's JSON-key parameter name — one of the entries masteringInsertParamInfo reports with an `id`; a construction-only entry (no `id`) takes effect only when the insert is built. Applied at the next block head via the engine command queue; safe during playback. Throws if the track, insert, or name is unknown, the param is not realtime-safe, or the command queue is full.
applyStripInsertParamNow(ref: StripRef, insertIndex: number, param: InsertParamValue): boolean; // Apply a live insert edit on this engine's owning thread without draining its command queue. Returns `false` when the smoother slots are exhausted.
restoreStripInsertParam(ref: StripRef, insertIndex: number, param: InsertParamValue): void; // Restore a retained insert value exactly after a strip scene is replayed.
setBusInsertParam(busId: number, insertIndex: number, param: InsertParamValue): void; // Bus-strip counterpart of setStripInsertParam.
applyBusInsertParamNow(busId: number, insertIndex: number, param: InsertParamValue): boolean; // Bus-strip counterpart of applyStripInsertParamNow.
restoreBusInsertParam(busId: number, insertIndex: number, param: InsertParamValue): void; // Bus-strip counterpart of restoreStripInsertParam.
clearStripInsertParameterBases(ref: StripRef): void; // Forgets the remembered manual insert-parameter values of one strip and discards its queued insert edits. Call before setStrip replaces the strip when its old values must not carry over; the setter never does this itself, since a queued edit may already target the new chain.
clearBusInsertParameterBases(busId: number): void; // Clears the stored base values of the inserts of bus `busId` that automation offsets are applied to. Not safe concurrently with process.
// Resolves a strip insert parameter (by its JSON-key name) to the reserved automation id usable with `setAutomationLane` / `setParameter`. Throws `RangeError` when the track, insert, or name is unknown, as Node does and as Python raises `SonareValueError`; no surface returns a `-1` sentinel.
//
// This is how a mastering processor gets time-varying automation: the `eq.*`, `dynamics.*`, `saturation.*`, `spectral.*`, `stereo.*`, `maximizer.*` and `multiband.*` processors are all available as strip inserts, so placing one on a strip and resolving its parameter here drives it at audio-block precision, live and offline alike. The whole-signal stages of the offline mastering chain that have no insert form (`repair.declick`, `repair.declip`, `repair.trimSilence`, `loudness`, and the match stages) have no automation id: they buffer the entire signal by construction and do not run on the realtime path. The four realtime repair inserts (`repair.decrackle`, `repair.dehum`, `repair.denoiseClassical`, `repair.dereverbClassical`) load into a strip, but every one of their parameters is construction-only, so no automation id resolves (RangeError) and an edit needs a strip replacement.
//
// Track, bus and master insert ids share one lifetime rule: an id names its strip by identity and the kind of processor in its slot (for `effects.gsEfx`, its EFX type too), so it survives lane and bus reorders and the removal of other strips, and stays valid until its track or bus is removed or its slot comes to hold another kind of processor. After that it applies nothing, its queued edits are dropped, and it is never reissued; resolve again for the new processor. A change that would take the engine past its 8192 insert-id entries is refused.
resolveStripInsertAutomationId(ref: StripRef, insertIndex: number, paramName: string): number;
resolveBusInsertAutomationId(busId: number, insertIndex: number, paramName: string): number; // Bus-strip counterpart of resolveStripInsertAutomationId.
resolveStripAutomationId(ref: StripRef, kind: 'faderDb' | 'pan' | 'width'): number; // Resolve a strip's fader (`'faderDb'`), pan (`'pan'`) or width (`'width'`) to its reserved automation id, usable with `setAutomationLane` / `setParameter`. A track ref has no width, so `'width'` on one is a `RangeError`. The id names the track, not its lane position, so it keeps driving that track across setTrackLanes reorders and applies nothing once the track is removed; the master strip always exists, so its id never goes stale. Throws `RangeError` when the track has no lane or the name is none of the three.
resolveBusAutomationId(busId: number, paramName: 'faderDb'): number; // Resolve a bus's fader (`'faderDb'`) to its reserved automation id. Same lifetime rule as resolveStripInsertAutomationId: the id names the bus, not its position in the bus list, so it keeps driving that bus across setTrackBuses reorders and the removal of other buses, and applies nothing once the bus is removed. Throws `RangeError` when the bus is not configured or the name is not `'faderDb'`.
setStripFaderDb(ref: StripRef, faderDb: number, renderFrame?: number): void; // Queue a strip fader change in dB: the strip's `'faderDb'` automation id plus setParameter.
setBusGainDb(busId: number, gainDb: number, renderFrame?: number): void; // Queue a bus gain change in dB: the bus's `'faderDb'` automation id plus setParameter.
// Resolves a hosted instrument's continuous parameter (by its JSON-key name) to the reserved automation id usable with `setAutomationLane` / `setParameter`, so an instrument parameter is driven at audio-block precision exactly like a strip insert. Throws `RangeError` when the destination has no bound instrument, the instrument exposes no automatable parameters, or the name is unknown.
//
// For the NativeSynth (setSynthInstrument) the names are the continuous SynthPatch fields: `gain`, `busDrive`, `cutoffHz`, `resonanceQ`, `drive`, `keyTrack`, `envToCutoffCents`, `velToCutoffCents`, `ampAttackMs`, `ampDecayMs`, `ampSustain`, `ampReleaseMs`, `filterAttackMs`, `filterDecayMs`, `filterSustain`, `filterReleaseMs`, `lfoRateHz`, `lfoToPitchCents`, `lfo2RateHz`, `glideMs`, `bodyMix`, `stereoSpread`, `detuneCents`, `driftCents`, `pitchOffsetCents`, `hpCutoffHz`, `sampleHoldHz`, `bitDepth`, `driftRateHz`, `ampDelayMs`, `ampHoldMs`, `filterDelayMs`, `filterHoldMs`.
//
// Structural fields (`preset`, `engineMode`, `waveform`, `filterModel`, `unison`, `polyphony`, `body`, `modRoutings`) are not automatable and throw `RangeError`: they resize voice pools or swap DSP topology, which is not audio-thread safe. Rebind the instrument with a new patch instead.
//
// All automatable parameters of a NativeSynth reach already-sounding voices from the next processed block. Voices using GM program patches are unaffected; parameters apply to NativeSynth's own patch only.
//
// The id survives an unbind/rebind of the same destination and applies nothing while that destination is unbound.
resolveInstrumentAutomationId(destinationId: number, paramName: string): number;
setStripPan(ref: StripRef, pan: number): void; // Sets a track strip's pan position in realtime (glitch-free). The master strip has no setter: drive `resolveStripAutomationId('master', 'pan')`.
setStripPanLaw(ref: StripRef, panLaw: PanLaw): void; // Sets a track strip's pan law in realtime; an ordinal is a `TypeError`.
setStripPanMode(ref: StripRef, panMode: PanMode): void; // Sets a track strip's pan mode in realtime; an ordinal is a `TypeError`.
setStripDualPan(ref: StripRef, leftPan: number, rightPan: number): void; // Sets a track strip's dual-pan left/right positions in realtime.
setStripSurroundPan(ref: StripRef, pan: SurroundPan): void; // Sets a track strip's surround placement in realtime (glitch-free; a constant-power 5 ms one-pole glide). Used when the destination has more than two channels. Omitted fields default to a centered point source. Throws a RangeError for `azimuth` outside [-180, 180] or `divergence`/`lfe` outside [0, 1], and for an unknown track, a track without a lane strip, or a non-finite field; a TypeError for a key outside those three.
setStripChannelDelaySamples(ref: StripRef, delaySamples: number): void; // Sets a track strip's alignment delay (whole samples), moving this lane later relative to every other lane. It is not latency: PDC does not compensate it and the reported graph latency is unchanged.
setBusPan(busId: number, pan: number): void; // Sets a bus strip's output pan position in realtime (glitch-free). Throws for an unknown bus or one wider than stereo.
setBusPanLaw(busId: number, panLaw: PanLaw): void; // Sets a bus strip's pan law in realtime; an ordinal is a `TypeError`.
setBusPanMode(busId: number, panMode: PanMode): void; // Sets a bus strip's pan mode in realtime; an ordinal is a `TypeError`.
setBusDualPan(busId: number, leftPan: number, rightPan: number): void; // Sets a bus strip's dual-pan left/right positions in realtime.
popClipPageRequest(): ClipPageSampleRequest | undefined; // Pops the oldest clip-page request, or `undefined` when none is queued.
get clipPageRequestOverflowCount(): number; // Cumulative page misses dropped because the native bounded request queue was full. A 64-bit count, exact up to `Number.MAX_SAFE_INTEGER`.
get warpStretchOverflowCount(): number; // Cumulative warp-stretch requests dropped because the native queue was full. A 64-bit count, exact up to `Number.MAX_SAFE_INTEGER`.
setWarpVoiceCapacity(voices: number): void; // Sets the number of concurrent time-stretch voices. `voices` must be an integer in `[0, 64]`; a non-integer, negative, or larger value throws and leaves the capacity unchanged. Default is 8. Capacity 0 disables time-stretch, so every warped clip plays resampled instead and none of that counts toward warpStretchOverflowCount. A change applied while the engine is running restarts the splice state of any clip stretching through a voice at that moment. Control-thread only.
get warpVoiceCapacity(): number; // The current time-stretch voice capacity (default 8).
// Sets the clip-page look-ahead window in timeline frames.
//
// The player reports the pages it is *about to* read that are not resident yet, so a streaming host can service them before the audio thread reaches them. Without look-ahead a page miss is only reported after the read already produced silence, which costs one block of silence at every page boundary the host has not primed — the reason a sliding-window streamer cannot keep a live playhead fed from miss reports alone.
//
// Look-ahead requests drain through the same `popClipPageRequest` queue and are queued *after* the block's genuine misses, so a host that keeps only the newest request per clip (as ClipPageStreamer does) tracks the look-ahead frontier.
//
// `prepare` defaults this to half a second at the engine's sample rate. `0` disables the look-ahead. A clip whose pages are all resident produces no requests at all, with or without look-ahead. Safe to call during playback.
setClipPagePrefetchFrames(frames: number): void;
get clipPagePrefetchFrames(): number; // Current clip-page look-ahead window in timeline frames.
configureCapture(options: CaptureOptions): void; // Sets up capture in one call: buffer, source, record offset and punch window. It leaves the input monitor (setInputMonitor) alone. The call states the whole setup, so an omitted field returns to its default and an omitted `punch` clears the punch window. The buffer is reallocated only when `numChannels` or `capacityFrames` changes, and doing that while capture is armed is a `SonareError` with `ErrorCode.InvalidState`.
armCapture(state: CaptureArmState): void; // Arms or disarms capture.
resetCapture(): void; // Clears the capture frame counter. Call while capture is not running.
captureStatus(): EngineCaptureStatus; // Reads the capture state: recorded frames, overflow count, armed and punch flags, source and record offset.
capturedAudio(): Float32Array[]; // Reads the recorded samples: one `Float32Array` per capture channel, sliced to the frames recorded so far.
// Renders in place, adding engine output to `channels`. Zero each plane first when it contains no upstream input.
//
// With `{ withMonitor: true }` the monitor (cue/listen) bus is returned apart from the program mix instead of being folded into it: `output` is the program mix and `monitor` the monitor bus, one buffer per plane. Audio thread only; each plane must not exceed the prepared block size.
process(channels: Float32Array[], options?: { withMonitor?: false; }): Float32Array[];
process(
channels: Float32Array[],
options: { withMonitor: true; },
): EngineProcessWithMonitorResult;
prepareChannels(numChannels: number, maxFrames: number): void; // Allocates persistent per-channel WASM-heap scratch for the zero-copy `channelBuffer` / `processPrepared` realtime path. Call once (off the audio thread) before driving `processPrepared` from an AudioWorklet so the render callback never allocates on the C++/JS heap.
channelBuffer(channel: number, numFrames: number): Float32Array; // Returns a Float32Array view onto the persistent WASM-heap scratch for one channel (valid for up to `numFrames`). Fill it, call `processPrepared`, then read the same view back. Re-acquire after WASM memory growth.
// Runs the engine in place over the prepared per-channel scratch buffers. Zero each active span first when it contains no upstream input. Allocation-free: safe to call on the AudioWorklet render thread after `prepareChannels`.
//
// With `{ withMonitor: true }` the cue bus is written to the monitor scratch (monitorChannelBuffer) instead of being folded into the program output; that needs `prepareMonitorChannels` first.
processPrepared(numFrames: number, options?: EngineProcessOptions): void;
prepareMonitorChannels(numChannels: number, maxFrames: number): void; // Allocates the cue-bus counterpart of prepareChannels. Needed only when PFL/AFL monitoring must reach a separate output: `processPrepared` folds the cue bus into the program output, while `processPrepared(frames, { withMonitor: true })` keeps the two apart. Call once, off the audio thread, with at least as many channels as `prepareChannels` got.
monitorChannelBuffer(channel: number, numFrames: number): Float32Array; // Returns a Float32Array view onto the persistent cue-bus scratch for one channel (valid for up to `numFrames`). Read it after `processPrepared(frames, { withMonitor: true })`. Re-acquire after WASM memory growth.
// Render `request.channels` offline from the current transport position. Requesting more planes than `prepare` reserved throws a `RangeError` rather than returning silence that reads as a finished render.
//
// Set `finalize: false` to render one chunk of a longer timeline; see RenderOfflineRequest.finalize and finishOfflineRender.
renderOffline(request: RenderOfflineRequest): Float32Array[];
// End a chunked offline render: release every note the sequencer still holds and flush the PDC / alignment delay lines. Required after `renderOffline({ finalize: false })`; the finalizing form does it itself.
//
// Skipping it leaves every note still sounding at the last chunk held. On an engine-internal instrument the tail simply never releases; on a destination marked external (RealtimeEngine.setMidiDestinationExternal) the note-ons already left through the external MIDI queue, so the note-offs emitted here are the only ones the receiving device will get and the notes otherwise hang outside the engine.
finishOfflineRender(): void;
bounceOffline(options: EngineBounceOptions): EngineBounceResult; // Bounce the timeline to planar channels. `numChannels` above the prepared channel count throws a `RangeError`. `blockSize`, `targetSampleRate` and `sourceSampleRate` are omitted for their defaults (the engine block, the source rate, the engine rate); an explicit `0` is a `RangeError`. An omitted `targetLufs` is -14 LUFS and any finite value is literal. If the bounce throws after pre-roll or rendering begins, the engine retains changes already made to its processor and transport state. The failed call returns no bounce result.
freezeOffline(options: EngineFreezeOptions): EngineFreezeResult; // Render the source layer over the span and install it as the only clip. Bakes every audio clip and hosted MIDI instrument through the lane strips, lane inserts and group buses; the master strip, monitor bus, engine graph, capture and metronome stay live and process the frozen clip once on playback. The frozen clip replaces the whole clip set and every MIDI clip is withdrawn in the same call, so nothing plays twice; live MIDI input still reaches the instruments. `numChannels` above the prepared channel count throws a `RangeError`.
drainTelemetry(maxRecords?: number): EngineTelemetry[]; // Drains pending process and error telemetry records, oldest first.
drainMeterTelemetry(maxRecords?: number): EngineMeterTelemetry[]; // Drains pending meter telemetry as per-plane records, oldest first. A stereo target's left and right are planes 0 and 1; a surround target carries every plane.
meterTargetInsertGainReduction(targetId: number): number[]; // Per-insert gain reduction in dB (each <= 0) of a meter target's strip from the last rendered block, in combined pre-to-post insert order. `targetId` uses the meter-record encoding (0 master, 1..32 lanes, 33..40 buses; 0xFFFF monitor yields an empty array). Throws for an id outside that range.
configureScopeTelemetry(intervalFrames: number, bandCount: number): number; // Enables per-target spectrum + vectorscope capture.
drainScopeTelemetry(maxRecords?: number): EngineScopeTelemetry[]; // Drains pending spectrum + vectorscope snapshots (per mix target).
destroy(): void; // Release the underlying WASM object. Idempotent, as the Node facade is.
[Symbol.dispose](): void; // Releases the handle through destroy, so the instance works with `using`.
}
const MAX_TRACK_LANES = 32
interface RealtimeEngineConfig {
sampleRate: number; // Sample rate in Hz. Required.
maxBlockSize?: number; // Largest block the engine renders, in frames. Default `128`; `0` is refused.
commandCapacity?: number; // Command queue capacity, at most 65536. Default `1024`; `0` is refused.
telemetryCapacity?: number; // Telemetry queue capacity, at most 16384. Default `1024`; `0` is refused.
maxChannels?: number; // Most channel planes the engine can render. Default `64`; `0` is refused.
}