add-audio
npx skills add https://github.com/opusgamelabs/game-creator --skill add-audio
Agent 安装分布
Skill 文档
Add Audio
Add procedural music and sound effects to an existing game. BGM uses Strudel.cc for looping patterns. SFX use the Web Audio API directly for true one-shot playback. No audio files needed â everything is synthesized in the browser.
Instructions
Analyze the game at $ARGUMENTS (or the current directory if no path given).
First, load the game-audio skill to get the full Strudel patterns and integration guide.
Step 1: Audit
- Read
package.jsonto identify the engine and check if@strudel/webis installed - Read
src/core/EventBus.jsto see what game events exist (flap, score, death, etc.) - Read all scene files to understand the game flow (gameplay, game over)
- Identify what music and SFX would fit the game’s genre and mood
Step 2: Plan
Present a table of planned audio:
| Event / Scene | Audio Type | Style | Description |
|---|---|---|---|
| GameScene | BGM | Chiptune | Upbeat square wave melody + bass + drums |
| GameOverScene | BGM | Somber | Slow descending melody |
| Player action | SFX | Retro | Quick pitch sweep |
| Score | SFX | Retro | Two-tone ding |
| Death | SFX | Retro | Descending crushed notes |
Explain in plain English: “Background music will automatically loop during each scene. Sound effects will play when you do things like jump, score, or die. The first time you click/tap, the audio system will activate (browsers require a user interaction before playing sound).”
Step 3: Implement
- Install
@strudel/webif not already present - Create
src/audio/AudioManager.jsâ manages Strudel init, BGM play/stop (useshush()+ 100ms delay before new.play()) - Create
src/audio/AudioBridge.jsâ wires EventBus events to AudioManager for BGM, calls SFX functions directly - Create
src/audio/music.jswith BGM for each scene (Strudelstack()+.play()â these loop continuously) - Create
src/audio/sfx.jswith SFX for each event (Web Audio API â OscillatorNode + GainNode + BiquadFilterNode for true one-shot playback) - Add audio events to
EventBus.js(AUDIO_INIT,MUSIC_GAMEPLAY,MUSIC_GAMEOVER,MUSIC_STOP) - Wire
initAudioBridge()inmain.js - Emit
AUDIO_INITon first user interaction (game starts immediately, no menu) - Emit music events at scene transitions and SFX events at game actions
Critical: Strudel’s .play() starts a continuously looping pattern â correct for BGM, wrong for SFX. SFX must use the Web Audio API directly (see game-audio skill). Import stack, note, s, hush from @strudel/web for BGM only.
Step 4: Verify
- Run
npm run buildto confirm no errors - List all files created/modified
- Remind the user: “Click/tap once to activate audio, then you’ll hear the music”
- Note the AGPL-3.0 license requirement for
@strudel/web
Next Step
Tell the user:
Your game now has music and sound effects! Next, run
/game-creator:qa-gameto add automated tests that verify your game boots correctly, scenes transition properly, scoring works, and visuals haven’t broken.Pipeline progress:
/make-gameâ/design-gameâ/add-audioâ/qa-gameâ/review-game