Skip to content
Tone.js

Noise

class Source ↳ extends Source<NoiseOptions>

Noise is a noise generator. It uses looped noise buffers to save on performance. Noise supports the noise types: “pink”, “white”, and “brown”. Read more about colors of noise on Wikipedia.

// initialize the noise and start
const noise = new Tone.Noise("pink").start();
// make an autofilter to shape the noise
const autoFilter = new Tone.AutoFilter({
	frequency: "8n",
	baseFrequency: 200,
	octaves: 8
}).toDestination().start();
// connect the noise
noise.connect(autoFilter);
// start the autofilter LFO
autoFilter.start();
new Noise(type?: NoiseType)

Parameters

  • type NoiseType optional

    the noise type (white|pink|brown)

new Noise(options?: Partial<NoiseOptions>)

Parameters

↳ inherited from Source

input: undefined

Sources have no inputs

Default: undefined

read-only

name: string

The name of the class

Default: "Noise"

↳ inherited from Source

The callback to invoke when the source is stopped.

↳ inherited from Source

output: OutputNode

The output node

↳ inherited from Source

volume: Param<"decibels">

The volume of the output in decibels.

const source = new Tone.PWMOscillator().toDestination();
source.volume.value = -6;
fadeIn: Time

The fadeIn time of the amplitude envelope.

fadeOut: Time

The fadeOut time of the amplitude envelope.

↳ inherited from Source

mute: boolean

Mute the output.

const osc = new Tone.Oscillator().toDestination().start();
// mute the output
osc.mute = true;
playbackRate: number

The playback rate of the noise. Affects the “frequency” of the noise.

read-only ↳ inherited from Source

Returns the playback state of the source, either “started” or “stopped”.

const player = new Tone.Player("https://tonejs.github.io/audio/berklee/ahntone_c3.mp3", () => {
	player.start();
	console.log(player.state);
}).toDestination();
type: NoiseType

The type of the noise. Can be “white”, “brown”, or “pink”.

const noise = new Tone.Noise().toDestination().start();
noise.type = "brown";
dispose(): this

Clean up.

Returns this

↳ inherited from Source

restart(time?: Time, offset?: Time, duration?: Time): this

Restart the source.

Parameters

  • time Time optional
  • offset Time optional
  • duration Time optional

Returns this

↳ inherited from Source

start(time?: Time, offset?: Time, duration?: Time): this

Start the source at the specified time. If no time is given, start the source now.

const source = new Tone.Oscillator().toDestination();
source.start("+0.5"); // starts the source 0.5 seconds from now

Parameters

  • time Time optional

    When the source should be started.

  • offset Time optional

  • duration Time optional

Returns this

↳ inherited from Source

stop(time?: Time): this

Stop the source at the specified time. If no time is given, stop the source now.

const source = new Tone.Oscillator().toDestination();
source.start();
source.stop("+0.5"); // stops the source 0.5 seconds from now

Parameters

  • time Time optional

    When the source should be stopped.

Returns this

↳ inherited from Source

sync(): this

Sync the source to the Transport so that all subsequent calls to start and stop are synced to the TransportTime instead of the AudioContext time.

const osc = new Tone.Oscillator().toDestination();
// sync the source so that it plays between 0 and 0.3 on the Transport's timeline
osc.sync().start(0).stop(0.3);
// start the transport.
Tone.Transport.start();
// set it to loop once a second
Tone.Transport.loop = true;
Tone.Transport.loopEnd = 1;

Returns this

↳ inherited from Source

unsync(): this

Unsync the source to the Transport.

See also: sync

Returns this

static

getDefaults(): NoiseOptions

Returns all of the default options belonging to the class.

Returns NoiseOptions