Skip to content
Josh Stovall edited this page Dec 21, 2020 · 1 revision

Welcome to the synth.js wiki!

Oscillator()

create an oscillator

var oscillator = new Oscillator({
	frequency: 440,
	gain: 0.5,
});

Attributes

Oscillator

attribute type options description
type string sine square sawtooth triangle shape of waveform
frequency float 120 set the frequency (in hertz)
gain float 0 to 1 set gain (volume)

Functions

setFrequency(Hz)

set the frequency

// create an oscillator at 440 Hz
var osc = new Oscillator({
	frequency: 440,
});

// change frequency to 200 Hz
osc.setFrequency(200);

GetFrequency()

returns the current frequency

// create an oscillator at 440 Hz
var osc = new Oscillator({ frequency: 440, });

// change frequency to 200 Hz
osc.getFrequency();
// ==> 440

hz()

set or get frequency

if blank, it will return the current frequency

osc.hz();
// 440

or pass a value to set the frequency

osc.hz(200);

Ramp()

smoothly ramp a value

 new Ramp({
   at: osc,
   gain: 0.1,
   frequency: 600,
   duration: 2000
});

Parameters

Name Type Options Default Description
type string absolue relative 0
at object or array object to apply the ramp
repeat int 0 number of times to repeat
yoyo bool false repeat animation yoyo style
delay int 0 on-set delay (ms)
ease string back bounce circ cubic elastic exponential linear quad quart quint sine linear ease type
direction string in out inout intout ease direction
gain float null end gain
frequency float null end frequency
Clone this wiki locally