The first tool of the opensnes-* family (The opensnes-* tools: conventions). It turns a PCM .wav — a jump, a hit, a UI blip, a voice clip — into the .brr the SNES DSP plays, plus a header with its sizes, and it tells you what a sample costs before you commit to it. The encoder is the one smconv bakes into soundbanks and the one wav2brr used: a .brr from here is byte for byte what wav2brr wrote.
In: PCM WAV, 8- or 16-bit, mono or stereo (stereo is downmixed). Keep the source at 32 kHz or below: the DSP plays BRR at 32 kHz whatever the file said, so a 44.1 kHz source comes out lower and slower (the tool warns and says by how much).
Out: jump.brr (raw BRR, one 9-byte block per 16 samples, loop and end flags set) and jump.h:
A loop has to be a whole number of 16-sample blocks, because BRR is. When the one you give is not, the tool makes it so, in one of two ways:
A loop that does not start on a block boundary is preceded by silence so that it does. _brr_loop is the byte offset the loop comes back to; 0 means "from the start", not "no loop": _brr_loops says whether it loops.
Bake the .brr into the ROM and load it with the sizes from the header:
examples/audio/soundboard is the worked example, Audio & Music Tutorial the tutorial.
--save writes res/hum.wav.toml next to the file:
From then on opensnes-sample encode res/hum.wav loops without being told, and a --loop on the command line overrides it for that run. The file is the one the build system reads (the tool line says which tool converts the asset); a key it does not know is refused, so a typo cannot fall back to a default in silence.
Nothing is converted or written; this is how you size a sound set against the 64 KB of audio RAM before recording more.
0 done; 1 the input was refused and the message names the limit (--loop 100 50 is out of range — the file has 220 samples, START < END); 2 usage; 3 the file system. A refused input writes nothing. --json puts the result — sources, outputs, blocks, ARAM bytes, loop — on stdout as one object; -q drops the summary line; -v says what is being done.
| wav2brr | opensnes-sample |
|---|---|
| wav2brr in.wav [out.brr] | opensnes-sample encode in.wav [--out DIR] (the name follows the input) |
| --loop START END | the same, and --save keeps it in in.wav.toml |
| -v prints the load line | in.h carries the sizes; inspect the figures |
Same bytes: the golden suite of opensnes-sample compares its .brr against wav2brr's goldens.