Synthlet
Audio Sources

Noise

Noise

@synthlet/noise

A Noise generator. Currently white and pink noise are supported.

import { registerNoiseWorklet, Noise, NoiseType } from "synthlet";
 
const audioContext = new AudioContext();
await registerNoiseWorklet(audioContext);
 
const noise = Noise(audioContext, {
  type: NoiseType.White,
});
noise.connect(audioContext.destination);
 
// Change the algorithm
noise.type.value = NoiseType.Pink;

Parameters

  • type: The type of noise to generate. Can be one of:
    • 0 NoiseType.White: White noise that uses Math.rand for random numbers.
    • 10: NoiseType.Pink: Pink noise based on this Larry Trammel algorithm

Since type is an audio param, any arbitrary value can be used, but only the above values are valid. If you suply an invalid value, a warning will be printed and the noise will default to white random.

References

On this page