Reference
Sound controls
import { … } from "@johnmorrisdotca/domino/tile-sounds";
19.3 kB minified and gzipped, with everything it imports (measured with esbuild)
THE SOUNDS OF A DOMINO TABLE: tiles shuffled, a tile drawn from the boneyard, a tile laid, a knock on the table for a pass. The recordings are poker chips set down and handled (Kenney's Casino Audio, CC0; see CREDITS.md), the nearest recorded sound of a hard tile on a table that is free to use. They are loaded the first time a sound is played and never before, so a page that stays silent never fetches them. Where they cannot be loaded or decoded, a short sound made in the browser stands in. Nothing here throws: a platform with no audio, a context the browser holds still, or a failed decode is simply silent.
Domino never makes a sound by itself. A table asks for one with play.
Exports
| Name | Kind | What it is |
|---|---|---|
createTileSounds | function | A table's tile sounds. |
MOST_SOUNDS_AT_ONCE | constant | As many sounds as one call plays: fifteen tiles drawn are eight clicks, not a wall of noise. |
PlayTileSoundOptions | type | How one sound is played. |
soundTimes | function | When each of count sounds starts, in milliseconds from the first: one every gap, and no more than MOST_SOUNDS_AT_ONCE, spread over the same time. |
TILE_SOUND_KINDS | constant | Every kind of sound, in the order a game meets them. |
TileSoundData | type | The recordings, by name (lay-2), as base64 AAC. |
TileSoundKind | type | One kind of sound: shuffle the tiles stirred face down, draw a tile taken from the boneyard, lay a tile set down on a train, knock a rap on the table, which is how a pass is announced. |
TileSounds | type | A table's sounds: play one, mute and unmute, change the volume, close when the table goes. |
TileSoundsOptions | type | How a table's sounds are made. |
TileSoundWindow | type | The parts of a window the sounds use: an audio context and atob. |