Shorthands
When you just need a quick tone, use the shorthand constructors. Each wraps defineSound and returns a play function.
import { sine, triangle, square, sawtooth, noise } from "@web-kits/audio";
sine(440, 0.1)();
triangle(880, 0.2)();
noise("pink", 0.05)();Available shorthands
| Function | Signature | Description |
|---|---|---|
sine | sine(frequency, decay, gain?) | Sine wave |
triangle | triangle(frequency, decay, gain?) | Triangle wave |
square | square(frequency, decay, gain?) | Square wave |
sawtooth | sawtooth(frequency, decay, gain?) | Sawtooth wave |
noise | noise(color?, decay?, gain?) | White, pink, or brown |
All return (opts?: PlayOptions) => VoiceHandle.