VADPCM audio codec
  • C 85.2%
  • Python 11.5%
  • Starlark 1.9%
  • CMake 1.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-07 22:22:58 -04:00
.vscode Clean up VS Code settings 2023-09-12 00:41:45 -04:00
bazel Fix Bazel build system 2026-01-14 23:19:50 -05:00
codec Expose version number from vadpcm.h 2026-09-07 21:55:04 -04:00
common Make runtime-selectable predictor assignment 2026-08-13 00:07:48 -04:00
docs Add push instructions to docs README 2026-08-21 22:57:51 -04:00
scripts Add predictor cell statistics tool 2026-08-07 03:09:30 -04:00
stats Add stats for latest revision 2026-08-07 01:02:05 -04:00
tests Add statecheck binary to Bazel 2026-08-13 07:58:00 -04:00
vadpcm Expose version number from vadpcm.h 2026-09-07 21:55:04 -04:00
vadpcmstats Define default parameters as constant 2026-08-16 13:01:37 -04:00
.bazelrc Fix Bazel build system 2026-01-14 23:19:50 -05:00
.clang-format Create font rasterizer tool 2023-09-11 23:59:15 -04:00
.gitignore Ignore generated stats/predictor-cells.csv 2026-08-07 08:10:33 -04:00
BUILD.bazel Get entire repository to build again 2023-09-11 23:59:27 -04:00
CHANGELOG.md Add changelog 2026-08-24 00:17:41 -04:00
CMakeLists.txt CMake: Install tool and library 2026-09-07 22:22:58 -04:00
CONTRIBUTING.md Add contribution guidelines 2026-08-21 23:16:34 -04:00
LICENSE.txt Add MPL 2.0 license 2023-09-11 23:59:28 -04:00
MODULE.bazel Update Bazel dependencies 2026-08-06 23:08:45 -04:00
MODULE.bazel.lock Update Bazel dependencies 2026-08-06 23:08:45 -04:00
Properties.props MSVC: Create project for CLI 2026-01-15 00:30:46 -05:00
README.md Update links and documentation 2026-08-21 22:27:44 -04:00
SECURITY.md Add security policy 2026-08-21 22:33:02 -04:00
vadpcm.slnx MSVC: Create project for CLI 2026-01-15 00:30:46 -05:00
WORKSPACE Fix Bazel build system 2026-01-14 23:19:50 -05:00

VADPCM

VADPCM

This is an implementation of the VADPCM codec. The VADPCM codec is often used by Nintendo 64 games—this includes both homebrew games made using LibDragon and commercial games made during the 1990s and 2000s with the proprietary SDK, LibUltra.

VADPCM is licensed under the terms of the Mozilla Public License Version 2.0. See LICENSE.txt for details.

Usage

Convert an AIFF file to use VADPCM:

vadpcm encode input.aiff output.aifc

Convert a VADPCM file back to AIFF:

vadpcm decode input.aifc output.aiff

VADPCM-encoded files are always AIFF-C files with the .aifc extension. The unencoded version can be AIFF, AIFF-C, or WAV.

Project Status

The project is, as of August 2026, under active development.

What is VADPCM?

VADPCM is a variant of ADPCM. It encodes blocks of 16 samples of audio into 9 bytes of data, giving 4.5 bits per sample. There are no settings or parameters to change the bit rate; the bit rate is always 4.5 bits per sample.

The audio quality of VADPCM is good, but this codec is not competitive with codecs like Opus, Vorbis, or even MP3.

Technical Details

VADPCM uses a codebook of second-order linear predictors, and encodes the residuals using 4 bits per sample. Each block of 16 samples shares the same predictor and scaling factor. The predictors in the codebook are stored in a vector format, which makes it easy to write a high-performance decoder using SIMD instructions. The Nintendo 64 has a coprocessor, called the Reality Signal Processor, with SIMD capabilities.

Building

CMake

You can build using CMake:

cmake -B build -DCMAKE_BUILD_TYPE=Release
make -C build -j4

This places the main program at build/vadpcm.

If you are doing development work, recommended CMake flags are:

  • -G Ninja to use Ninja instead of Make,
  • -DENABLE_WARNINGS=ON to enable compiler warnings,
  • -DENABLE_WERROR=ON to treat warning sas errors,
  • -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to generate the compilation database for Clangd,
  • DCMAKE_C_FLAGS='-fdiagnostics-color=always for color warnings and errors.

Bazel

You can build using Bazel:

bazel build -c opt //vadpcm

This places the main program at bazel-bin/vadpcm/vadpcm.

If you are doing development work, generate the compilation database with hedron:

bazel run @hedron_compile_commands//:refresh_all

Recommended Bazel flags are --//bazel:warnings=error.

Development

For CMake, you may want the compile_commands.json for Clangd or your LSP to work correctly. Pass -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to CMake to generate the compile_commands.json file that Clangd uses. On Unix systems, this will be symlinked into the project source directory.