Skip to main content

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.

songprint is a pure-Kotlin library that generates Shazam-compatible binary audio signatures from raw PCM input. Feed it roughly 12 seconds of audio and it produces the same compact constellation-map signature a Shazam client would send to the discovery endpoint — letting you identify songs without an API key, without any native code, and without pulling in a single runtime dependency. It was built for and battle-tested in RadioShake, a live-radio app for Android that identifies tracks as they stream, and its core module is written in pure common Kotlin so it slots naturally into a Kotlin Multiplatform shared module.

Quickstart

Install songprint and identify your first song in under 5 minutes.

PCM Preparation

Convert any audio format into the 16 kHz mono PCM the generator expects.

Recognition

Send a signature to the Shazam endpoint and parse the JSON response.

Algorithm

Deep-dive into the spectrogram, peak-spreading, and binary encoding pipeline.

Key Features

Pure Kotlin Core

No JNI, no native shared libraries, no platform-specific glue. The entire fingerprinting pipeline is implemented in common Kotlin.

Zero Runtime Dependencies

The library has no runtime dependencies beyond the Kotlin standard library. There is nothing extra to manage in your dependency graph.

Shazam-Compatible Binary Format

Produces the exact binary signature format Shazam clients send, including the 0xcafe2580 magic header, delta-encoded peak data, and an embedded CRC32.

Built-in PCM Conversion Utilities

Pcm.bytesToShorts decodes raw 16-bit LE PCM bytes, and Pcm.resampleToMono16k converts any sample rate and channel count to 16 kHz mono using channel averaging and linear-interpolation resampling.

KMP-Compatible Core

The signature-generation core uses no java.io, java.nio, or java.util.zip. It compiles unchanged on any Kotlin Multiplatform target, making it suitable for shared KMP modules.

Deterministic, Reusable SignatureGenerator

generateSignature resets all internal state on every call, so a single SignatureGenerator instance can be reused across multiple audio clips without creating a new object each time.

Caveats

Unofficial endpointRecognitionClient posts to an undocumented Shazam discovery endpoint that has been stable for years and is used by projects like SongRec, but it is not an official API. It can change or disappear without notice. Treat it as unsuitable for high-volume or load-bearing commercial use, and be respectful with request rates. SignatureGenerator is not thread-safe — each instance maintains internal ring buffers and mutable state. Do not share a SignatureGenerator across threads. Instances are cheap to construct, so the recommended pattern is one instance per thread (or per coroutine that needs to stay on a single thread). Trademark disclaimer — “Shazam” is a trademark of Apple Inc. songprint is not affiliated with or endorsed by Apple; the name is used solely to describe format compatibility.

Licence

songprint is released under the MIT licence.

Build docs developers (and LLMs) love