Skip to content

EZ Web Audio / createPolySynth

Function: createPolySynth()

Call Signature

createPolySynth(options?): Promise<PolySynth>

Defined in: packages/core/src/index.ts:800

Create a PolySynth for polyphonic synthesis with automatic voice management.

PolySynth manages a pool of Oscillator voices, handling allocation, recycling, and voice stealing automatically. All voices route through a shared output bus with master gain/pan controls and effect chain support.

Parameters

options?

PolySynthOptions

PolySynth configuration (maxVoices, stealStrategy, oscillator settings)

Returns

Promise<PolySynth>

Promise resolving to a PolySynth instance

Example

typescript
import { createPolySynth } from 'ez-web-audio'

const synth = await createPolySynth({
  maxVoices: 8,
  type: 'sawtooth',
  envelope: { attack: 0.01, decay: 0.2, sustain: 0.5, release: 0.3 },
  lowpass: { frequency: 2000, q: 1 }
})

// Play a chord
synth.play({ frequency: 261.63 }) // C4
synth.play({ frequency: 329.63 }) // E4
synth.play({ frequency: 392.00 }) // G4

// Add effects to all voices
const delay = createDelay({ time: 0.3, feedback: 0.4, wet: 0.3 })
synth.addEffect(delay)

Call Signature

createPolySynth(audioContext, options?): Promise<PolySynth>

Defined in: packages/core/src/index.ts:801

Create a PolySynth for polyphonic synthesis with automatic voice management.

PolySynth manages a pool of Oscillator voices, handling allocation, recycling, and voice stealing automatically. All voices route through a shared output bus with master gain/pan controls and effect chain support.

Parameters

audioContext

BaseAudioContext

options?

PolySynthOptions

PolySynth configuration (maxVoices, stealStrategy, oscillator settings)

Returns

Promise<PolySynth>

Promise resolving to a PolySynth instance

Example

typescript
import { createPolySynth } from 'ez-web-audio'

const synth = await createPolySynth({
  maxVoices: 8,
  type: 'sawtooth',
  envelope: { attack: 0.01, decay: 0.2, sustain: 0.5, release: 0.3 },
  lowpass: { frequency: 2000, q: 1 }
})

// Play a chord
synth.play({ frequency: 261.63 }) // C4
synth.play({ frequency: 329.63 }) // E4
synth.play({ frequency: 392.00 }) // G4

// Add effects to all voices
const delay = createDelay({ time: 0.3, feedback: 0.4, wet: 0.3 })
synth.addEffect(delay)