Skip to main content

Module audio

Module audio 

Source
Expand description

The Playdate’s sounds and music, baked for pdc: every sound file of the audio the game ships there, and each of its music tracks, decoded (OGG Vorbis or WAV), mixed down to mono and written as an IMA ADPCM WAV at its own 44.1 kHz, under BAKED_SOUND_DIR and BAKED_MUSIC_DIR, where shuyi-playdate opens them. pdc turns each into a .pda.

Decoding music takes seconds, so each file made is kept in the build’s cache under its source’s checksum, in a folder named after FORMAT, so a new conversion never reuses an old file.

Structs§

Job
One file to bake.

Constants§

BLOCK_BYTES
Bytes in one ADPCM block: what both tools the SDK’s docs name (ffmpeg’s adpcm_ima_wav and Audacity) write for mono at 44.1 kHz, so it is what pdc is known to read.
BLOCK_SAMPLES
Samples in one mono block: the one in its header, then two a byte.
FORMAT
The conversion’s version: the cache folder is named after it, so a change to what is written must change it.

Functions§

adpcm_wav
samples (mono, SAMPLE_RATE) as an IMA ADPCM WAV file: blocks of BLOCK_BYTES, the last padded with silence, and a fact chunk with the real number of samples, to which pdc trims it, so a looped track loops with no gap.
bake
Bakes jobs into into, through the cache in cache, which holds each result under its source’s checksum and length.
cache_dir
The cache of baked files under the build’s folder build.
decode
The mono samples of the audio file bytes named name (.wav, or else OGG Vorbis), at SAMPLE_RATE: a stereo file’s channels are averaged.
jobs
The files to bake of what the game ships: each sound file once, unless the build leaves it out, and the file of each music cue, read from root’s music folder where the game doesn’t read them itself. Two files that would land on one path are an error, and so is a file that can’t be read.