Introduction
Musepack (formerly MPEGplus, MP+) is a lossy audio codec made for music at high quality. It uses the same 32-band polyphase filter bank as MPEG Layer I and II, codes 36 samples of each band in every frame (1,152 samples a channel), and replaces the Layer II bit allocation tables and fixed scalefactor grouping with Huffman codes that adapt to the signal. Files use the extension .mpc.
Two stream versions are in use today: stream version 7 (SV7), a stream of frames after a fixed header, and stream version 8 (SV8), a stream of keyed packets. The two have different containers and different entropy coding, but the same filter bank, quantisers and scalefactors. Older streams (versions 1 to 6) have no marker and are described on the SV4 to SV6 page.
Structure
An SV8 file starts with the four bytes MPCK and then holds packets. Each packet is a two-letter key, a size that counts the whole packet and a payload. A stream header (SH) comes first, then replay gain (RG), optional encoder information (EI), an optional seek table offset (SO), the audio packets (AP), a seek table (ST) and chapter packets (CT), and finally the stream end packet (SE). Tags follow the stream end.
0Marker the bytes MPCK4 bytes4Packets key, size, payload; SH, RG, EI, SO, AP (many), ST, CT, SEvaries…Tags APEv2, ID3v1 or Lyrics3 after the stream endoptional
An SV7 file starts with the three bytes MP+ and a version byte, followed by a header of six 32-bit words and one more byte (25 bytes, 200 bits), and then frames one after another, each with a 20-bit length. All 32-bit words are stored little-endian, and the bits of each word are read from the most significant bit down.
0Header MP+, version, frame count, band limit, profile, sample rate, replay gain, gapless fields, encoder25 bytes25Frames 20-bit length, then the fields of one frame; frames follow each other without paddingvaries…Padding to a whole 32-bit word0 to 3 bytes…Tags APEv2, ID3v1 or Lyrics3optional
The reference pages give every field:
- SV8 packets – the packet syntax and every packet: SH, RG, EI, SO, ST, CT, SE and AP
- SV7 header – the 200-bit header, the profiles and the gapless fields
- Frames – the fields of an SV8 frame and of an SV7 frame, band by band
- Entropy coding – the codes the fields use: Huffman, canonical Huffman, logarithmic and enumerative codes
- Requantisation – turning sample codes into subband samples: resolutions, scalefactors and mid/side
- Synthesis – the 32-band filter bank, the output length and the decoder delay
- Tags – where tags sit in the two versions
- SV4 to SV6 – the old stream versions: header, frames and end of stream
- Tables – every Huffman code, the code tables, the requantisation constants, the transform constants and the synthesis window
The filter bank is the one of MP2 and MP1. Tags are the ones of MP3: APEv2 is the usual one.
What the pages follow
The reference follows the Musepack specifications archived from the old project wiki (SV7 header, SV8), the official source code and, for the old versions, the 2000 decoder library. The viewer decodes every stream version from 1 to 8 to the same sound as those decoders (within one step of a 16-bit sample; versions 1 to 3, constant bit rate, intensity stereo and blocks of several frames against the 2000 library), shows every packet, frame, field and sample code, and lists each frame it cannot read to the end. Every table the decoders use is on the Tables page. The SV7 frame layout is not part of the archived specification (the wiki page is missing from the archive); it is taken from the official source code.
Sources
- Musepack SV8 specification and SV7 specification (the header only), from the old project wiki, archived 2013 (links below).
- The official Musepack source, revision 475: the SV7 and SV8 decoder (
libmpcdec), the encoder, the Huffman and requantisation tables and the synthesis filter bank. - libmpcdec 1.2.6: the decoder for stream versions 4 to 7, for the old header, frame layout and end of stream.
- The 2000 Musepack decoder library for Windows (
mppdecoder.cpp,mppdecoder.lib): stream versions 1 to 3, constant bit rate, intensity stereo and block sizes above 1. - mppenc 1.16, the old SV7 encoder, for the SV7 test streams.
- APEv2 specification (Hydrogenaudio), for tags.
Links
Software
- Musepack tools – the official encoder and decoder, mpcenc and mpcdec (Windows, macOS, Linux)
- foobar2000 – free music player and converter that plays Musepack (Windows, macOS, mobile)
- VLC media player – free player for almost any audio or video file (Windows, macOS, Linux, mobile)
- FFmpeg – command-line tool that decodes SV7 and SV8 (Windows, macOS, Linux)
Developers
- libmpcdec – the official decoder library, with the encoder and tools in the same source (C)
- libavcodec – FFmpeg’s decoders for SV7 and SV8 (C)
Reference
- Musepack SV8 specification – the stream version 8 packet format, from the old project wiki (archived copy)
- Musepack SV7 specification – the stream version 7 header, from the old project wiki (archived copy)
- APEv2 specification – the tag format used in Musepack files