Skip to content

EZ Web Audio / createWhiteNoise

Function: createWhiteNoise()

createWhiteNoise(): Promise<Sound>

Defined in: index.ts:484

Create a Sound containing white noise.

White noise is useful for sound effects (rain, static, wind) and as a synthesis building block when combined with filters.

Returns

Promise<Sound>

Promise resolving to a Sound containing 1 second of white noise

Example

typescript
import { createWhiteNoise, createFilterEffect } from 'ez-web-audio'

// Create white noise
const noise = await createWhiteNoise()
noise.play()

// Filter white noise to create wind-like sound
const wind = await createWhiteNoise()
const lowpass = createFilterEffect(await getAudioContext(), 'lowpass', {
  frequency: 400
})
wind.addEffect(lowpass)
wind.play()