EZ Web Audio / OscillatorOptions
Interface: OscillatorOptions
Defined in: oscillator.ts:43
Configuration options for creating an Oscillator.
Example
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?
optionalallpass:OscillatorFilterOptions
Defined in: oscillator.ts:69
Allpass filter - shifts phase without changing amplitude.
bandpass?
optionalbandpass:OscillatorFilterOptions
Defined in: oscillator.ts:57
Bandpass filter - allows frequencies near cutoff, attenuates others.
detune?
optionaldetune:number
Defined in: oscillator.ts:49
Detune in cents (100 cents = 1 semitone).
envelope?
optionalenvelope:EnvelopeOptions
Defined in: oscillator.ts:71
ADSR envelope for amplitude shaping.
frequency?
optionalfrequency:number
Defined in: oscillator.ts:47
Base frequency in Hz (default: 440).
gain?
optionalgain:number
Defined in: oscillator.ts:51
Initial gain/volume (0-1).
highpass?
optionalhighpass:OscillatorFilterOptions
Defined in: oscillator.ts:55
Highpass filter - removes frequencies below cutoff.
highshelf?
optionalhighshelf:OscillatorFilterOptions
Defined in: oscillator.ts:63
Highshelf filter - boosts/cuts frequencies above cutoff.
lowpass?
optionallowpass:OscillatorFilterOptions
Defined in: oscillator.ts:59
Lowpass filter - removes frequencies above cutoff.
lowshelf?
optionallowshelf:OscillatorFilterOptions
Defined in: oscillator.ts:61
Lowshelf filter - boosts/cuts frequencies below cutoff.
name?
optionalname: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?
optionalnotch:OscillatorFilterOptions
Defined in: oscillator.ts:67
Notch filter - attenuates frequencies at cutoff.
peaking?
optionalpeaking:OscillatorFilterOptions
Defined in: oscillator.ts:65
Peaking filter - boosts/cuts frequencies around cutoff.
setTimeout()?
optionalsetTimeout: (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?
optionalstartOffset:number
Defined in: oscillator.ts:45
Starting offset in seconds (rarely used for oscillators).
type?
optionaltype:OscillatorType
Defined in: oscillator.ts:53
Waveform type: 'sine', 'square', 'sawtooth', or 'triangle'.