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
Constructor
Section titled “Constructor”new ToneOscillatorNode(frequency: Frequency, type: OscillatorType)Parameters
-
frequency
FrequencyThe frequency value
-
type
OscillatorTypeThe basic oscillator type
new ToneOscillatorNode(options?: Partial<ToneOscillatorNodeOptions>)Parameters
- options
Partial<ToneOscillatorNodeOptions>optional
Properties
Section titled “Properties”frequency
Section titled “frequency”read-only
frequency: Param<"frequency">The frequency of the oscillator
read-only
name: stringThe name of the class
Default: "ToneOscillatorNode"
onended
Section titled “onended”↳ inherited from OneShotSource
onended: onEndedCallbackThe callback to invoke after the source is done playing.
Default: noOp
read-only ↳ inherited from OneShotSource
state: BasicPlaybackStateGet the playback state at the current time
type: OscillatorTypeThe oscillator type. Either ‘sine’, ‘sawtooth’, ‘square’, or ‘triangle’
Methods
Section titled “Methods”cancelStop()
Section titled “cancelStop()”↳ inherited from OneShotSource
cancelStop(): thisCancel a scheduled stop event
Returns this
getStateAtTime()
Section titled “getStateAtTime()”↳ inherited from OneShotSource
getStateAtTime(time: Time): BasicPlaybackStateGet the playback state at the given time
Parameters
- time
Time
Returns BasicPlaybackState
setPeriodicWave()
Section titled “setPeriodicWave()”setPeriodicWave(periodicWave: PeriodicWave): thisSets an arbitrary custom periodic waveform given a PeriodicWave.
Parameters
-
periodicWave
PeriodicWavePeriodicWave should be created with context.createPeriodicWave
Returns this
start()
Section titled “start()”start(time?: Time): thisStart the oscillator node at the given time
Parameters
-
time
TimeoptionalWhen to start the oscillator
Returns this
stop()
Section titled “stop()”↳ inherited from OneShotSource
stop(time?: Time): thisStop the source node at the given time.
Parameters
-
time
TimeoptionalWhen to stop the source
Returns this
getDefaults()
Section titled “getDefaults()”static
getDefaults(): ToneOscillatorNodeOptionsReturns all of the default options belonging to the class.
Returns ToneOscillatorNodeOptions
Inherited members
Section titled “Inherited members”- From
ToneWithContext: context, blockTime, sampleTime, get(), immediate(), now(), set(), toFrequency(), toSeconds(), toTicks() - From
Tone: debug, version, disposed, toString() - From
ToneAudioNode: channelCount, channelCountMode, channelInterpretation, numberOfInputs, numberOfOutputs, chain(), connect(), disconnect(), fan(), toDestination(), toMaster()