API
Everything is exported from svelte-audio-renderer. The rest is plain Web Audio.
setAudioContext
function setAudioContext(create: () => BaseAudioContext): voidGives the audio components below this component a context. create is called once, by
the first audio component that needs it, so a page that calls it stays safe to server-render. Call
it during component initialisation, like setContext.
getAudioContext
function getAudioContext(): BaseAudioContextReturns the context in any component below setAudioContext, creating it on first use.
It throws if no parent called setAudioContext.
audioNode
function audioNode<T extends AudioNode>(
callback: (node: T) => void | (() => void)
): AttachmentAn attachment for {@attach} that calls callback with the element's
real AudioNode. A function it returns runs when the element is removed. See Direct node access.
createRoot
function createRoot(options: { context: BaseAudioContext }): TreeNodeA target for mount(), without a page. Its children connect to the context's destination. See Offline rendering.
renderer
import renderer from 'svelte-audio-renderer';
import { renderer } from 'svelte-audio-renderer';The renderer itself, for mount(Component, { renderer, target }). It is also the
default export, which customRenderer="svelte-audio-renderer" uses.
Types
import type {
AudioElements,
NodeAttributes,
SourceAttributes,
ConnectionAttributes,
ScheduleAttributes,
TreeNode
} from 'svelte-audio-renderer';AudioElements: every tag and its attributes, used bysvelte-check.NodeAttributes<T>: the attributes of a node type.SourceAttributes<T>: a source's attributes, withstartandstop.ConnectionAttributes:param,outputandinput.ScheduleAttributes:startandstop.TreeNode: an element in the renderer's tree.