Skip to content

EZ Web Audio / getAudioContext

Function: getAudioContext()

getAudioContext(): Promise<AudioContext>

Defined in: index.ts:117

Get the shared AudioContext instance, creating it lazily if it doesn't exist.

The library uses a single AudioContext instance for all audio operations. This function creates the context automatically on first call.

Returns

Promise<AudioContext>

The shared AudioContext instance

Example

typescript
import { getAudioContext } from 'ez-web-audio'

// Get the AudioContext for custom Web Audio operations
const ctx = await getAudioContext()
const oscillator = ctx.createOscillator()