Skip to content

EZ Web Audio / createSounds

Function: createSounds()

Call Signature

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

Defined in: packages/core/src/index.ts:526

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<BaseSoundEventMap>[]>

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}`)
)

Call Signature

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

Defined in: packages/core/src/index.ts:530

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

audioContext

BaseAudioContext

urls

string[]

Array of audio file URLs to load

onProgress?

(loaded, total, url) => void

Optional callback fired after each sound loads

Returns

Promise<Sound<BaseSoundEventMap>[]>

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}`)
)