Skip to content
maximilianfeixPublic

About

Game sound effects as code: 180 CC0 SFX, a 2.9 kB Web Audio player, a CLI to WAV/OGG and an agent skill. No audio files.

Topics

Resources

Contributing

Security policy

Stars

135 stars

Watchers

0 watching

Forks

Repository files navigation

plinkfx: game sound effects as code

274 game sound effects, written as code. Coins, jumps, hits, lasers, explosions, UI clicks and the rest of what a game needs, each one a few readable numbers that a 3.1 kB player turns into sound. CC0, no audio files, no account.

The plinkfx gallery: clicking tiles plays coin, jump, laser, explosion and more; each tile shows its waveform

▶ Hear all 274 in your browser (one click per sound, tweak any of them and share the link) · play the 30-second demo game · watch the 30 s video with sound

npm i plinkfx
import { play } from "plinkfx";

play("coin");

Each sound has four takes, and play picks a different one from the last, so the hundredth coin doesn't sound like a loop.

More ways to play: options, game setup, tree-shaking, your own sound

By name (every sound included, 23.8 kB gzipped):

import { play, volume, muted } from "plinkfx";

play("laser");
play("coin", { volume: 0.5, rate: 1.2 });   // quieter, a bit higher
play("step-wood", { variant: 2 });          // a specific take (0-3)
play("step-wood", { pan: -0.6 });           // to the left
play("coin", { delay: 0.1 });               // 100 ms later
play("combo-chain", { rate: 2 ** (n / 12) }); // n-th combo step, a semitone higher each
volume(0.8);                                // master volume, 0..1
muted(true);                                // mute everything, muted() reads it

The player protects your mix. The same sound started again within 30 ms is skipped (cooldown), so 30 coin pickups in one frame make one coin, not one deafening stack. At most 4 copies of a sound play at once (voices); one more stops the oldest with a short fade. Both are per call:

play("step-grass", { cooldown: 0.08 });     // footsteps: at most one every 80 ms
play("explosion", { voices: 2 });           // keep the mix clear
play("click", { cooldown: 0, voices: 16 }); // off

Loops: rain-loop, wind-loop, engine-idle and force-field are seamless and loop until you stop them. play() returns a voice you can stop (with a fade) or bend:

const engine = play("engine-idle");
engine?.rate(1.6);                          // revs up, gliding
engine?.stop(0.5);                          // fade out over 0.5 s
play("coin", { loop: true });               // any sound can loop; loop: false plays a loop sound once

play() returns undefined when it skips a sound (on the server, inside the cooldown, before the first click), hence the ?.. The voice's node is the AudioBufferSourceNode if you need more.

muted() is not saved. To remember it, one line at startup and one where you toggle it:

muted(localStorage.muted == "1");
localStorage.muted = muted(!muted()) ? "1" : "0";

In a game: browsers keep audio locked until the first click or key press. unlockAudio() resumes it on that first gesture (and on iOS lets sounds play with the silent switch on). Sounds triggered before that are skipped, not saved up into one loud burst. preload() renders sounds in idle time so the first play has no delay; stopAll() is for pause screens.

import { play, preload, stopAll, unlockAudio } from "plinkfx";

unlockAudio();
preload(["jump", "coin", "hit", "explosion"]);
// ...
stopAll();

Everything is safe to import on the server (Next.js, Nuxt, SvelteKit): play() and volume() do nothing there.

Only what you use (player plus one sound: 3 kB gzipped). Importing anything from "plinkfx" includes every sound, so use the subpaths when size matters:

import { play } from "plinkfx/core";
import { coin, jump } from "plinkfx/sounds";

play(coin);

Your own sound is a plain object. Tweak any sound in the gallery, open the "params" tab and paste:

import { play } from "plinkfx/core";

const blip = {
  layers: [
    { wave: "square", duty: 0.25, freq: 988, arp: [0, 5], arpRate: 0.07, h: 0.05, d: 0.3, lp: 7000 },
    { wave: "sine", freq: 1976, arp: [0, 5], arpRate: 0.07, d: 0.22, gain: 0.5 },
  ],
  verb: [0.2, 0.12],
};
play(blip);

All fields are documented in skills/plinkfx/reference.md.

React, a two-line hook is enough:

import { play } from "plinkfx";
const useSfx = (name) => useCallback((opts) => play(name, opts), [name]);

Vue / Svelte: call play("coin") from any click handler; unlockAudio() once in onMounted / onMount.

Without a bundler, straight from a CDN:

<script type="module">
  import { play, unlockAudio } from "https://esm.sh/plinkfx@0";
  // or https://cdn.jsdelivr.net/npm/plinkfx@0/+esm
  unlockAudio();
  document.body.onclick = () => play("coin");
