Synthlet
Audio Sources

Impulse

Impuse generator

@synthlet/impulse

This module generates an impulse when a gate is opened. Useful to generate a click sound.

import { registerImpulseWorklet, Impulse } from "synthlet";
 
const audioContext = new AudioContext();
await registerImpulseWorklet(audioContext);
const impulse = Impulse(audioContext);
 
impulse.gate.value = 1;

Example

const s = await synthlet(new AudioContext());
const trigger = s.param();
const impulse = s.impulse(trigger);
 
// UI
onMouseDown(() => (trigger.value = 1));
onMouseUp(() => (trigger.value = 0));

Parameters

  • trigger: The gate trigger. 0 means off, 1 means on.

Triggering

the trigger value is 0, it needs to move back to 0 in order to trigger again.

On this page