A songprint signature is a compact binary representation of a constellation map of spectral peaks. It’s the same format Shazam clients generate and send to the discovery endpoint — a few KB for 12 seconds of audio. Understanding the layout is useful when debugging signatures, building custom decoders, or verifying byte-level compatibility with other Shazam-compatible tools.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hitenpatel/songprint/llms.txt
Use this file to discover all available pages before exploring further.
Header structure
The signature opens with a 48-byte fixed header followed by an 8-byte content header. All multi-byte integers are little-endian.| Bytes | Value | Purpose |
|---|---|---|
| 0–3 | 0xcafe2580 | Magic number identifying a Shazam signature |
| 4–7 | CRC32 (u32) | CRC32 of every byte from offset 8 to the end of the file |
| 8–11 | Content length | Number of bytes from offset 8 to the end |
| 12–15 | 0x94119c00 | Second magic constant |
| 16–27 | 0x00000000 | Reserved / zeroed |
| 28–31 | 3 << 27 | Fixed flag field |
| 32–39 | 0x00000000 | Reserved / zeroed |
| 40–43 | Sample count | Total PCM samples processed, plus 0.24s × 16000 samples |
| 44–47 | (15 << 19) + 0x40000 | Fixed flag field |
| 48–51 | 0x40000000 | Content header magic |
| 52–55 | Content section length | Length of the band data that follows, including these 8 bytes |
Bytes 16–27 and 32–39 are always zero in signatures produced by songprint. The reference SongRec implementation documents these as reserved fields with no defined meaning.
Band sections
Peaks are grouped into four frequency bands. Each band that contains at least one peak contributes a section to the content area. Bands with no peaks are omitted entirely.| Band | Frequency range | Section marker |
|---|---|---|
| 0 | 250–520 Hz | 0x60030040 |
| 1 | 520–1450 Hz | 0x60030041 |
| 2 | 1450–3500 Hz | 0x60030042 |
| 3 | 3500–5500 Hz | 0x60030043 |
Section length (4 bytes)
Little-endian
uint32 giving the byte length of the raw peak data that follows (not including the marker, this length field, or the alignment padding).Peak data (variable)
The encoded peaks for this band. See Peak encoding below.
Peak encoding
Within each band section, peaks are sorted by FFT frame number and encoded sequentially. Each peak occupies 5 or 10 bytes depending on the delta to the previous peak. Delta encoding of frame numbers:- Compute the delta between this peak’s FFT frame number and the previous peak’s frame number in the same band (first peak uses
0as the prior value). - If
delta < 255: write a single byte containing the delta. - If
delta >= 255: write an escape byte0xFF, then write the absolute FFT frame number as a little-endianuint32(5 bytes for the escape sequence), then resetprevFftPasstopeak.fftPassNumberand fall through to the normal delta byte — which is now always0x00(1 byte).
uint16 fields:
| Field | Size | Content |
|---|---|---|
| Peak magnitude | 2 bytes | Log-scaled magnitude: ln(mag) × 1477.3 + 6144.0, truncated to Int |
| Corrected frequency bin | 2 bytes | Sub-bin position at 1/64-bin precision from parabolic interpolation |
CRC32
The 4-byte CRC32 at bytes 4–7 of the header covers every byte from offset 8 to the end of the signature — the content-length field, both magic constants, the band sections, and all padding. It is computed before the value is written back into the header. songprint uses a pure-Kotlin CRC32 implementation that carries no dependency onjava.util.zip, making the core compile on any Kotlin Multiplatform target:
uint32: