1. Overview of MP3 Karaoke Specification
MP3 Karaoke combines high-definition studio audio recording (MPEG-1 Layer III) with embedded ID3v2 metadata frames containing word-level KLyr XML lyrics. This allows audio playback of real vocals/instruments while maintaining full real-time lyric color wiping and metadata display within a single .mp3 file.
2. ID3v2 Tag Header Parsing & TIS-620 Decoding
The parser examines the first 10 bytes of the MP3 file buffer for the ID3 magic identifier. It reads the synchsafe integer size and parses text frames with TIS-620/Windows-874 fallback decoding:
Standard ID3 Frames Extracted
TIT2 Frame
Contains official song title string. Automatically decoded via TIS-620/Windows-874 fallback if Thai characters are detected.
TPE1 Frame
Contains lead artist or band name.
TALB Frame
Contains album or collection name.
3. Embedded KLyr XML Payload Extraction from TXXX / TEXT Frames
Karaoke lyrics are embedded inside custom ID3 text frames (such as TEXT, TXXX_TEXT, or TXXX_Lyricist) prefixed with the LyrHdr string identifier. The extraction workflow functions as follows:
ID3 Lyric Extraction Pipeline
- 11. Frame Scanning: Scan ID3 text frames for
LyrHdr1string prefix. - 22. Payload Clean & Base64 Decoding: Strip the
LyrHdr1prefix and convert Base64 string payload intoUint8Arraybytes. - 33. zlib Inflation: Decompress binary payload with
pako.inflate()to recover raw XML bytes. - 44. XML Parsing & Audio Duration Syncing: Parse
<INFO>and<LYRIC><WORD>elements. Calculate audio duration via HTML5 Audio metadata for millisecond-level lyric color wiping.