Skip to content

EZ Web Audio / EffectWrapper

Class: EffectWrapper

Defined in: 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: effects/effect-wrapper.ts:60

Parameters

audioContext

AudioContext

externalEffect

ExternalEffect

Returns

EffectWrapper

Accessors

bypass

Get Signature

get bypass(): boolean

Defined in: effects/effect-wrapper.ts:115

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

Returns

boolean

Set Signature

set bypass(v): void

Defined in: effects/effect-wrapper.ts:119

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: effects/effect-wrapper.ts:141

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: effects/effect-wrapper.ts:103

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: effects/effect-wrapper.ts:128

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: effects/effect-wrapper.ts:132

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: effects/effect-wrapper.ts:108

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