Class InferenceHandler#

One stream through a pipeline on a context’s core, the web twin of anira::InferenceHandler: prepare with a contract (a PlanReport back), then stream through its audio node (createAudioNode).

class InferenceHandler(abi, handler, inputs)#

A handler (anira_handler): one stream through a pipeline on a context’s core, the web twin of anira::InferenceHandler of anira.hpp, member for member (camelCase for snake_case). Prepare it with a contract (a PlanReport back), then stream through it with an audio node (createAudioNode). Where the web differs: the Hard process, push and pop forms are the audio node’s (createAudioNode: the C render callback calls them on the audio thread), a failed call throws an AniraError instead of returning its status, and the handler is destroyed with destroy() (no RAII): its audio nodes first, then the handler.

Arguments:
  • abi (AniraBindings)

  • handler (number)

  • inputs (readonly InputSpec[])

static create(context, pipeline)#

anira_handler_create: copies the pipeline, which can be destroyed right after.

Arguments:
  • context (Context)

  • pipeline (Pipeline)

Returns:

InferenceHandler

prepare(contract)#

anira_handler_prepare: copies the contract, which can be destroyed right after, and returns the plan report of this prepare (planReport()). Refused while an audio node streams through the handler: re-prepare through the node (audioNode.prepare(contract)).

Arguments:
  • contract (ContractHandle)

Returns:

PlanReport

planReport()#

The report of the last prepare (anira_handler_plan_report): a view until the next one.

Returns:

PlanReport

numEntries()#

The entries a prepared handler holds in flight at once (anira_handler_num_entries).

Returns:

number

getLatency(slot=0)#

The latency of output slot in samples (anira_handler_get_latency).

Arguments:
  • slot (number)

Returns:

number

getLatencies()#

The latency of every output slot in samples, in slot order, 0 for one that is not Streamed (anira_handler_get_latencies).

Returns:

number[]

setStaticInput(slot, values)#

Write a Static input whole from the main thread (anira_handler_set_static_input), in the spec’s dtype and extents: a typed array of the spec’s element type, any ArrayBufferView of exactly the spec’s bytes, or plain numbers in the spec’s order, converted to its element type. For a handler no audio node drives (an audio node serves its Static inputs itself: its AudioParams and its own setStaticInput).

Arguments:
  • slot (number)

  • values (ArrayBufferView<ArrayBufferLike> | ArrayLike<number>)

rtError()#

The last real-time failure recorded on the handler, ANIRA_OK for none since the last prepare or reset (anira_handler_rt_error): returned, as the C++ member returns it, never thrown.

Returns:

number

setPlan(plan)#

Select the plan the next chunk runs on, a dense index of the report (anira_handler_set_plan).

Arguments:
  • plan (number)

getPlan()#

The selected plan (anira_handler_get_plan).

Returns:

number

async createAudioNode(audioContext, options={})#

A Wasm Audio Worklet node that streams through this handler (createAudioNode). Prepare the handler with the geometry measureRenderGeometry measures on the context first: a handler whose host_block_max is below the context’s burst misses quanta live.

Arguments:
  • audioContext (BaseAudioContext)

  • options (AudioNodeOptions)

Returns:

Promise<AniraAudioNode>

native()#

The anira_handler* the raw entries take.

Returns:

number

destroy()#