Class OscillatorNode


public final class OscillatorNode extends AudioScheduledSourceNode

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);
  • 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: any type but CUSTOM
      Throws
    • setPeriodicWave

      public void setPeriodicWave(PeriodicWave wave)

      Plays a custom waveform; the type becomes CUSTOM.

      Parameters
      • wave: the waveform