Skip to content

EZ Web Audio / OscillatorOptions

Interface: OscillatorOptions

Defined in: oscillator.ts:43

Configuration options for creating an Oscillator.

Example

typescript
const opts: OscillatorOptions = {
  frequency: 440,      // A4
  type: 'sawtooth',    // Rich harmonic content
  gain: 0.5,           // Half volume
  lowpass: {           // Filter out harsh highs
    frequency: 2000,
    q: 1
  },
  envelope: {          // ADSR for note shaping
    attack: 0.01,
    decay: 0.2,
    sustain: 0.5,
    release: 0.3
  }
}

Extends

  • BaseSoundOptions

Properties

allpass?

optional allpass: OscillatorFilterOptions

Defined in: oscillator.ts:69

Allpass filter - shifts phase without changing amplitude.


bandpass?

optional bandpass: OscillatorFilterOptions

Defined in: oscillator.ts:57

Bandpass filter - allows frequencies near cutoff, attenuates others.


detune?

optional detune: number

Defined in: oscillator.ts:49

Detune in cents (100 cents = 1 semitone).


envelope?

optional envelope: EnvelopeOptions

Defined in: oscillator.ts:71

ADSR envelope for amplitude shaping.


frequency?

optional frequency: number

Defined in: oscillator.ts:47

Base frequency in Hz (default: 440).


gain?

optional gain: number

Defined in: oscillator.ts:51

Initial gain/volume (0-1).


highpass?

optional highpass: OscillatorFilterOptions

Defined in: oscillator.ts:55

Highpass filter - removes frequencies below cutoff.


highshelf?

optional highshelf: OscillatorFilterOptions

Defined in: oscillator.ts:63

Highshelf filter - boosts/cuts frequencies above cutoff.


lowpass?

optional lowpass: OscillatorFilterOptions

Defined in: oscillator.ts:59

Lowpass filter - removes frequencies above cutoff.


lowshelf?

optional lowshelf: OscillatorFilterOptions

Defined in: oscillator.ts:61

Lowshelf filter - boosts/cuts frequencies below cutoff.


name?

optional name: string

Defined in: base-sound.ts:19

Optional name for identifying this sound instance. Useful for debugging and when managing multiple sounds.

Inherited from

BaseSoundOptions.name


notch?

optional notch: OscillatorFilterOptions

Defined in: oscillator.ts:67

Notch filter - attenuates frequencies at cutoff.


peaking?

optional peaking: OscillatorFilterOptions

Defined in: oscillator.ts:65

Peaking filter - boosts/cuts frequencies around cutoff.


setTimeout()?

optional setTimeout: (fn, delayMillis) => number

Defined in: base-sound.ts:31

Custom setTimeout implementation.

By default, an AudioContext-aware setTimeout is used that compensates for browser throttling. Override this if you need different timing behavior.

Parameters

fn

() => void

Function to call after delay

delayMillis

number

Delay in milliseconds

Returns

number

Timeout ID for cancellation

Inherited from

BaseSoundOptions.setTimeout


startOffset?

optional startOffset: number

Defined in: oscillator.ts:45

Starting offset in seconds (rarely used for oscillators).


type?

optional type: OscillatorType

Defined in: oscillator.ts:53

Waveform type: 'sine', 'square', 'sawtooth', or 'triangle'.