Skip to content

EZ Web Audio / createSounds

Function: createSounds()

createSounds(urls, onProgress?): Promise<Sound[]>

Defined in: index.ts:241

Load multiple sounds from an array of URLs with optional progress tracking.

Loads all sounds in parallel for speed. Progress callback fires after each sound finishes loading, providing loaded count, total count, and the URL that just completed.

Parameters

urls

string[]

Array of audio file URLs to load

onProgress?

(loaded, total, url) => void

Optional callback fired after each sound loads

Returns

Promise<Sound[]>

Promise resolving to array of Sound instances

Throws

If any audio file cannot be loaded or decoded

Example

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

const sounds = await createSounds(
  ['click.mp3', 'whoosh.mp3', 'ding.mp3'],
  (loaded, total, url) => console.log(`Loaded ${loaded}/${total}: ${url}`)
)