EZ Web Audio / OscillatorOptions
Interface: OscillatorOptions
Defined in: packages/core/src/oscillator.ts:46
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: packages/core/src/oscillator.ts:84
Allpass filter - shifts phase without changing amplitude.
bandpass?
optionalbandpass:OscillatorFilterOptions
Defined in: packages/core/src/oscillator.ts:72
Bandpass filter - allows frequencies near cutoff, attenuates others.
clearTimeout()?
optionalclearTimeout: (id) =>void
Defined in: packages/core/src/base-sound.ts:45
Custom clearTimeout implementation.
Must match the setTimeout implementation. By default, the AudioContext-aware clearTimeout is used.
Parameters
id
number
Timeout ID returned by setTimeout
Returns
void
Inherited from
BaseSoundOptions.clearTimeout
detune?
optionaldetune:number
Defined in: packages/core/src/oscillator.ts:64
Detune in cents (100 cents = 1 semitone).
envelope?
optionalenvelope:EnvelopeOptions
Defined in: packages/core/src/oscillator.ts:86
ADSR envelope for amplitude shaping.
frequency?
optionalfrequency:number
Defined in: packages/core/src/oscillator.ts:62
Base frequency in Hz (default: 440).
gain?
optionalgain:number
Defined in: packages/core/src/oscillator.ts:66
Initial gain/volume (0-1).
highpass?
optionalhighpass:OscillatorFilterOptions
Defined in: packages/core/src/oscillator.ts:70
Highpass filter - removes frequencies below cutoff.
highshelf?
optionalhighshelf:OscillatorFilterOptions
Defined in: packages/core/src/oscillator.ts:78
Highshelf filter - boosts/cuts frequencies above cutoff.
lowpass?
optionallowpass:OscillatorFilterOptions
Defined in: packages/core/src/oscillator.ts:74
Lowpass filter - removes frequencies above cutoff.
lowshelf?
optionallowshelf:OscillatorFilterOptions
Defined in: packages/core/src/oscillator.ts:76
Lowshelf filter - boosts/cuts frequencies below cutoff.
name?
optionalname:string
Defined in: packages/core/src/base-sound.ts:23
Optional name for identifying this sound instance. Useful for debugging and when managing multiple sounds.
Inherited from
BaseSoundOptions.name
notch?
optionalnotch:OscillatorFilterOptions
Defined in: packages/core/src/oscillator.ts:82
Notch filter - attenuates frequencies at cutoff.
note?
optionalnote:string
Defined in: packages/core/src/oscillator.ts:60
Note name (e.g., 'A4', 'C3', 'Eb5'). Looked up in the frequency map. Takes precedence over frequency if both provided. Both flat (Db, Eb, Gb, Ab, Bb) and sharp (C#, D#, F#, G#, A#) notation are supported as enharmonic equivalents.
Example
// Play middle C
const osc = await createOscillator({ note: 'C4', type: 'sine' })peaking?
optionalpeaking:OscillatorFilterOptions
Defined in: packages/core/src/oscillator.ts:80
Peaking filter - boosts/cuts frequencies around cutoff.
setTimeout()?
optionalsetTimeout: (fn,delayMillis) =>number
Defined in: packages/core/src/base-sound.ts:35
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: packages/core/src/oscillator.ts:48
Starting offset in seconds (rarely used for oscillators).
type?
optionaltype:OscillatorType
Defined in: packages/core/src/oscillator.ts:68
Waveform type: 'sine', 'square', 'sawtooth', or 'triangle'.