earcons 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context.ts","../src/synth.ts","../src/sounds/success.ts","../src/sounds/error.ts","../src/sounds/warning.ts","../src/sounds/notification.ts","../src/sounds/click.ts","../src/sounds/info.ts","../src/index.ts"],"names":["VARIANTS"],"mappings":";;;AAIA,IAAI,IAAA,GAA4B,IAAA;AAOhC,eAAsB,eAAA,GAAyC;AAC7D,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,IAAA,GAAO,IAAI,YAAA,EAAa;AAAA,EAC1B;AAEA,EAAA,IAAI,IAAA,CAAK,UAAU,WAAA,EAAa;AAC9B,IAAA,MAAM,KAAK,MAAA,EAAO;AAAA,EACpB;AAEA,EAAA,OAAO,IAAA;AACT;AAkBA,eAAsB,iBAAA,GAAmC;AACvD,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,KAAK,KAAA,EAAM;AACjB,IAAA,IAAA,GAAO,IAAA;AAAA,EACT;AACF;AAKO,SAAS,gBAAgB,GAAA,EAAyB;AACvD,EAAA,IAAA,GAAO,GAAA;AACT;;;AC3CA,IAAM,gBAAA,GAA6B;AAAA,EACjC,MAAA,EAAQ,IAAA;AAAA,EACR,KAAA,EAAO,IAAA;AAAA,EACP,OAAA,EAAS,GAAA;AAAA,EACT,OAAA,EAAS,IAAA;AAAA,EACT,IAAA,EAAM;AACR,CAAA;AAMO,SAAS,sBAAsB,SAAA,EAA2B;AAC/D,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,SAAA,GAAY,EAAE,CAAA;AACnC;AAMA,SAAS,YAAA,CACP,GAAA,EACA,IAAA,EACA,UAAA,EACA,iBACA,UAAA,EACQ;AACR,EAAA,MAAM,GAAA,GAAgB;AAAA,IACpB,GAAG,gBAAA;AAAA,IACH,GAAG,IAAA,CAAK;AAAA,GACV;AAE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AAS,aAAA;AAAA,EACT,YAAA,EAAc,kBAAA;AAAA,EACd,KAAA,EAAO,WAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAWA,eAAsB,MAAA,CACpB,IAAA,EACA,IAAA,GAAqB,EAAC,EACP;AACf,EAAA,MAAM,MAAA,GAAS,KAAK,IAAI,CAAA;AACxB,EAAA,OAAO,IAAA,CAAK,OAAO,IAAA,CAAK,OAAA,IAAW,UAAU,IAAA,CAAK,KAAA,IAAS,CAAC,CAAA,EAAG,IAAI,CAAA;AACrE;AAiBO,SAAS,aAAA,CAAc,MAAc,MAAA,EAA2B;AACrE,EAAC,IAAA,CAAqC,IAAI,CAAA,GAAI,MAAA;AAChD","file":"index.cjs","sourcesContent":["// ---------------------------------------------------------------------------\n// earcon — AudioContext singleton with autoplay-policy handling\n// ---------------------------------------------------------------------------\n\nlet _ctx: AudioContext | null = null;\n\n/**\n * Returns the shared AudioContext, creating it on first call.\n * Automatically resumes a suspended context (needed after browser\n * autoplay-policy restrictions kick in before a user gesture).\n */\nexport async function getAudioContext(): Promise<AudioContext> {\n if (!_ctx) {\n _ctx = new AudioContext();\n }\n\n if (_ctx.state === \"suspended\") {\n await _ctx.resume();\n }\n\n return _ctx;\n}\n\n/**\n * Returns the shared AudioContext synchronously.\n * The context may still be suspended — callers that need it resumed\n * should use {@link getAudioContext} instead.\n */\nexport function getAudioContextSync(): AudioContext {\n if (!_ctx) {\n _ctx = new AudioContext();\n }\n return _ctx;\n}\n\n/**\n * Closes and discards the shared AudioContext.\n * Useful in tests or when tearing down an SPA.\n */\nexport async function closeAudioContext(): Promise<void> {\n if (_ctx) {\n await _ctx.close();\n _ctx = null;\n }\n}\n\n/**\n * Replace the internal singleton — useful in tests to inject a mock.\n */\nexport function setAudioContext(ctx: AudioContext): void {\n _ctx = ctx;\n}\n","// ---------------------------------------------------------------------------\n// earcon — synthesis engine\n// Schedules NoteEvents on a given AudioContext using oscillator nodes\n// and a GainNode-based ADSR envelope.\n// ---------------------------------------------------------------------------\n\nimport type { EarconSound, Envelope, NoteEvent } from \"./types.js\";\n\nconst DEFAULT_ENVELOPE: Envelope = {\n attack: 0.01,\n decay: 0.05,\n sustain: 0.7,\n release: 0.08,\n hold: 0,\n};\n\n/**\n * Converts a semitone offset to a frequency multiplier.\n * e.g. +12 semitones → ×2 (one octave up)\n */\nexport function semitonesToMultiplier(semitones: number): number {\n return Math.pow(2, semitones / 12);\n}\n\n/**\n * Schedules a single NoteEvent on the provided AudioContext.\n * Returns the scheduled end time (AudioContext.currentTime + startAt + duration + release).\n */\nfunction scheduleNote(\n ctx: AudioContext,\n note: NoteEvent,\n masterGain: GainNode,\n pitchMultiplier: number,\n timeOffset: number\n): number {\n const env: Envelope = {\n ...DEFAULT_ENVELOPE,\n ...note.envelope,\n };\n\n const t0 = timeOffset + note.startAt;\n const noteGain = note.gain ?? 1;\n const waveShape = note.waveShape ?? \"sine\";\n const freq = note.frequency * pitchMultiplier;\n\n // Per-note gain envelope node\n const gainNode = ctx.createGain();\n gainNode.connect(masterGain);\n gainNode.gain.setValueAtTime(0, t0);\n\n // Attack\n gainNode.gain.linearRampToValueAtTime(noteGain, t0 + env.attack);\n\n // Hold (optional flat segment)\n const holdEnd = t0 + env.attack + (env.hold ?? 0);\n gainNode.gain.setValueAtTime(noteGain, holdEnd);\n\n // Decay → sustain level\n gainNode.gain.linearRampToValueAtTime(\n noteGain * env.sustain,\n holdEnd + env.decay\n );\n\n // Sustain until note end\n const noteEnd = t0 + note.duration;\n gainNode.gain.setValueAtTime(noteGain * env.sustain, noteEnd);\n\n // Release\n gainNode.gain.linearRampToValueAtTime(0, noteEnd + env.release);\n\n // Oscillator\n const osc = ctx.createOscillator();\n osc.type = waveShape;\n osc.frequency.setValueAtTime(freq, t0);\n osc.connect(gainNode);\n osc.start(t0);\n osc.stop(noteEnd + env.release + 0.01); // tiny buffer to avoid click\n\n return noteEnd + env.release;\n}\n\n/**\n * Plays an {@link EarconSound} on the provided AudioContext.\n *\n * @param ctx - AudioContext to schedule on\n * @param sound - The sound descriptor to play\n * @param volume - Master volume 0–1\n * @param pitchSemitones - Semitone offset applied to all frequencies\n * @param onEnded - Optional callback when the sound finishes\n */\nexport function playSound(\n ctx: AudioContext,\n sound: EarconSound,\n volume: number,\n pitchSemitones: number,\n onEnded?: () => void\n): void {\n const masterGain = ctx.createGain();\n masterGain.gain.setValueAtTime(Math.max(0, Math.min(1, volume)), ctx.currentTime);\n masterGain.connect(ctx.destination);\n\n const pitchMultiplier = semitonesToMultiplier(pitchSemitones);\n const timeOffset = ctx.currentTime;\n\n let latestEnd = timeOffset;\n\n for (const note of sound.notes) {\n const end = scheduleNote(ctx, note, masterGain, pitchMultiplier, timeOffset);\n if (end > latestEnd) latestEnd = end;\n }\n\n // Schedule onEnded callback via a silent OscillatorNode that stops at latestEnd\n if (onEnded) {\n const sentinel = ctx.createOscillator();\n const silentGain = ctx.createGain();\n silentGain.gain.setValueAtTime(0, timeOffset);\n sentinel.connect(silentGain);\n silentGain.connect(ctx.destination);\n sentinel.start(timeOffset);\n sentinel.stop(latestEnd);\n sentinel.onended = onEnded;\n }\n}\n","// ---------------------------------------------------------------------------\n// earcon — \"success\" preset\n// A short ascending two-tone chime (major third → fifth), bright and clean.\n// ---------------------------------------------------------------------------\n\nimport type { EarconSound, SoundVariant } from \"../types.js\";\n\nconst VARIANTS: Record<SoundVariant, EarconSound> = {\n short: {\n name: \"success\",\n duration: 0.25,\n notes: [\n { frequency: 523.25, duration: 0.1, startAt: 0, waveShape: \"sine\", gain: 0.8 },\n { frequency: 783.99, duration: 0.15, startAt: 0.1, waveShape: \"sine\", gain: 0.9 },\n ],\n },\n medium: {\n name: \"success\",\n duration: 0.45,\n notes: [\n { frequency: 523.25, duration: 0.12, startAt: 0, waveShape: \"sine\", gain: 0.7 },\n { frequency: 659.25, duration: 0.12, startAt: 0.12, waveShape: \"sine\", gain: 0.8 },\n { frequency: 783.99, duration: 0.2, startAt: 0.24, waveShape: \"sine\", gain: 0.9 },\n ],\n },\n long: {\n name: \"success\",\n duration: 0.7,\n notes: [\n { frequency: 392.00, duration: 0.1, startAt: 0, waveShape: \"sine\", gain: 0.6 },\n { frequency: 523.25, duration: 0.12, startAt: 0.1, waveShape: \"sine\", gain: 0.7 },\n { frequency: 659.25, duration: 0.12, startAt: 0.22, waveShape: \"sine\", gain: 0.8 },\n { frequency: 783.99, duration: 0.25, startAt: 0.34, waveShape: \"sine\", gain: 0.9 },\n ],\n },\n};\n\nexport function successPreset(\n variant: SoundVariant,\n pitchSemitones: number\n): EarconSound {\n // pitchSemitones is applied by the synth engine — just return the descriptor\n void pitchSemitones;\n return VARIANTS[variant];\n}\n","// ---------------------------------------------------------------------------\n// earcon — \"error\" preset\n// Descending dissonant tones (tritone), harsh and attention-grabbing.\n// ---------------------------------------------------------------------------\n\nimport type { EarconSound, SoundVariant } from \"../types.js\";\n\nconst VARIANTS: Record<SoundVariant, EarconSound> = {\n short: {\n name: \"error\",\n duration: 0.25,\n notes: [\n { frequency: 440, duration: 0.1, startAt: 0, waveShape: \"square\", gain: 0.5,\n envelope: { attack: 0.005, decay: 0.04, sustain: 0.6, release: 0.06 } },\n { frequency: 311, duration: 0.15, startAt: 0.1, waveShape: \"square\", gain: 0.6,\n envelope: { attack: 0.005, decay: 0.04, sustain: 0.6, release: 0.06 } },\n ],\n },\n medium: {\n name: \"error\",\n duration: 0.5,\n notes: [\n { frequency: 440, duration: 0.12, startAt: 0, waveShape: \"sawtooth\", gain: 0.4,\n envelope: { attack: 0.005, decay: 0.06, sustain: 0.5, release: 0.08 } },\n { frequency: 392, duration: 0.12, startAt: 0.13, waveShape: \"sawtooth\", gain: 0.45,\n envelope: { attack: 0.005, decay: 0.06, sustain: 0.5, release: 0.08 } },\n { frequency: 311, duration: 0.2, startAt: 0.26, waveShape: \"sawtooth\", gain: 0.55,\n envelope: { attack: 0.005, decay: 0.06, sustain: 0.5, release: 0.12 } },\n ],\n },\n long: {\n name: \"error\",\n duration: 0.75,\n notes: [\n { frequency: 440, duration: 0.12, startAt: 0, waveShape: \"sawtooth\", gain: 0.4,\n envelope: { attack: 0.005, decay: 0.07, sustain: 0.5, release: 0.1 } },\n { frequency: 415, duration: 0.1, startAt: 0.14, waveShape: \"sawtooth\", gain: 0.4,\n envelope: { attack: 0.005, decay: 0.07, sustain: 0.5, release: 0.1 } },\n { frequency: 370, duration: 0.12, startAt: 0.26, waveShape: \"sawtooth\", gain: 0.45,\n envelope: { attack: 0.005, decay: 0.07, sustain: 0.5, release: 0.1 } },\n { frequency: 311, duration: 0.25, startAt: 0.4, waveShape: \"sawtooth\", gain: 0.55,\n envelope: { attack: 0.005, decay: 0.08, sustain: 0.5, release: 0.15 } },\n ],\n },\n};\n\nexport function errorPreset(\n variant: SoundVariant,\n pitchSemitones: number\n): EarconSound {\n void pitchSemitones;\n return VARIANTS[variant];\n}\n","// ---------------------------------------------------------------------------\n// earcon — \"warning\" preset\n// A flat-then-descending minor second — cautious, not alarming.\n// ---------------------------------------------------------------------------\n\nimport type { EarconSound, SoundVariant } from \"../types.js\";\n\nconst VARIANTS: Record<SoundVariant, EarconSound> = {\n short: {\n name: \"warning\",\n duration: 0.28,\n notes: [\n { frequency: 587.33, duration: 0.1, startAt: 0, waveShape: \"triangle\", gain: 0.7 },\n { frequency: 523.25, duration: 0.18, startAt: 0.1, waveShape: \"triangle\", gain: 0.75 },\n ],\n },\n medium: {\n name: \"warning\",\n duration: 0.5,\n notes: [\n { frequency: 587.33, duration: 0.12, startAt: 0, waveShape: \"triangle\", gain: 0.65 },\n { frequency: 587.33, duration: 0.12, startAt: 0.14, waveShape: \"triangle\", gain: 0.65 },\n { frequency: 493.88, duration: 0.2, startAt: 0.28, waveShape: \"triangle\", gain: 0.75 },\n ],\n },\n long: {\n name: \"warning\",\n duration: 0.8,\n notes: [\n { frequency: 587.33, duration: 0.12, startAt: 0, waveShape: \"triangle\", gain: 0.6 },\n { frequency: 587.33, duration: 0.12, startAt: 0.15, waveShape: \"triangle\", gain: 0.6 },\n { frequency: 554.37, duration: 0.12, startAt: 0.3, waveShape: \"triangle\", gain: 0.65 },\n { frequency: 493.88, duration: 0.25, startAt: 0.45, waveShape: \"triangle\", gain: 0.75 },\n ],\n },\n};\n\nexport function warningPreset(\n variant: SoundVariant,\n pitchSemitones: number\n): EarconSound {\n void pitchSemitones;\n return VARIANTS[variant];\n}\n","// ---------------------------------------------------------------------------\n// earcon — \"notification\" preset\n// Two clean sine tones — a gentle, neutral \"ding\" suitable for messages.\n// ---------------------------------------------------------------------------\n\nimport type { EarconSound, SoundVariant } from \"../types.js\";\n\nconst VARIANTS: Record<SoundVariant, EarconSound> = {\n short: {\n name: \"notification\",\n duration: 0.22,\n notes: [\n { frequency: 880, duration: 0.08, startAt: 0, waveShape: \"sine\", gain: 0.6 },\n { frequency: 660, duration: 0.14, startAt: 0.08, waveShape: \"sine\", gain: 0.65 },\n ],\n },\n medium: {\n name: \"notification\",\n duration: 0.38,\n notes: [\n { frequency: 880, duration: 0.1, startAt: 0, waveShape: \"sine\", gain: 0.55 },\n { frequency: 660, duration: 0.28, startAt: 0.1, waveShape: \"sine\", gain: 0.6 },\n ],\n },\n long: {\n name: \"notification\",\n duration: 0.55,\n notes: [\n { frequency: 1046.5, duration: 0.08, startAt: 0, waveShape: \"sine\", gain: 0.5 },\n { frequency: 880, duration: 0.1, startAt: 0.1, waveShape: \"sine\", gain: 0.55 },\n { frequency: 660, duration: 0.3, startAt: 0.22, waveShape: \"sine\", gain: 0.6 },\n ],\n },\n};\n\nexport function notificationPreset(\n variant: SoundVariant,\n pitchSemitones: number\n): EarconSound {\n void pitchSemitones;\n return VARIANTS[variant];\n}\n","// ---------------------------------------------------------------------------\n// earcon — \"click\" preset\n// A very short transient — simulates a tactile UI button press/toggle.\n// ---------------------------------------------------------------------------\n\nimport type { EarconSound, SoundVariant } from \"../types.js\";\n\nconst VARIANTS: Record<SoundVariant, EarconSound> = {\n short: {\n name: \"click\",\n duration: 0.04,\n notes: [\n {\n frequency: 1200,\n duration: 0.03,\n startAt: 0,\n waveShape: \"sine\",\n gain: 0.5,\n envelope: { attack: 0.002, decay: 0.015, sustain: 0, release: 0.01 },\n },\n ],\n },\n medium: {\n name: \"click\",\n duration: 0.07,\n notes: [\n {\n frequency: 900,\n duration: 0.05,\n startAt: 0,\n waveShape: \"sine\",\n gain: 0.55,\n envelope: { attack: 0.002, decay: 0.03, sustain: 0, release: 0.015 },\n },\n ],\n },\n long: {\n name: \"click\",\n duration: 0.12,\n notes: [\n {\n frequency: 700,\n duration: 0.08,\n startAt: 0,\n waveShape: \"triangle\",\n gain: 0.6,\n envelope: { attack: 0.002, decay: 0.05, sustain: 0, release: 0.025 },\n },\n ],\n },\n};\n\nexport function clickPreset(\n variant: SoundVariant,\n pitchSemitones: number\n): EarconSound {\n void pitchSemitones;\n return VARIANTS[variant];\n}\n","// ---------------------------------------------------------------------------\n// earcon — \"info\" preset\n// A neutral single soft tone — informational, non-intrusive.\n// ---------------------------------------------------------------------------\n\nimport type { EarconSound, SoundVariant } from \"../types.js\";\n\nconst VARIANTS: Record<SoundVariant, EarconSound> = {\n short: {\n name: \"info\",\n duration: 0.2,\n notes: [\n {\n frequency: 698.46, // F5\n duration: 0.18,\n startAt: 0,\n waveShape: \"sine\",\n gain: 0.55,\n envelope: { attack: 0.015, decay: 0.04, sustain: 0.5, release: 0.1 },\n },\n ],\n },\n medium: {\n name: \"info\",\n duration: 0.35,\n notes: [\n {\n frequency: 698.46,\n duration: 0.32,\n startAt: 0,\n waveShape: \"sine\",\n gain: 0.55,\n envelope: { attack: 0.02, decay: 0.05, sustain: 0.5, release: 0.12 },\n },\n ],\n },\n long: {\n name: \"info\",\n duration: 0.55,\n notes: [\n {\n frequency: 587.33, // D5\n duration: 0.18,\n startAt: 0,\n waveShape: \"sine\",\n gain: 0.5,\n envelope: { attack: 0.02, decay: 0.05, sustain: 0.4, release: 0.1 },\n },\n {\n frequency: 698.46, // F5\n duration: 0.3,\n startAt: 0.2,\n waveShape: \"sine\",\n gain: 0.55,\n envelope: { attack: 0.02, decay: 0.06, sustain: 0.5, release: 0.12 },\n },\n ],\n },\n};\n\nexport function infoPreset(\n variant: SoundVariant,\n pitchSemitones: number\n): EarconSound {\n void pitchSemitones;\n return VARIANTS[variant];\n}\n","// ---------------------------------------------------------------------------\n// earcon — public API\n// ---------------------------------------------------------------------------\n\nexport type {\n WaveShape,\n SoundVariant,\n SoundOptions,\n Envelope,\n NoteEvent,\n EarconSound,\n SoundPreset,\n} from \"./types.js\";\n\nexport { closeAudioContext, setAudioContext } from \"./context.js\";\nexport { semitonesToMultiplier } from \"./synth.js\";\n\nimport { getAudioContext } from \"./context.js\";\nimport { playSound } from \"./synth.js\";\nimport type { SoundOptions } from \"./types.js\";\n\nimport {\n successPreset,\n errorPreset,\n warningPreset,\n notificationPreset,\n clickPreset,\n infoPreset,\n} from \"./sounds/index.js\";\n\n// ---------------------------------------------------------------------------\n// Internal helper — resolves options and dispatches to the synth engine\n// ---------------------------------------------------------------------------\n\nasync function play(\n preset: ReturnType<typeof successPreset>,\n opts: SoundOptions = {}\n): Promise<void> {\n const { volume = 0.5, pitch = 0, audioContext, onEnded } = opts;\n const ctx = audioContext ?? (await getAudioContext());\n playSound(ctx, preset, volume, pitch, onEnded);\n}\n\n// ---------------------------------------------------------------------------\n// Named play functions — tree-shakable, one per sound type\n// ---------------------------------------------------------------------------\n\n/** Play a success / confirmation sound */\nexport async function playSuccess(opts: SoundOptions = {}): Promise<void> {\n return play(successPreset(opts.variant ?? \"medium\", opts.pitch ?? 0), opts);\n}\n\n/** Play an error sound */\nexport async function playError(opts: SoundOptions = {}): Promise<void> {\n return play(errorPreset(opts.variant ?? \"medium\", opts.pitch ?? 0), opts);\n}\n\n/** Play a warning sound */\nexport async function playWarning(opts: SoundOptions = {}): Promise<void> {\n return play(warningPreset(opts.variant ?? \"medium\", opts.pitch ?? 0), opts);\n}\n\n/** Play a notification / message sound */\nexport async function playNotification(opts: SoundOptions = {}): Promise<void> {\n return play(\n notificationPreset(opts.variant ?? \"medium\", opts.pitch ?? 0),\n opts\n );\n}\n\n/** Play a UI click / toggle transient */\nexport async function playClick(opts: SoundOptions = {}): Promise<void> {\n return play(clickPreset(opts.variant ?? \"short\", opts.pitch ?? 0), opts);\n}\n\n/** Play an informational / neutral tone */\nexport async function playInfo(opts: SoundOptions = {}): Promise<void> {\n return play(infoPreset(opts.variant ?? \"medium\", opts.pitch ?? 0), opts);\n}\n\n// ---------------------------------------------------------------------------\n// Sound bank — generic play-by-name API\n// ---------------------------------------------------------------------------\n\nconst BANK = {\n success: successPreset,\n error: errorPreset,\n warning: warningPreset,\n notification: notificationPreset,\n click: clickPreset,\n info: infoPreset,\n} as const;\n\nexport type SoundName = keyof typeof BANK;\n\n/**\n * Play any registered sound by name.\n *\n * @example\n * await earcon(\"success\");\n * await earcon(\"error\", { variant: \"long\", volume: 0.8 });\n */\nexport async function earcon(\n name: SoundName,\n opts: SoundOptions = {}\n): Promise<void> {\n const preset = BANK[name];\n return play(preset(opts.variant ?? \"medium\", opts.pitch ?? 0), opts);\n}\n\n/**\n * Register a custom sound under a new name so it can be played via {@link earcon}.\n *\n * @example\n * import type { SoundPreset } from \"earcons\";\n *\n * const mySound: SoundPreset = (variant, pitch) => ({\n * name: \"mySound\",\n * duration: 0.3,\n * notes: [{ frequency: 440, duration: 0.3, startAt: 0 }],\n * });\n *\n * registerSound(\"mySound\", mySound);\n * await earcon(\"mySound\");\n */\nexport function registerSound(name: string, preset: SoundPreset): void {\n (BANK as Record<string, SoundPreset>)[name] = preset;\n}\n\nimport type { SoundPreset } from \"./types.js\";\n"]}
@@ -0,0 +1,153 @@
1
+ /** Oscillator wave shapes supported by the Web Audio API */
2
+ type WaveShape = "sine" | "square" | "sawtooth" | "triangle";
3
+ /** Optional duration variants for sounds that have them */
4
+ type SoundVariant = "short" | "medium" | "long";
5
+ /**
6
+ * Options accepted by every public play* function.
7
+ */
8
+ interface SoundOptions {
9
+ /**
10
+ * Master volume for this sound, 0–1.
11
+ * @default 0.5
12
+ */
13
+ volume?: number;
14
+ /**
15
+ * Duration variant. Not all sounds support all variants.
16
+ * Falls back to "medium" when unsupported.
17
+ * @default "medium"
18
+ */
19
+ variant?: SoundVariant;
20
+ /**
21
+ * Semitone offset applied to all pitches in the sound (+12 = one octave up).
22
+ * @default 0
23
+ */
24
+ pitch?: number;
25
+ /**
26
+ * Provide your own AudioContext instead of using the shared singleton.
27
+ * Useful in frameworks that manage their own audio graph.
28
+ */
29
+ audioContext?: AudioContext;
30
+ /**
31
+ * Called when the sound finishes playing.
32
+ */
33
+ onEnded?: () => void;
34
+ }
35
+ /**
36
+ * ADSR envelope parameters (all times in seconds).
37
+ */
38
+ interface Envelope {
39
+ attack: number;
40
+ decay: number;
41
+ sustain: number;
42
+ release: number;
43
+ hold?: number;
44
+ }
45
+ /**
46
+ * Descriptor for a single note/tone within a sound sequence.
47
+ */
48
+ interface NoteEvent {
49
+ /** Frequency in Hz */
50
+ frequency: number;
51
+ /** Duration of the note in seconds */
52
+ duration: number;
53
+ /** Start offset from the beginning of the sequence (seconds) */
54
+ startAt: number;
55
+ /** Wave shape */
56
+ waveShape?: WaveShape;
57
+ /** Per-note volume multiplier 0–1 */
58
+ gain?: number;
59
+ /** ADSR envelope (overrides synth defaults if provided) */
60
+ envelope?: Partial<Envelope>;
61
+ }
62
+ /**
63
+ * A fully-described playable sound — returned by every preset builder.
64
+ */
65
+ interface EarconSound {
66
+ /** Human-readable name, e.g. "success" */
67
+ name: string;
68
+ /** Total duration in seconds (used to schedule the onEnded callback) */
69
+ duration: number;
70
+ /** Sequence of notes that make up this sound */
71
+ notes: NoteEvent[];
72
+ }
73
+ /**
74
+ * A sound preset function signature: accepts variant and pitch offset,
75
+ * returns a fully-specified EarconSound ready for the scheduler.
76
+ */
77
+ type SoundPreset = (variant: SoundVariant, pitchSemitones: number) => EarconSound;
78
+
79
+ /**
80
+ * Closes and discards the shared AudioContext.
81
+ * Useful in tests or when tearing down an SPA.
82
+ */
83
+ declare function closeAudioContext(): Promise<void>;
84
+ /**
85
+ * Replace the internal singleton — useful in tests to inject a mock.
86
+ */
87
+ declare function setAudioContext(ctx: AudioContext): void;
88
+
89
+ /**
90
+ * Converts a semitone offset to a frequency multiplier.
91
+ * e.g. +12 semitones → ×2 (one octave up)
92
+ */
93
+ declare function semitonesToMultiplier(semitones: number): number;
94
+
95
+ declare function successPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
96
+
97
+ declare function errorPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
98
+
99
+ declare function warningPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
100
+
101
+ declare function notificationPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
102
+
103
+ declare function clickPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
104
+
105
+ declare function infoPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
106
+
107
+ /** Play a success / confirmation sound */
108
+ declare function playSuccess(opts?: SoundOptions): Promise<void>;
109
+ /** Play an error sound */
110
+ declare function playError(opts?: SoundOptions): Promise<void>;
111
+ /** Play a warning sound */
112
+ declare function playWarning(opts?: SoundOptions): Promise<void>;
113
+ /** Play a notification / message sound */
114
+ declare function playNotification(opts?: SoundOptions): Promise<void>;
115
+ /** Play a UI click / toggle transient */
116
+ declare function playClick(opts?: SoundOptions): Promise<void>;
117
+ /** Play an informational / neutral tone */
118
+ declare function playInfo(opts?: SoundOptions): Promise<void>;
119
+ declare const BANK: {
120
+ readonly success: typeof successPreset;
121
+ readonly error: typeof errorPreset;
122
+ readonly warning: typeof warningPreset;
123
+ readonly notification: typeof notificationPreset;
124
+ readonly click: typeof clickPreset;
125
+ readonly info: typeof infoPreset;
126
+ };
127
+ type SoundName = keyof typeof BANK;
128
+ /**
129
+ * Play any registered sound by name.
130
+ *
131
+ * @example
132
+ * await earcon("success");
133
+ * await earcon("error", { variant: "long", volume: 0.8 });
134
+ */
135
+ declare function earcon(name: SoundName, opts?: SoundOptions): Promise<void>;
136
+ /**
137
+ * Register a custom sound under a new name so it can be played via {@link earcon}.
138
+ *
139
+ * @example
140
+ * import type { SoundPreset } from "earcons";
141
+ *
142
+ * const mySound: SoundPreset = (variant, pitch) => ({
143
+ * name: "mySound",
144
+ * duration: 0.3,
145
+ * notes: [{ frequency: 440, duration: 0.3, startAt: 0 }],
146
+ * });
147
+ *
148
+ * registerSound("mySound", mySound);
149
+ * await earcon("mySound");
150
+ */
151
+ declare function registerSound(name: string, preset: SoundPreset): void;
152
+
153
+ export { type EarconSound, type Envelope, type NoteEvent, type SoundName, type SoundOptions, type SoundPreset, type SoundVariant, type WaveShape, closeAudioContext, earcon, playClick, playError, playInfo, playNotification, playSuccess, playWarning, registerSound, semitonesToMultiplier, setAudioContext };
@@ -0,0 +1,153 @@
1
+ /** Oscillator wave shapes supported by the Web Audio API */
2
+ type WaveShape = "sine" | "square" | "sawtooth" | "triangle";
3
+ /** Optional duration variants for sounds that have them */
4
+ type SoundVariant = "short" | "medium" | "long";
5
+ /**
6
+ * Options accepted by every public play* function.
7
+ */
8
+ interface SoundOptions {
9
+ /**
10
+ * Master volume for this sound, 0–1.
11
+ * @default 0.5
12
+ */
13
+ volume?: number;
14
+ /**
15
+ * Duration variant. Not all sounds support all variants.
16
+ * Falls back to "medium" when unsupported.
17
+ * @default "medium"
18
+ */
19
+ variant?: SoundVariant;
20
+ /**
21
+ * Semitone offset applied to all pitches in the sound (+12 = one octave up).
22
+ * @default 0
23
+ */
24
+ pitch?: number;
25
+ /**
26
+ * Provide your own AudioContext instead of using the shared singleton.
27
+ * Useful in frameworks that manage their own audio graph.
28
+ */
29
+ audioContext?: AudioContext;
30
+ /**
31
+ * Called when the sound finishes playing.
32
+ */
33
+ onEnded?: () => void;
34
+ }
35
+ /**
36
+ * ADSR envelope parameters (all times in seconds).
37
+ */
38
+ interface Envelope {
39
+ attack: number;
40
+ decay: number;
41
+ sustain: number;
42
+ release: number;
43
+ hold?: number;
44
+ }
45
+ /**
46
+ * Descriptor for a single note/tone within a sound sequence.
47
+ */
48
+ interface NoteEvent {
49
+ /** Frequency in Hz */
50
+ frequency: number;
51
+ /** Duration of the note in seconds */
52
+ duration: number;
53
+ /** Start offset from the beginning of the sequence (seconds) */
54
+ startAt: number;
55
+ /** Wave shape */
56
+ waveShape?: WaveShape;
57
+ /** Per-note volume multiplier 0–1 */
58
+ gain?: number;
59
+ /** ADSR envelope (overrides synth defaults if provided) */
60
+ envelope?: Partial<Envelope>;
61
+ }
62
+ /**
63
+ * A fully-described playable sound — returned by every preset builder.
64
+ */
65
+ interface EarconSound {
66
+ /** Human-readable name, e.g. "success" */
67
+ name: string;
68
+ /** Total duration in seconds (used to schedule the onEnded callback) */
69
+ duration: number;
70
+ /** Sequence of notes that make up this sound */
71
+ notes: NoteEvent[];
72
+ }
73
+ /**
74
+ * A sound preset function signature: accepts variant and pitch offset,
75
+ * returns a fully-specified EarconSound ready for the scheduler.
76
+ */
77
+ type SoundPreset = (variant: SoundVariant, pitchSemitones: number) => EarconSound;
78
+
79
+ /**
80
+ * Closes and discards the shared AudioContext.
81
+ * Useful in tests or when tearing down an SPA.
82
+ */
83
+ declare function closeAudioContext(): Promise<void>;
84
+ /**
85
+ * Replace the internal singleton — useful in tests to inject a mock.
86
+ */
87
+ declare function setAudioContext(ctx: AudioContext): void;
88
+
89
+ /**
90
+ * Converts a semitone offset to a frequency multiplier.
91
+ * e.g. +12 semitones → ×2 (one octave up)
92
+ */
93
+ declare function semitonesToMultiplier(semitones: number): number;
94
+
95
+ declare function successPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
96
+
97
+ declare function errorPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
98
+
99
+ declare function warningPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
100
+
101
+ declare function notificationPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
102
+
103
+ declare function clickPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
104
+
105
+ declare function infoPreset(variant: SoundVariant, pitchSemitones: number): EarconSound;
106
+
107
+ /** Play a success / confirmation sound */
108
+ declare function playSuccess(opts?: SoundOptions): Promise<void>;
109
+ /** Play an error sound */
110
+ declare function playError(opts?: SoundOptions): Promise<void>;
111
+ /** Play a warning sound */
112
+ declare function playWarning(opts?: SoundOptions): Promise<void>;
113
+ /** Play a notification / message sound */
114
+ declare function playNotification(opts?: SoundOptions): Promise<void>;
115
+ /** Play a UI click / toggle transient */
116
+ declare function playClick(opts?: SoundOptions): Promise<void>;
117
+ /** Play an informational / neutral tone */
118
+ declare function playInfo(opts?: SoundOptions): Promise<void>;
119
+ declare const BANK: {
120
+ readonly success: typeof successPreset;
121
+ readonly error: typeof errorPreset;
122
+ readonly warning: typeof warningPreset;
123
+ readonly notification: typeof notificationPreset;
124
+ readonly click: typeof clickPreset;
125
+ readonly info: typeof infoPreset;
126
+ };
127
+ type SoundName = keyof typeof BANK;
128
+ /**
129
+ * Play any registered sound by name.
130
+ *
131
+ * @example
132
+ * await earcon("success");
133
+ * await earcon("error", { variant: "long", volume: 0.8 });
134
+ */
135
+ declare function earcon(name: SoundName, opts?: SoundOptions): Promise<void>;
136
+ /**
137
+ * Register a custom sound under a new name so it can be played via {@link earcon}.
138
+ *
139
+ * @example
140
+ * import type { SoundPreset } from "earcons";
141
+ *
142
+ * const mySound: SoundPreset = (variant, pitch) => ({
143
+ * name: "mySound",
144
+ * duration: 0.3,
145
+ * notes: [{ frequency: 440, duration: 0.3, startAt: 0 }],
146
+ * });
147
+ *
148
+ * registerSound("mySound", mySound);
149
+ * await earcon("mySound");
150
+ */
151
+ declare function registerSound(name: string, preset: SoundPreset): void;
152
+
153
+ export { type EarconSound, type Envelope, type NoteEvent, type SoundName, type SoundOptions, type SoundPreset, type SoundVariant, type WaveShape, closeAudioContext, earcon, playClick, playError, playInfo, playNotification, playSuccess, playWarning, registerSound, semitonesToMultiplier, setAudioContext };