Skip to content
Tone.js

ToneOscillatorNode

class Source ↳ extends OneShotSource<ToneOscillatorNodeOptions>

Wrapper around the native fire-and-forget OscillatorNode. Adds the ability to reschedule the stop method. Oscillator is better for most use-cases

new ToneOscillatorNode(frequency: Frequency, type: OscillatorType)

Parameters

  • frequency Frequency

    The frequency value

  • type OscillatorType

    The basic oscillator type

new ToneOscillatorNode(options?: Partial<ToneOscillatorNodeOptions>)

Parameters

read-only

detune: Param<"cents">

The detune of the oscillator

read-only

frequency: Param<"frequency">

The frequency of the oscillator

↳ inherited from OneShotSource

input: undefined

Sources do not have input nodes

read-only

name: string

The name of the class

Default: "ToneOscillatorNode"

↳ inherited from OneShotSource

The callback to invoke after the source is done playing.

Default: noOp

↳ inherited from OneShotSource

output: Gain

The public output node

read-only ↳ inherited from OneShotSource

Get the playback state at the current time

type: OscillatorType

The oscillator type. Either ‘sine’, ‘sawtooth’, ‘square’, or ‘triangle’

↳ inherited from OneShotSource

cancelStop(): this

Cancel a scheduled stop event

Returns this

dispose(): this

Clean up.

Returns this

↳ inherited from OneShotSource

getStateAtTime(time: Time): BasicPlaybackState

Get the playback state at the given time

Parameters

Returns BasicPlaybackState

setPeriodicWave(periodicWave: PeriodicWave): this

Sets an arbitrary custom periodic waveform given a PeriodicWave.

Parameters

  • periodicWave PeriodicWave

    PeriodicWave should be created with context.createPeriodicWave

Returns this

start(time?: Time): this

Start the oscillator node at the given time

Parameters

  • time Time optional

    When to start the oscillator

Returns this

↳ inherited from OneShotSource

stop(time?: Time): this

Stop the source node at the given time.

Parameters

  • time Time optional

    When to stop the source

Returns this

static

Returns all of the default options belonging to the class.

Returns ToneOscillatorNodeOptions