# bake
Bakes chipSfx's synthesised 8-bit sounds (the presets in `chipSfx.sfx`) into PCM soundClip assets under `chipSfx.package/sounds`, the clips the package ships and plays. Run it again after changing or adding a preset.
- `generate(names?) -> { path }`: bake every preset in `Sfx.NAMES`, or only the names given.
- `bake(name) -> path`: bake one.
```luau
require("chipSfx.bake").generate()
```
# chipSfx: 8-bit sound effects for platformers
Eleven ready-made 8-bit sound effects for any Zero game, made the way an old console sound chip makes them: **jump, land, hard landing, dash, wall jump, gem, checkpoint, death, game over, level clear and a UI click**. Each one is synthesised from square (with duty cycle), stepped triangle and 15-bit noise voices with pitch sweeps, vibrato and a stepped envelope, and shipped as a soundClip, so playing one costs nothing. Play a sound on this peer with one call; another player's sounds come out quieter and fade with distance, and nothing goes over the network.
It is the sound of **twoDKit** (the 2D pixel platformer kit), which installs it.
## Install
`zero zeromind installAsset 08ec245b-eb89-41f3-a761-1e92b71c1bac` in the engine shell, or search ZeroMind for "chipSfx" or "8-bit sound effects". No dependencies.
## Play a sound
```luau
local Sfx = require("chipSfx.sfx")
Sfx.play("jump") -- your own moment, full volume
Sfx.play("gem", { isLocal = false, x = 12, y = 3, -- someone else's: quieter,
listenerX = 4, listenerY = 3 }) -- fading with distance
Sfx.setVolume(0.4) -- this peer's master volume
```
## Make your own sound
Add a preset (voices of `square`, `triangle` or `noise` with a duration, start and end pitch, duty, vibrato and decay), hear its samples with `Sfx.render`, and bake it into a clip with `chipSfx.bake`:
```luau
local Sfx = require("chipSfx.sfx")
local pcm = Sfx.render({ voices = { { wave = "square", duty = 0.25, dur = 0.1, f0 = 300, f1 = 900, decay = true } } })
```
`sfx.module`'s README lists every field and function.
## Changelog
- **1.0.1**: the install line names this package's id.
- **1.0.0**: first release, split out of twoDKit (where it was `twoDKit.sfx` and `twoDKit.artgen.sfx`, which still work).