Skip to content

EZ Web Audio / EffectWrapper

Class: EffectWrapper ​

Defined in: packages/core/src/effects/effect-wrapper.ts:50

EffectWrapper - Wraps external effects (like Tuna.js, custom WaveShaperNode, etc.) to provide a standard Effect interface with bypass and wet/dry mix controls.

External effects only need a connect() method to be wrapped. The wrapper creates the necessary infrastructure for wet/dry mixing and bypass functionality.

Supported Effect Types ​

Supports three types of external effects:

  1. Tuna.js effects — Have an input AudioNode property
  2. Native AudioNodes — WaveShaperNode, ConvolverNode, etc.
  3. Any object with connect() — Minimum interface requirement

Routing:

  • Dry path: input -> dryGain -> output
  • Wet path: input -> externalEffect -> wetGain -> output

Example ​

typescript
// Wrap a Tuna.js effect
const tuna = new Tuna(audioContext)
const chorus = tuna.Chorus({ rate: 1.5 })
const wrapped = wrapEffect(audioContext, chorus)

// Now use standard Effect interface
wrapped.bypass = true  // Bypass the effect
wrapped.mix = 0.5  // 50% wet/dry blend

// Access original effect
wrapped.effect.rate = 2.0

Implements ​

Constructors ​

Constructor ​

new EffectWrapper(audioContext, externalEffect): EffectWrapper

Defined in: packages/core/src/effects/effect-wrapper.ts:62

Parameters ​

audioContext ​

AudioContext

externalEffect ​

ExternalEffect

Returns ​

EffectWrapper

Accessors ​

bypass ​

Get Signature ​

get bypass(): boolean

Defined in: packages/core/src/effects/effect-wrapper.ts:136

When true, signal bypasses the effect entirely (100% dry).

Returns ​

boolean

Set Signature ​

set bypass(v): void

Defined in: packages/core/src/effects/effect-wrapper.ts:140

When true, effect is bypassed (passthrough)

Parameters ​
v ​

boolean

Returns ​

void

When true, effect is bypassed (passthrough)

Implementation of ​

Effect.bypass


effect ​

Get Signature ​

get effect(): ExternalEffect

Defined in: packages/core/src/effects/effect-wrapper.ts:162

Access the wrapped external effect for configuration. This allows direct manipulation of the effect's native properties.

Returns ​

ExternalEffect


input ​

Get Signature ​

get input(): AudioNode

Defined in: packages/core/src/effects/effect-wrapper.ts:124

The input AudioNode (receives signal from chain)

Returns ​

AudioNode

The input AudioNode that receives signal from the chain

Implementation of ​

Effect.input


mix ​

Get Signature ​

get mix(): number

Defined in: packages/core/src/effects/effect-wrapper.ts:149

Wet/dry mix: 0 = fully dry (no effect), 1 = fully wet (all through effect). Uses equal-power crossfade for natural mixing.

Returns ​

number

Set Signature ​

set mix(v): void

Defined in: packages/core/src/effects/effect-wrapper.ts:153

Wet/dry mix: 0 = fully dry (no effect), 1 = fully wet (full effect)

Parameters ​
v ​

number

Returns ​

void

Wet/dry mix: 0 = fully dry (no effect), 1 = fully wet (full effect)

Implementation of ​

Effect.mix


output ​

Get Signature ​

get output(): AudioNode

Defined in: packages/core/src/effects/effect-wrapper.ts:129

The output AudioNode (sends signal to next in chain)

Returns ​

AudioNode

The output AudioNode that sends signal to the next in chain

Implementation of ​

Effect.output

Methods ​

dispose() ​

dispose(): void

Defined in: packages/core/src/effects/effect-wrapper.ts:185

Disconnect all internal audio nodes (input/output/dry/wet) and, if the wrapped external effect exposes a disconnect() method, disconnect it too. Idempotent — safe to call multiple times.

Returns ​

void

Implementation of ​

Effect.dispose