UNPKG

sw-synth

Version:

Lightweight sound synthesizer designed for real-time user interaction using the Web Audio API

38 lines (37 loc) 1.39 kB
/** Parameters for the ADSR envelope of the synth. */ export type VoiceBaseParams = { /** Audio delay in seconds. Increase on Firefox to reduce pops. */ audioDelay: number; /** Attack time in seconds. */ attackTime: number; /** Decay time constant (exponential decay from 1 to `sustainLevel`). */ decayTime: number; /** Steady state amplitude. */ sustainLevel: number; /** Release time constant (exponential decay from `sustainLevel` to 0). */ releaseTime: number; }; /** Per-note pitch bend weights in cents for each bend direction. */ export type PitchBendRange = { /** Maximum downward bend in cents when pitch bend is -1. */ down: number; /** Maximum upward bend in cents when pitch bend is +1. */ up: number; }; /** * Oscillator with ADSR envelope. * Represents a single "channel" of polyphony. Should be reused for multiple notes. */ export declare class VoiceBase { age: number; context: BaseAudioContext; envelope: GainNode; log: (msg: string) => void; noteId: number; voiceId: number; lastNoteOff?: () => void; pitchBend: WaveShaperNode; constructor(context: BaseAudioContext, destination: AudioNode, log: (msg: string) => void); noteOn(frequency: number, velocity: number, noteId: number, params: VoiceBaseParams, pitchBendRange?: PitchBendRange): () => void; dispose(): void; }