</script>

Deno / Bun: deno run -A npm:plinkfx render coin -o coin.wav, bunx plinkfx render coin.

What's inside

Category Sounds Examples
UI 32 click click-soft toggle-on confirm error notify swipe plink
Pickups 19 coin coin-double coin-bag gem key heart ka-ching
Jump & land 12 jump jump-double jump-cartoon land land-heavy spring
Hits 20 hit hit-heavy punch hurt enemy-die sword-hit block crit
Explosions 10 explosion explosion-big explosion-retro firework implosion
Power-ups 12 powerup level-up extra-life shield-on heal charge-up
Shots & lasers 21 laser blaster zap pew gunshot ricochet bow-twang reload
Footsteps 12 step-grass step-stone step-wood step-metal step-snow step-water
Magic 13 sparkle spell-cast fireball ice teleport harp lightning
Alerts 13 alarm warning low-health heartbeat countdown radar-ping
Jingles 11 victory checkpoint level-complete game-over secret-found achievement
Doors & mechanics 10 door-open door-heavy lock-open chest-open lever ratchet
play("combo-chain", { rate: 2 ** (n / 12) }); // n-th combo step, a semitone higher each
World 13 whoosh swing splash water-drop wind glass-break engine-idle (loop) force-field (loop)
Creatures 9 bat-flap slime-blob growl-small ghost-moan bee-buzz voice-babble
Nature 8 thunder-far rain-drop bird-chirp frog-croak stone-drop rain-loop (loop) wind-loop (loop)

Every sound with a one-line description: npx plinkfx list, or the gallery.

Files for your engine

Godot, Unity, Phaser, Defold, LÖVE or anything else that loads audio files.

Download every sound as WAV + OGG (zip), all four takes, 48 kHz mono, in category folders. No install needed. Or render them yourself:

npx plinkfx export sfx/                       # every sound as 48 kHz mono WAV, in category folders
npx plinkfx export sfx/ --format both         # WAV + OGG (OGG needs ffmpeg)
npx plinkfx export sfx/ --variants            # all four takes of each sound
npx plinkfx render explosion-big -o boom.wav  # one sound
  • Godot: drop the folder into res:// and turn the importer's Normalize off. The levels are already matched.
  • Unity: WAV with Decompress On Load for short effects. The files are mono already.
  • Phaser: this.load.audio("coin", ["sfx/pickup/coin.ogg", "sfx/pickup/coin.wav"]), or skip files and call play("coin") from plinkfx.

Each sound in the gallery also has a "download .wav" button. Ready-made players for the exported files: Godot, Unity, and a Phaser example that needs no files at all.

One audio sprite (Phaser, Howler)

For the web, one file with every sound means one request instead of 274:

npx plinkfx export public/sfx --sprite --format both           # all sounds, 0.1 s of silence between them
npx plinkfx export public/sfx --sprite --only ui,pickup        # only some categories

That writes plinkfx-sprite.ogg and plinkfx-sprite.wav (take 0 of each sound, back to back), plinkfx-sprite.phaser.json (Phaser's audio sprite format) and plinkfx-sprite.json (Howler's sprite map, { "coin": [offsetMs, durationMs] }). Sprite names are the sound names. --gap 0.25 changes the silence between sounds.

// Phaser 3 or 4
preload() {
  this.load.audioSprite("sfx", "sfx/plinkfx-sprite.phaser.json", ["sfx/plinkfx-sprite.ogg", "sfx/plinkfx-sprite.wav"]);
}
create() {
  this.sound.playAudioSprite("sfx", "coin");
}
// Howler
import { Howl } from "howler";
const sprite = await (await fetch("sfx/plinkfx-sprite.json")).json();
const sfx = new Howl({ src: ["sfx/plinkfx-sprite.ogg", "sfx/plinkfx-sprite.wav"], sprite });
sfx.play("coin");

The agent skill

plinkfx ships a skill for Claude Code, Codex, Cursor and other agents. Ask for "a heavy door for a dungeon level" and the agent starts from the nearest catalogue sound, writes a parameter file, renders it, measures it against that reference (loudness, true peak, duration, brightness) and adjusts. It runs on the CLI, offline. Agents can't hear, so the skill tells yours to say so and hand you the WAV to judge.

Terminal: plinkfx list, level, measure and render for a dungeon door sound

npx skills add maximilianfeix/plinkfx                 # Claude Code, Codex, Cursor and others

In Claude Code you can also add the repo as a plugin marketplace:

/plugin marketplace add maximilianfeix/plinkfx
/plugin install plinkfx@plinkfx

