Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class OscillatorNode

  1. Object
  2. AudioNode
  3. AudioScheduledSourceNode
  4. OscillatorNode

A band-limited periodic waveform, the Web Audio OscillatorNode. Mono.

OfflineAudioContext audio = new OfflineAudioContext(2, 44100, 44100);
OscillatorNode osc = audio.createOscillator();
osc.setType(OscillatorType.SAWTOOTH);
osc.getFrequency().setValue(220);
osc.connect(audio.getDestination());
osc.start();
osc.stop(audio.getCurrentTime() + 1);

Methods

public AudioParam getFrequency()The frequency in Hz, 440 by default; an audio rate parameter.
public AudioParam getDetune()A detune in cents applied on top of the frequency, 0 by default; an audio rate parameter.
public OscillatorType getType()The waveform.
public void setType(OscillatorType type)Selects a standard waveform.
public void setPeriodicWave(PeriodicWave wave)Plays a custom waveform; the type becomes CUSTOM.

Inherited methods

Method details

getFrequency

public AudioParam getFrequency()
The frequency in Hz, 440 by default; an audio rate parameter.

Returns

the parameter

getDetune

public AudioParam getDetune()
A detune in cents applied on top of the frequency, 0 by default; an audio rate parameter.

Returns

the parameter

getType

public OscillatorType getType()
The waveform.

Returns

the type, CUSTOM after setPeriodicWave(PeriodicWave)

setType

public void setType(OscillatorType type)
Selects a standard waveform.

Parameters

type OscillatorType
any type but CUSTOM

setPeriodicWave

public void setPeriodicWave(PeriodicWave wave)
Plays a custom waveform; the type becomes CUSTOM.

Parameters

wave PeriodicWave
the waveform