Skip to content
finthetechguyPublic

About

Library and utility for creating, rendering, playing and editing NintendoWare sound sequences, archives, and waves

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

sarkit

A toolkit for NintendoWare-format sound archives. It can read, play, convert and build the .bcsar sound archives found in 3DS software and the .bfsar archives found in Wii U software.

Features

  • Inspect archives, sequences, banks and wave files.
  • Render/play sequence, stream and wave sounds.
  • Convert sequences to and from MIDI and text MML, banks to and from SoundFont and TOML, and waves to and from WAV.
  • Build a new archive from a project file, unpack an archive into a project, or patch sounds of an existing archive.
  • Embed (Library) the playback engine in a Rust or C program. Engine core is no_std.

Supported consoles

Console Files Read and write Play Build, unpack and patch
3DS .bcsar, .bcseq, .bcbnk, .bcwar, .bcwav, .bcstm … yes yes yes
Wii U .bfsar, .bfseq, .bfbnk, .bfwar, .bfwav, .bfstm … yes yes yes
Switch .bfsar no no no

Switch support is planned.

Install

Prebuilt binaries for Windows, macOS and Linux are on the releases page.

To build from source (Rust 1.85 or newer):

cargo install --git https://github.com/finthetechguy/sarkit sarkit-cli

On Linux, audio output needs the ALSA headers (libasound2-dev on Debian/Ubuntu).

Command line

Run sarkit help <command> for help with each command.

Inspect

sarkit info game.bcsar                    # summary and table sizes
sarkit list game.bcsar                    # every sound with its kind, file and banks
sarkit tree game.bcsar --sound BGM_TITLE  # banks, wave archives and files a sound uses
sarkit extract game.bcsar -o files/       # write each stored file on its own
sarkit disasm game.bcsar BGM_TITLE        # print a sequence as text MML
sarkit census roms/                       # count sequence commands across a folder

Listen

sarkit render game.bcsar BGM_TITLE -o title.wav --secs 60
sarkit play game.bcsar BGM_TITLE
sarkit testnote game.bcsar BGM_TITLE 0 60 -o note.wav   # one held note: program, key

Use --solo, --tracks or --mute to pick tracks, --quality to set interpolation and voice count, and --seed to fix random commands.

Convert

sarkit export game.bcsar BGM_TITLE -o title    # title.mid and a matching title.sf2
sarkit compile song.mid -o song.bcseq          # MIDI to sequence
sarkit asm song.mml -o song.bcseq              # text MML to sequence
sarkit bank piano.bcbnk -o piano.toml          # bank to TOML text, and back
sarkit decode jingle.bcwav -o jingle.wav       # loop kept in a `smpl` chunk
sarkit encode loop.wav -o loop.bcstm --codec dsp

Build, unpack and patch

sarkit unpack game.bcsar -o project/
sarkit build project/project.toml -o game.bcsar --emit-ids sounds.h
sarkit patch game.bcsar --replace BGM_TITLE=new_title.mid -o patched.bcsar
  • unpack writes sequences as MML, banks as TOML and audio as WAV, along with MIDI and SoundFont copies.
  • build reads a project.toml manifest of players, sounds, banks and groups. --emit-ids writes the sound IDs as a C header or Rust file. See examples/project for a small project with every kind of sound.
  • patch gives new sources to some sounds or banks and keeps all IDs, names and other bytes as they were. It prints how much each group grows, since games load groups into fixed-size memory; --strict-size refuses any growth. A patch.toml file can list many changes at once, and --add NAME@LIKE=FILE adds a sound with the settings of an existing one.
  • import-soundmaker turns a SoundMaker .cspj project into a manifest.
  • The same commands work on Wii U .bfsar archives. unpack writes platform = "wiiu" into the manifest, and build then writes a Wii U archive.

Library

Each sub-system has a crate.

Crate What it does no_std
sarkit-format Read and write archive, sequence, bank, wave, stream and group files yes
sarkit-codec PCM, DSP-ADPCM and IMA-ADPCM decode and encode yes
sarkit-engine Playback engine: sequencer, voices, envelopes, LFO, filters, mixer yes
sarkit-convert MIDI, MML, SoundFont, TOML and WAV conversion no
sarkit-build Build, unpack and patch whole archives no
sarkit-output Play the engine on the default audio device no
sarkit-ffi C interface to the engine no
sarkit-cli The CLI sarkit command no
use sarkit_engine::{Engine, EngineConfig};
use sarkit_format::SoundArchive;

let archive = SoundArchive::from_bytes(&std::fs::read("sound.bcsar")?)?;
let (index, _) = archive.sound_by_name("BGM_TITLE").ok_or("no such sound")?;

let mut config = EngineConfig::default();
config.sample_rate = 44_100;
let mut engine = Engine::new(archive, config);
let handle = engine.play(index)?;

// Interleaved stereo, left then right.
let mut buffer = vec![0.0f32; 2 * 1024];
engine.render(&mut buffer);
engine.stop(handle, 500);

C

sarkit-ffi builds a static and a shared library, with the header at crates/ffi/include/sarkit.h. examples/c/render.c loads an archive and renders one sound; cargo xtask c-example builds and runs it.

Notes

sarkit is not affiliated with or endorsed by Nintendo. Nintendo, NintendoWare, Nintendo 3DS and Wii U are trademarks of Nintendo.

No Nintendo assets or audio is provived with sarkit, you must dump audio archives from your own games and applications.

Licence

MIT.

About

Library and utility for creating, rendering, playing and editing NintendoWare sound sequences, archives, and waves

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages