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

FunctionSignatureDescription
sinesine(frequency, decay, gain?)Sine wave
triangletriangle(frequency, decay, gain?)Triangle wave
squaresquare(frequency, decay, gain?)Square wave
sawtoothsawtooth(frequency, decay, gain?)Sawtooth wave
noisenoise(color?, decay?, gain?)White, pink, or brown

All return (opts?: PlayOptions) => VoiceHandle.