svelte-audio-renderer

Attributes

Attributes set the node's AudioParams and properties, and update when they change.

Rules

You writeWeb Audio does
frequency={440} on an AudioParamnode.frequency.value = 440
type="sine" on a propertynode.type = 'sine'
removing an attributethe param's defaultValue, or the property's original value
maxDelayTime, feedforward, numberOfInputs, …passed to create…(), read once
a read-only property such as numberOfInputs on <gain>ignored, and a type error

AudioParams

An AudioParam attribute sets .value, which changes it instantly, with no smoothing. For ramps and automation, use the node directly with audioNode.

<biquadFilter type="lowpass" frequency={cutoff} Q="2"></biquadFilter>

Number attributes also accept strings, such as Q="2", because static attributes in Svelte are strings.

Removing an attribute

When an attribute is removed or set to undefined, the param goes back to its defaultValue and the property to the value the node had when it was created.

Creation options

Options that only exist at creation are passed to create…() and read once. Changing one later does nothing, as in Web Audio. Wrap the element in {#key} to recreate it:

{#key maxDelayTime}
	<delay {maxDelayTime} delayTime={0.5}></delay>
{/key}

Read-only properties

Read-only properties and methods are never assigned. numberOfInputs={2} on a <gain> is ignored at runtime, and it is a type error.