JavaScripture
Contribute via GitHub Feedback

JavaScript OscillatorNode : AudioNode

OscillatorNode is an audio source that generates a periodic waveform such as a sine, triangle, sawtooth, or square wave (specified by the type property. Created by audioContext.createOscillator().

Instance Properties

detune : AudioParam  

A detuning value to alter the effective frequency (detune is specified in Cents). The default value is 0. This is combined with frequency to produce the effective frequency using the equation: effectiveFrequency = frequency * pow(2, detune / 1200).

Example:

Run

Results:

 

frequency : AudioParam  

The frequency of the wave (in Hertz). The default value is 440. This is combined with detune to produce the effective frequency using the equation: effectiveFrequency = frequency * pow(2, detune / 1200).

Example:

Run

Results:

 

type : String

The type of wave generated by this. Can be set to one of 'sine', 'square', 'sawtooth', or 'triangle'. When using setPeriodicWave() to define the waveform, type will be set to 'custom'.

Example:

Run

Results:

 

Instance Methods

setPeriodicWave(periodicWave : PeriodicWave) : undefined

Sets the shape of the waveform.

Example:

Run

Results:

 

start(when : Number) : undefined

stop(when : Number) : undefined

Instance Events

onended / 'ended'  
listener(event : Event) : undefined