Skip to content

EZ Web Audio / VoiceHandle

Class: VoiceHandle

Defined in: packages/core/src/poly-synth.ts:96

Handle returned by PolySynth.play() representing a single playing voice.

The handle provides per-voice control through the full Oscillator fluent API. When the voice is stolen or stopped, the handle becomes stale and all methods silently no-op — no errors thrown, no accidental modification of other voices.

Example

typescript
const handle = synth.play({ frequency: 440 })
handle.update('gain').to(0.5).as('ratio')  // per-voice volume
handle.update('frequency').to(450).as('ratio')  // pitch bend

// After voice is stolen:
handle.active  // false
handle.update('gain')  // silently no-ops

Constructors

Constructor

new VoiceHandle(oscillator, onStop): VoiceHandle

Defined in: packages/core/src/poly-synth.ts:99

Parameters

oscillator

Oscillator

onStop

() => void

Returns

VoiceHandle

Accessors

active

Get Signature

get active(): boolean

Defined in: packages/core/src/poly-synth.ts:105

Whether this handle still references an active voice.

Returns

boolean

Methods

onPlayRamp()

onPlayRamp(type, rampType?): object

Defined in: packages/core/src/poly-synth.ts:140

Schedule a parameter ramp when the voice next plays. Returns no-op builder if handle is stale.

Parameters

type

ControlType

rampType?

RampType

Returns

object

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


onPlaySet()

onPlaySet(type): object

Defined in: packages/core/src/poly-synth.ts:125

Schedule a parameter value to be set when the voice next plays. Returns no-op builder if handle is stale.

Parameters

type

ControlType

Returns

object

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


stop()

stop(): Promise<void>

Defined in: packages/core/src/poly-synth.ts:158

Stop this voice. The handle becomes stale after stopping.

With an ADSR envelope, the voice enters its release phase and keeps ringing until the tail completes — the pool reclaims it only then.

Returns

Promise<void>


update()

update(type): object

Defined in: packages/core/src/poly-synth.ts:111

Update a voice parameter immediately. Returns no-op builder if handle is stale.

Parameters

type

ControlType

Returns

object

to()

to: (value) => object

Parameters
value

number

Returns

object

as()

as: (method) => void

Parameters
method

RatioType

Returns

void