A full run, with the real terminal output, is in docs/skill-example.md.

Use from an agent (MCP)

plinkfx mcp is an MCP server. It runs locally over stdio and needs no network or API key.

claude mcp add plinkfx -- npx -y plinkfx mcp          # Claude Code

Cursor (.cursor/mcp.json) and other clients that take JSON:

{
  "mcpServers": {
    "plinkfx": { "command": "npx", "args": ["-y", "plinkfx", "mcp"] }
  }
}

Codex (~/.codex/config.toml):

[mcp_servers.plinkfx]
command = "npx"
args = ["-y", "plinkfx", "mcp"]

The tools:

Tool What it does
list_sounds Search the catalogue by category or words
show_sound The JSON recipe of a sound
render_sound Write a WAV from a name or a recipe. Returns the path and the measurements. With png: true it also returns a waveform and spectrogram image
measure_sound Loudness, true peak, duration and brightness of a sound or a WAV file
check_sound Look for clicks, cut tails, DC, clipping, silent padding and loudness off target

The same checks work from the shell. plinkfx check exits with 1 when a check fails:

npx plinkfx check sounds/door.json --cat mechanic   # your sound, against a category's loudness
npx plinkfx check --all                             # the whole catalogue
npx plinkfx render door-heavy --png door.png        # see a sound: waveform + spectrogram

How the sounds are measured

npm run bake renders and levels every sound, and the test suite checks all four takes of each one on Linux, macOS and Windows:

  • Loudness: each category has a target, measured as max momentary loudness per ITU-R BS.1770 (UI and footsteps −20 LUFS, hits −15, explosions −14, the rest in between). The four takes of a sound stay within ±1.5 LU of the target and average within 0.5 LU. Short transients such as clicks, hits and steps often reach the peak ceiling first; those sit below the target and are marked limited in the catalogue.
  • Peaks: true peak (4× oversampled) ≤ −1 dBTP for every take at 44.1 kHz. At 48 kHz the noise comes out differently, and a few takes land between −1 and −0.4 dBTP. plinkfx check --all lists them.
  • The meter itself: tested against the BS.1770 reference sine, and it agrees with ffmpeg's ebur128 filter (explosion-big: −19.9 LUFS integrated in both).
  • Clean edges: at least 1 ms attack, a 5 ms fade at the end, a DC blocker, the silent tail trimmed.
  • Determinism: the same parameters and take always give the same samples. A hash of every take is part of the tests.
  • Variation: the four takes differ (pitch spread per sound, slightly different decay, new noise).
  • Ears: numbers can't tell a good sound from a dull one. A spectrogram of every category is checked during development (npm run bake -- --reels), but a headphone pass over all sounds isn't finished yet. If one sounds wrong to you, open an issue with its name.

The meter is exported too: import { measure } from "plinkfx/meter", or npx plinkfx measure file.wav for any WAV.

How it compares

sfxr (DrPetter, 2007) started this genre, and these are the tools most people reach for today:

plinkfx ZzFX jsfxr Kenney audio packs
What it is named sound library as code tiny synth + designer sfxr port: generator + library WAV/OGG asset packs
Size (gzip) 3.1 kB player, 23.8 kB with all sounds ~1.3 kB ~6.3 kB no code, files
Licence CC0 sounds, MIT code MIT Unlicense CC0
Named sounds 274 4 examples, random generators random generators per category many, generic file names
Matched loudness yes, measured in tests no no not stated
Same input, same samples yes, seeded and hash-tested only with randomness set to 0 per saved parameter set fixed files
Variations 4 seeded takes per sound edit or randomise mutate separate files
Export WAV, OGG, CLI WAV (designer) WAV already files

ZzFX is smaller and the right pick for js13k. jsfxr is great for exploring random sounds. Kenney packs have real recordings. plinkfx is for when you want a finished set that sounds consistent and that you can read, tweak and ship. Also have a look at 8bit-sfx and make-sfx (game sounds as code), uisfx (UI sounds), and earshot if you want an agent to listen to audio.

Licence

Sounds: CC0 1.0, public domain

Use them in any game, app, video or stream, commercial or not. No credit needed. LICENSE-SOUNDS

Code: MIT

The engine, CLI, gallery and skill. LICENSE

Contributing

New sounds are the best contribution: open the gallery, tweak something until it fits a moment in your game, and open an issue or PR with the params. Look for issues labelled good first issue and new sound. See CONTRIBUTING.md.

中文说明

About

Game sound effects as code: 180 CC0 SFX, a 2.9 kB Web Audio player, a CLI to WAV/OGG and an agent skill. No audio files.

Topics

Resources

Contributing

Security policy

Stars

135 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages