EZ Web Audio / Oscillator
Class: Oscillator
Defined in: packages/core/src/oscillator.ts:137
Synthesizer that generates audio from oscillator waveforms.
Oscillator creates sound from scratch using sine, square, sawtooth, or triangle waves. Supports ADSR envelopes for professional-quality synthesis, filters for tone shaping, and all the gain/pan controls from BaseSound.
Unlike Sound which plays pre-recorded audio, Oscillator generates audio in real-time. Oscillators have infinite duration and must be explicitly stopped.
Example
import { createOscillator } from 'ez-web-audio'
// Simple sine wave at 440Hz (A4)
const synth = await createOscillator({ frequency: 440, type: 'sine' })
synth.play()
setTimeout(() => synth.stop(), 500)
// With ADSR envelope for piano-like decay
const piano = await createOscillator({
frequency: 440,
type: 'triangle',
envelope: { attack: 0.01, decay: 0.1, sustain: 0.7, release: 0.3 }
})
piano.play()
setTimeout(() => piano.stop(), 500) // Release phase plays after stop
// With lowpass filter
const muted = await createOscillator({
frequency: 440,
type: 'sawtooth',
lowpass: { frequency: 800, q: 1 }
})
muted.play()Extends
BaseSound
Constructors
Constructor
new Oscillator(
audioContext,options?):Oscillator
Defined in: packages/core/src/oscillator.ts:184
Create an Oscillator instance.
Note: Use createOscillator factory function instead of calling this directly.
Parameters
audioContext
AudioContext
The AudioContext to use for audio operations
options?
Oscillator configuration (frequency, type, filters, envelope)
Returns
Oscillator
Overrides
BaseSound.constructor
Properties
_analyzer
protected_analyzer:Analyzer|null=null
Defined in: packages/core/src/base-sound.ts:161
Inherited from
_destination
protected_destination:AudioNode
Defined in: packages/core/src/base-sound.ts:154
Inherited from
_isPlaying
protected_isPlaying:boolean=false
Defined in: packages/core/src/base-sound.ts:84
Inherited from
_targetGain
protected_targetGain:number=1
Defined in: packages/core/src/base-sound.ts:107
The user's intended gain level (0–1). Tracks the last value set via changeGainTo() / volume setter so that gain can be restored after a fadeOut() or Oscillator anti-click stop that ramps gainNode.gain to 0.
Inherited from
audioContext
readonlyaudioContext:AudioContext
Defined in: packages/core/src/base-sound.ts:218
Inherited from
audioSourceNode
audioSourceNode:
OscillatorNode
Defined in: packages/core/src/oscillator.ts:139
The underlying OscillatorNode that generates the audio signal.
Overrides
BaseSound.audioSourceNode
clearTimeout()
protectedclearTimeout: (id) =>void
Defined in: packages/core/src/base-sound.ts:97
Parameters
id
number
Returns
void
Inherited from
BaseSound.clearTimeout
controller
protectedcontroller:OscillatorController
Defined in: packages/core/src/oscillator.ts:151
Controller for managing gain, pan, frequency, and detune parameters.
Overrides
BaseSound.controller
debug?
optionaldebug:boolean
Defined in: packages/core/src/base-sound.ts:216
Default
undefined (follows global debug mode)Example
sound.debug = true // enable debug for this sound
sound.debug = false // silence this sound even when global debug is onInherited from
effectChainInput
protectedeffectChainInput:GainNode
Defined in: packages/core/src/base-sound.ts:147
Inherited from
effects
protectedeffects:Effect[] =[]
Defined in: packages/core/src/base-sound.ts:140
Inherited from
freq
protectedfreq:number
Defined in: packages/core/src/oscillator.ts:148
Base frequency in Hz.
gainNode
protectedgainNode:GainNode
Defined in: packages/core/src/base-sound.ts:93
The GainNode controlling this sound's volume.
For simple volume control, use changeGainTo() or update('gain'). For advanced routing, use getGainNode().
Inherited from
name
name:
string
Defined in: packages/core/src/base-sound.ts:202
Inherited from
pannerNode
protectedpannerNode:StereoPannerNode
Defined in: packages/core/src/base-sound.ts:95
Inherited from
setTimeout()
protectedsetTimeout: (fn,delayMillis) =>number
Defined in: packages/core/src/base-sound.ts:96
Parameters
fn
() => void
delayMillis
number
Returns
number
Inherited from
BaseSound.setTimeout
startedPlayingAt
protectedstartedPlayingAt:number=0
Defined in: packages/core/src/base-sound.ts:99
Inherited from
startOffset
protectedstartOffset:number=0
Defined in: packages/core/src/base-sound.ts:170
Offset in seconds from the beginning of the audio buffer where playback starts. Used internally by Track for seek/resume functionality.
Default
0See
https://developer.mozilla.org/en-US/docs/Web/API/AudioScheduledSourceNode/start
Inherited from
Accessors
_isLooping
Get Signature
get
protected_isLooping():boolean
Defined in: packages/core/src/base-sound.ts:1183
Protected getter for looping state. Override in subclasses that support looping. Used by playAt() to skip the duration timeout when looping is active.
Returns
boolean
Inherited from
BaseSound._isLooping
disposed
Get Signature
get disposed():
boolean
Defined in: packages/core/src/base-sound.ts:1174
Whether this instance has been disposed.
Once disposed, the instance cannot be used for playback. Create a new instance if you need to play the sound again.
Example
sound.dispose()
console.log(sound.disposed) // trueReturns
boolean
Inherited from
duration
Get Signature
get duration():
TimeObject
Defined in: packages/core/src/oscillator.ts:543
Get the duration of the oscillator.
Oscillators have no inherent duration - they play indefinitely until stopped. Returns Infinity to indicate continuous playback, distinguishing from finite Sound/Track durations.
Example
const osc = await createOscillator({ frequency: 440 })
console.log(osc.duration.raw) // Infinity
// Oscillators must be explicitly stopped
osc.play()
setTimeout(() => osc.stop(), 1000)Returns
Overrides
BaseSound.duration
durationRaw
Get Signature
get durationRaw():
number
Defined in: packages/core/src/oscillator.ts:522
Get the duration in seconds without allocating a TimeObject. Oscillators have infinite duration.
Returns
number
Overrides
BaseSound.durationRaw
isPlaying
Get Signature
get isPlaying():
boolean
Defined in: packages/core/src/base-sound.ts:1115
Whether the sound is currently playing.
Example
if (sound.isPlaying) {
await sound.stop()
}Returns
boolean
Inherited from
percentGain
Get Signature
get percentGain():
number
Defined in: packages/core/src/base-sound.ts:1127
Current gain as a percentage (0-100).
Example
console.log(`Volume: ${sound.percentGain}%`) // "Volume: 50%"Returns
number
Inherited from
volume
Get Signature
get volume():
number
Defined in: packages/core/src/base-sound.ts:1150
Alias for gain. Get/set the volume (0 = silent, 1 = full volume).
Values above 1 amplify the signal and may cause distortion. The setter delegates to changeGainTo(), which throws if the value is negative and warns if it exceeds 1.
Inherited by Sound, Track, and Oscillator.
Example
sound.volume = 0.5 // set to half volume
console.log(sound.volume) // 0.5
// Works on all BaseSound subclasses
const osc = await createOscillator()
osc.volume = 0.8Returns
number
Set Signature
set volume(
value):void
Defined in: packages/core/src/base-sound.ts:1154
Parameters
value
number
Returns
void
Inherited from
BaseSound.volume
Methods
_clearListeners()
protected_clearListeners():void
Defined in: packages/core/src/events/typed-event-emitter.ts:192
Remove every listener registered through this emitter (via addEventListener(), on(), or once()), regardless of how many or what event type they're bound to.
Native EventTarget has no removeAllListeners(). This works around that by aborting a shared AbortSignal threaded through every addEventListener() call this class makes, then swapping in a fresh AbortController so the instance can keep accepting new listeners afterward (e.g. if it's reused before being garbage collected).
Subclasses call this from their dispose() alongside neutering dispatchEvent — the neuter stops future emits, this stops stale listener closures from being retained/invoked at all.
Returns
void
Inherited from
BaseSound._clearListeners
_onPlaybackStarted()
protected_onPlaybackStarted():void
Defined in: packages/core/src/base-sound.ts:1000
Hook method called after playback starts. Override in subclasses to add behavior that runs for all play variants.
Returns
void
Inherited from
BaseSound._onPlaybackStarted
addEffect()
addEffect(
effect,position?):this
Defined in: packages/core/src/base-sound.ts:401
Add an effect to the effect chain. Effects persist across multiple play() calls.
Parameters
effect
The Effect instance to add
position?
number
Optional index to insert at (defaults to end of chain)
Returns
this
this for chaining
Example
const filter = createFilterEffect('lowpass', { frequency: 1000 })
sound.addEffect(filter)Inherited from
BaseSound.addEffect
addEffects()
addEffects(
effects,position?):this
Defined in: packages/core/src/base-sound.ts:471
Add multiple effects to the effect chain in one call. The chain is rewired only once after all effects are added, which is more efficient than calling addEffect() multiple times.
Parameters
effects
Effect[]
Array of Effect instances to add
position?
number
Optional index to insert at (defaults to end of chain)
Returns
this
this for chaining
Example
const filter = createFilterEffect('lowpass', { frequency: 800 })
const boost = createGainEffect(1.5)
sound.addEffects([filter, boost])Inherited from
BaseSound.addEffects
addEventListener()
Call Signature
addEventListener<
K>(type,listener,options?):void
Defined in: packages/core/src/events/typed-event-emitter.ts:44
Add a typed event listener for known event types. Overloaded to provide type safety for known event types while remaining compatible with the native EventTarget API.
Type Parameters
K
K extends "play" | "dispose" | "stop" | "end"
Parameters
type
K
The event type (key of TMap)
listener
(event) => void
Typed event handler
options?
Standard addEventListener options
boolean | AddEventListenerOptions
Returns
void
Inherited from
BaseSound.addEventListener
Call Signature
addEventListener(
type,listener,options?):void
Defined in: packages/core/src/events/typed-event-emitter.ts:49
Add a typed event listener for known event types. Overloaded to provide type safety for known event types while remaining compatible with the native EventTarget API.
Parameters
type
string
The event type (key of TMap)
listener
Typed event handler
EventListenerOrEventListenerObject | null
options?
Standard addEventListener options
boolean | AddEventListenerOptions
Returns
void
Inherited from
BaseSound.addEventListener
changeGainTo()
changeGainTo(
value):this
Defined in: packages/core/src/base-sound.ts:693
Set the gain (volume) immediately.
Convenience method for update('gain').to(value).as('ratio').
Parameters
value
number
Gain from 0 (silent) to 1 (full volume)
Returns
this
this for chaining
Example
sound.changeGainTo(0.5) // Half volume
sound.changeGainTo(0) // Muted
sound.changeGainTo(1) // Full volumeInherited from
BaseSound.changeGainTo
changePanTo()
changePanTo(
value):this
Defined in: packages/core/src/base-sound.ts:670
Set the pan position immediately.
Convenience method for update('pan').to(value).as('ratio').
Parameters
value
number
Pan position from -1 (left) to 1 (right), 0 is center
Returns
this
this for chaining
Example
sound.changePanTo(-1) // Hard left
sound.changePanTo(0) // Center
sound.changePanTo(1) // Hard rightInherited from
BaseSound.changePanTo
dispose()
dispose():
void
Defined in: packages/core/src/base-sound.ts:1270
Dispose this sound instance, releasing all audio resources.
Disconnects all audio nodes, clears the effect chain, cancels pending timeouts, and marks the instance as unusable. After disposing, calling play() will throw an error.
Dispose is idempotent — calling it multiple times is safe.
After disposal, event listeners registered via on() / addEventListener() will no longer fire. To free listener references for garbage collection, call off() for each listener before calling dispose().
Returns
void
Example
const sound = await createSound('click.mp3')
await sound.play()
// When done with the sound
sound.dispose()
console.log(sound.disposed) // true
// Attempting to play after dispose will throw
// sound.play() // throws Error: Cannot play a disposed soundInherited from
BaseSound.dispose
emit()
protectedemit<K>(type,detail):void
Defined in: packages/core/src/events/typed-event-emitter.ts:95
Emit a typed event with the given detail.
Creates a CustomEvent with the provided detail and dispatches it on this target. Subclasses call this internally to fire lifecycle events.
Type Parameters
K
K extends "play" | "dispose" | "stop" | "end"
Parameters
type
K
The event type to emit (key of TMap)
detail
BaseSoundEventMap[K]["detail"]
The event detail object (typed by TMap)
Returns
void
Inherited from
BaseSound.emit
fadeIn()
fadeIn(
duration):Promise<void>
Defined in: packages/core/src/base-sound.ts:1202
Fade in the sound from silence to its current gain over duration seconds, then play.
Schedules a gain ramp from 0 to the current gain value and calls play(). The current gain is restored after playback — use changeGainTo() to set a target volume before calling fadeIn().
Parameters
duration
number
Fade-in duration in seconds
Returns
Promise<void>
Promise that resolves when playback begins
Example
const sound = await createSound('music.mp3')
await sound.fadeIn(2) // fade in over 2 secondsInherited from
BaseSound.fadeIn
fadeOut()
fadeOut(
duration):Promise<void>
Defined in: packages/core/src/base-sound.ts:1225
Fade out the sound from its current gain to silence over duration seconds, then stop.
If the sound is not playing, this is a no-op. Returns a Promise that resolves after the fade completes and stop() has been called.
Parameters
duration
number
Fade-out duration in seconds
Returns
Promise<void>
Promise that resolves when the fade and stop are complete
Example
const sound = await createSound('music.mp3')
await sound.play()
await sound.fadeOut(2) // fade out over 2 seconds then stopInherited from
BaseSound.fadeOut
getAnalyzer()
getAnalyzer():
Analyzer|null
Defined in: packages/core/src/base-sound.ts:578
Get the currently attached analyzer, if any.
Returns
Analyzer | null
The attached Analyzer instance, or null if none attached
Inherited from
BaseSound.getAnalyzer
getEffects()
getEffects(): readonly
Effect[]
Defined in: packages/core/src/base-sound.ts:514
Get a readonly copy of the current effects array.
Returns
readonly Effect[]
Shallow copy of the effects array
Inherited from
BaseSound.getEffects
getFilters()
getFilters(): readonly
BiquadFilterNode[]
Defined in: packages/core/src/oscillator.ts:514
Get a readonly snapshot of the oscillator's filter nodes.
Returns a shallow copy of the internal filters array so callers can inspect filter state (type, frequency, Q) without mutating the chain.
Returns
readonly BiquadFilterNode[]
Readonly array of BiquadFilterNode instances
Example
const osc = await createOscillator({
frequency: 440,
lowpass: { frequency: 800, q: 1 },
highpass: { frequency: 200 }
})
const filters = osc.getFilters()
console.log(filters.length) // 2
console.log(filters[0].type) // 'highpass'getGainNode()
getGainNode():
GainNode
Defined in: packages/core/src/base-sound.ts:597
Get the GainNode for this sound.
Provides controlled access to the underlying GainNode for advanced audio routing scenarios (e.g., crossfading between tracks). For simple volume control, use changeGainTo() or update('gain').
Returns
GainNode
The GainNode controlling this sound's volume
Example
const node = sound.getGainNode()
node.gain.linearRampToValueAtTime(0, ctx.currentTime + 2)Inherited from
BaseSound.getGainNode
getPannerNode()
getPannerNode():
StereoPannerNode
Defined in: packages/core/src/base-sound.ts:610
Get the StereoPannerNode for this sound.
Provides controlled access to the underlying StereoPannerNode for advanced audio routing scenarios (e.g., LFO modulation of pan position). For simple pan control, use changePanTo() or update('pan').
Returns
StereoPannerNode
The StereoPannerNode controlling this sound's pan position
Inherited from
BaseSound.getPannerNode
later()
protectedlater(fn):void
Defined in: packages/core/src/base-sound.ts:1158
Parameters
fn
() => void
Returns
void
Inherited from
BaseSound.later
off()
off<
K>(type,listener):this
Defined in: packages/core/src/events/typed-event-emitter.ts:167
Unsubscribe from an event.
Note: Due to native EventTarget limitations, you must provide the same listener function reference that was used when subscribing.
Type Parameters
K
K extends "play" | "dispose" | "stop" | "end"
Parameters
type
K
The event type to unsubscribe from
listener
(event) => void
The event handler function to remove
Returns
this
this for chaining
Example
const handler = (e) => console.log(e.detail)
emitter.on('play', handler)
// later...
emitter.off('play', handler)Inherited from
BaseSound.off
on()
on<
K>(type,listener):this
Defined in: packages/core/src/events/typed-event-emitter.ts:116
Subscribe to one or more events. Supports chaining.
Type Parameters
K
K extends "play" | "dispose" | "stop" | "end"
Parameters
type
The event type(s) to subscribe to (key or array of keys of TMap)
K | K[]
listener
(event) => void
The event handler function
Returns
this
this for chaining
Example
emitter.on('play', handlePlay).on('stop', handleStop)
emitter.on(['play', 'stop'], handleBoth)Inherited from
BaseSound.on
once()
once<
K>(type,listener):this
Defined in: packages/core/src/events/typed-event-emitter.ts:141
Subscribe to an event once. Handler is removed after first invocation.
Type Parameters
K
K extends "play" | "dispose" | "stop" | "end"
Parameters
type
K
The event type to subscribe to
listener
(event) => void
The event handler function
Returns
this
this for chaining
Example
emitter.once('end', () => console.log('Finished'))Inherited from
BaseSound.once
onPlayRamp()
onPlayRamp(
type,rampType?):object
Defined in: packages/core/src/oscillator.ts:311
Schedule a parameter ramp when play() is called.
Parameters
type
The parameter to ramp ('gain', 'pan', 'frequency', 'detune')
rampType?
RampType
Type of ramp curve ('linear' or 'exponential')
Returns
object
Fluent builder for setting start value, end value, and duration
from()
from: (
startValue) =>object
Parameters
startValue
number
Returns
object
to()
to: (
endValue) =>object
Parameters
endValue
number
Returns
object
in()
in: (
endTime) =>void
Parameters
endTime
number
Returns
void
Example
// Vibrato effect: ramp frequency up and down
osc.onPlayRamp('frequency', 'linear').from(440).to(450).in(0.1)
osc.play()Overrides
BaseSound.onPlayRamp
onPlaySet()
onPlaySet(
type):object
Defined in: packages/core/src/oscillator.ts:293
Schedule a parameter value to be set when play() is called.
Oscillator supports additional parameters beyond Sound:
- 'gain': Volume level (0-1)
- 'pan': Stereo position (-1 to 1)
- 'frequency': Oscillator frequency in Hz
- 'detune': Detune in cents
Parameters
type
The parameter to control
Returns
object
Fluent builder for setting value and timing
to()
to: (
value) =>object
Parameters
value
number
Returns
object
at()
at: (
time) =>void
Parameters
time
number
Returns
void
endingAt()
endingAt: (
time,rampType?) =>void
Parameters
time
number
rampType?
RampType
Returns
void
Example
// Start at frequency 220, glide up to 440 over 0.5 seconds
osc.onPlaySet('frequency').to(220).at(0)
osc.onPlaySet('frequency').to(440).endingAt(0.5, 'linear')
osc.play()Overrides
BaseSound.onPlaySet
play()
play():
Promise<void>
Defined in: packages/core/src/base-sound.ts:819
Play the sound immediately.
Resumes the AudioContext if suspended, sets up the audio source, and starts playback. For finite-duration sounds (Sound, Track), automatically schedules an 'end' event when playback completes.
Returns
Promise<void>
Promise that resolves when playback begins
Example
const sound = await createSound('click.mp3')
await sound.play()Inherited from
BaseSound.play
playAt()
playAt(
time):Promise<void>
Defined in: packages/core/src/base-sound.ts:895
Play the audio source at a specific time.
This is the underlying method for all play variants. Time is measured in seconds from when the AudioContext was created (audioContext.currentTime).
Parameters
time
number
The AudioContext time when playback should start
Returns
Promise<void>
Example
// Play immediately
sound.playAt(audioContext.currentTime)
// Play in 2 seconds
sound.playAt(audioContext.currentTime + 2)
// Sync multiple sounds
const startTime = audioContext.currentTime + 0.1
sound1.playAt(startTime)
sound2.playAt(startTime)Inherited from
BaseSound.playAt
playFor()
playFor(
duration):void
Defined in: packages/core/src/base-sound.ts:849
Play for a specific duration, then stop automatically.
Parameters
duration
number
Seconds of playback before stopping
Returns
void
Example
// Play for 3 seconds
sound.playFor(3)Inherited from
BaseSound.playFor
playIn()
playIn(
when):void
Defined in: packages/core/src/base-sound.ts:834
Schedule playback after a delay.
Parameters
when
number
Seconds from now until playback starts
Returns
void
Example
// Play in 2 seconds
sound.playIn(2)Inherited from
BaseSound.playIn
playInAndStopAfter()
playInAndStopAfter(
playIn,stopAfter):void
Defined in: packages/core/src/base-sound.ts:868
Play after a delay, then stop after a duration.
Combines playIn() and stopIn() for precise timed playback.
Parameters
playIn
number
Seconds from now until playback starts
stopAfter
number
Seconds of playback before stopping (from play start)
Returns
void
Example
// Start in 1 second, play for 3 seconds
sound.playInAndStopAfter(1, 3)Inherited from
BaseSound.playInAndStopAfter
removeEffect()
removeEffect(
effect):this
Defined in: packages/core/src/base-sound.ts:435
Remove an effect from the effect chain.
Parameters
effect
The Effect instance to remove
Returns
this
this for chaining
Example
sound.removeEffect(filter)Inherited from
BaseSound.removeEffect
removeEventListener()
Call Signature
removeEventListener<
K>(type,listener,options?):void
Defined in: packages/core/src/events/typed-event-emitter.ts:70
Remove a typed event listener for known event types. Overloaded to provide type safety for known event types while remaining compatible with the native EventTarget API.
Type Parameters
K
K extends "play" | "dispose" | "stop" | "end"
Parameters
type
K
The event type (key of TMap)
listener
(event) => void
Typed event handler to remove
options?
Standard removeEventListener options
boolean | EventListenerOptions
Returns
void
Inherited from
BaseSound.removeEventListener
Call Signature
removeEventListener(
type,listener,options?):void
Defined in: packages/core/src/events/typed-event-emitter.ts:75
Remove a typed event listener for known event types. Overloaded to provide type safety for known event types while remaining compatible with the native EventTarget API.
Parameters
type
string
The event type (key of TMap)
listener
Typed event handler to remove
EventListenerOrEventListenerObject | null
options?
Standard removeEventListener options
boolean | EventListenerOptions
Returns
void
Inherited from
BaseSound.removeEventListener
rewireEffects()
rewireEffects():
void
Defined in: packages/core/src/base-sound.ts:540
Re-wire the effect chain. Call this after toggling effect.bypass to update the audio routing.
Returns
void
Inherited from
BaseSound.rewireEffects
setAnalyzer()
setAnalyzer(
analyzer):this
Defined in: packages/core/src/base-sound.ts:567
Attach an analyzer to this sound for visualization. The analyzer is inserted at the end of the signal chain (after effects and panner, before destination), showing the fully processed signal.
The analyzer is a passthrough node - audio flows through it unchanged while providing frequency and waveform data for visualization.
Parameters
analyzer
The Analyzer instance to attach, or null to detach
Analyzer | null
Returns
this
this for chaining
Example
const analyzer = createAnalyzer(audioContext, { fftSize: 2048 })
sound.setAnalyzer(analyzer)
function draw() {
const freqData = analyzer.getFrequencyData()
// Draw frequency bars
requestAnimationFrame(draw)
}Inherited from
BaseSound.setAnalyzer
setDestination()
setDestination(
node):this
Defined in: packages/core/src/base-sound.ts:530
Set a custom destination for audio output instead of audioContext.destination. Useful for routing to sub-mixes, analyzers, or other processing chains.
Parameters
node
AudioNode
The AudioNode to route output to
Returns
this
this for chaining
Example
const analyzer = audioContext.createAnalyser()
analyzer.connect(audioContext.destination)
sound.setDestination(analyzer)Inherited from
BaseSound.setDestination
setup()
protectedsetup():void
Defined in: packages/core/src/oscillator.ts:321
Set up a fresh OscillatorNode for playback. Called automatically before each play() since OscillatorNode is single-use. The GainNode is reused across plays to keep cached references from getGainNode() stable.
Returns
void
Overrides
BaseSound.setup
stop()
stop():
Promise<void>
Defined in: packages/core/src/oscillator.ts:664
Stop the sound immediately.
Emits a 'stop' event. Safe to call when not playing (no-op).
Returns
Promise<void>
Promise that resolves when the stop is processed
Example
await sound.stop()Overrides
BaseSound.stop
stopAt()
stopAt(
time):Promise<void>
Defined in: packages/core/src/oscillator.ts:586
Stop the oscillator at a specific AudioContext time.
Applies a quick 10ms gain fade-out before stopping to prevent click/pop artifacts from abrupt waveform cutoff. If an ADSR envelope is active, the fade-out is skipped since the envelope's release handles it.
For a future time, isPlaying stays true and the 'stop' event fires at the actual stop time rather than immediately — mirroring BaseSound.stopAt's future/immediate split (H1).
Parameters
time
number
The AudioContext time when playback should stop
Returns
Promise<void>
Overrides
BaseSound.stopAt
stopIn()
stopIn(
seconds):Promise<void>
Defined in: packages/core/src/base-sound.ts:1016
Stop the audio source after a delay.
Parameters
seconds
number
Seconds from now until playback stops
Returns
Promise<void>
Example
sound.play()
// Stop after 5 seconds
sound.stopIn(5)Inherited from
BaseSound.stopIn
update()
update(
type):object
Defined in: packages/core/src/oscillator.ts:247
Update an audio parameter immediately.
Overrides BaseSound.update() to accept the full ControlType including 'frequency', which is only valid on Oscillator instances.
Parameters
type
The parameter to update ('gain', 'pan', 'detune', or 'frequency')
Returns
object
Fluent builder: .to(value).as(unit)
to()
to: (
value) =>object
Parameters
value
number
Returns
object
as()
as: (
method) =>void
Parameters
method
Returns
void
Example
osc.update('frequency').to(880).as('ratio')
osc.update('gain').to(0.5).as('ratio')Overrides
BaseSound.update
wireConnections()
protectedwireConnections():void
Defined in: packages/core/src/oscillator.ts:473
Wire oscillator through filters to effect chain.
Returns
void
Overrides
BaseSound.wireConnections