12-principles-of-anima…
Audit animation code against Disney's 12 principles adapted for web. Use when reviewing motion, implementing animations, or…
Audit Web Audio API code for sound synthesis best practices. Use when reviewing procedural audio, implementing UI sounds, or checking audio parameter quality. Outputs file:line findings.
$ npx -y skills add raphaelsalaja/skill --skill generating-sounds-with-ai --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/generating-sounds-with-aiContext preview
The summary Claude sees to decide when to auto-load this skill.
Audit Web Audio API code for sound synthesis best practices. Use when reviewing procedural audio, implementing UI sounds, or checking audio parameter quality. Outputs file:line findings.
name: generating-sounds-with-ai description: Audit Web Audio API code for sound synthesis best practices. Use when reviewing procedural audio, implementing UI sounds, or checking audio parameter quality. Outputs file:line findings. license: MIT metadata: author: raphael-salaja version: "2.0.0" source: /content/generating-sounds-with-ai/index.mdx
Review Web Audio API code for sound synthesis best practices.
1. Read the specified files (or prompt user for files/pattern) 2. Check against all rules below 3. Output findings in `file:line` format
| Priority | Category | Prefix | |----------|----------|--------| | 1 | Context Management | `context-` | | 2 | Decay & Envelope | `envelope-` | | 3 | Sound Design | `design-` | | 4 | Parameters | `param-` |
Reuse a single AudioContext instance; do not create new ones per sound.
**Fail:**
function playSound() {
const ctx = new AudioContext();
// Creates new context every call
}**Pass:**
let audioContext: AudioContext | null = null;
function getAudioContext(): AudioContext {
if (!audioContext) {
audioContext = new AudioContext();
}
return audioContext;
}Check and resume suspended AudioContext before playing.
**Fail:**
function playSound() {
const ctx = getAudioContext();
// Plays immediately without checking state
}**Pass:**
function playSound() {
const ctx = getAudioContext();
if (ctx.state === "suspended") {
ctx.resume();
}
}Disconnect and clean up audio nodes after playback.
**Fail:**
source.start(); // Nodes remain connected after sound ends
**Pass:**
source.start();
source.onended = () => {
source.disconnect();
gain.disconnect();
};Use exponential ramps for natural decay, not linear.
**Fail:**
gain.gain.linearRampToValueAtTime(0, t + 0.05);
**Pass:**
gain.gain.exponentialRampToValueAtTime(0.001, t + 0.05);
Exponential ramps cannot target 0; use 0.001 or similar small value.
**Fail:**
gain.gain.exponentialRampToValueAtTime(0, t + 0.05);
**Pass:**
gain.gain.exponentialRampToValueAtTime(0.001, t + 0.05);
Set initial value before ramping to avoid glitches.
**Fail:**
gain.gain.exponentialRampToValueAtTime(0.001, t + 0.05); // No setValueAtTime before ramp
**Pass:**
gain.gain.setValueAtTime(0.3, t); gain.gain.exponentialRampToValueAtTime(0.001, t + 0.05);
Use filtered noise for clicks/taps, not oscillators.
**Fail:**
// Click sound using sine oscillator const osc = ctx.createOscillator(); osc.type = "sine"; // Results in tonal "beep" not "click"
**Pass:**
// Click sound using noise burst
const buffer = ctx.createBuffer(1, ctx.sampleRate * 0.008, ctx.sampleRate);
const data = buffer.getChannelData(0);
for (let i = 0; i < data.length; i++) {
data[i] = (Math.random() * 2 - 1) * Math.exp(-i / 50);
}Use oscillators with pitch movement for tonal sounds (pops, confirmations).
**Fail:**
// Confirmation sound using static frequency osc.frequency.value = 400;
**Pass:**
// Confirmation sound with pitch sweep osc.frequency.setValueAtTime(400, t); osc.frequency.exponentialRampToValueAtTime(600, t + 0.04);
Apply bandpass filter to shape percussive sounds.
**Fail:**
// Raw noise without filtering source.connect(gain).connect(ctx.destination);
**Pass:**
const filter = ctx.createBiquadFilter(); filter.type = "bandpass"; filter.frequency.value = 4000; filter.Q.value = 3; source.connect(filter).connect(gain).connect(ctx.destination);
Click/tap sounds should be 5-15ms duration.
**Fail:**
const buffer = ctx.createBuffer(1, ctx.sampleRate * 0.1, ctx.sampleRate); // 100ms is too long for a click
**Pass:**
const buffer = ctx.createBuffer(1, ctx.sampleRate * 0.008, ctx.sampleRate); // 8ms is appropriate for a click
Bandpass filter for clicks should be 3000-6000Hz.
**Fail:**
filter.frequency.value = 500; // Too low, sounds muffled
**Pass:**
filter.frequency.value = 4000; // Crisp, present
Gain values should not exceed 1.0 to prevent clipping.
**Fail:**
gain.gain.setValueAtTime(1.5, t);
**Pass:**
gain.gain.setValueAtTime(0.3, t);
Filter Q for clicks should be 2-5 for focused but not harsh sound.
**Fail:**
filter.Q.value = 15; // Too resonant, harsh
**Pass:**
filter.Q.value = 3; // Focused but natural
When reviewing files, output findings as:
file:line - [rule-id] description of issue Example: lib/sounds.ts:23 - [envelope-exponential-decay] Using linearRampToValueAtTime instead of exponential lib/sounds.ts:45 - [context-reuse-single] Creating new AudioContext on each call
After findings, output a summary:
| Rule | Count | Severity | |------|-------|----------| | `context-reuse-single` | 1 | HIGH | | `envelope-exponential-decay` | 3 | MEDIUM | | `param-click-duration` | 1 | LOW |
When user describes issues, translate to parameter changes:
| User Says | Parameter Change | |-----------|------------------| | "too harsh" | Lower filter frequency, reduce Q | | "too muffled" | Higher filter frequency | | "too long" | Shorter duration, faster decay | | "cuts off abruptly" | Use exponential decay | | "more mechanical" | Higher Q, faster decay | | "softer" | Lower gain, triangle wave |
A skill file based on the articles written on userinterface.wiki. Designed for designers and engineers to help them build better user interfaces.
Audit animation code against Disney's 12 principles adapted for web. Use when reviewing motion, implementing animations, or…
Audit Motion/Framer Motion code for AnimatePresence best practices. Use when reviewing exit animations, modals, or presence…
Build icon components where any icon morphs into any other through SVG line transformation. Use when asked to "create morphing…
Audit CSS for pseudo-element best practices and View Transitions API usage. Use when reviewing hover effects, decorative layers,…
Audit UI code for audio feedback best practices. Use when reviewing sound implementation, checking audio UX decisions, or…
Audit animation code for correct timing function selection. Use when reviewing motion implementations, debugging animations that…