CDA Music Tracks File Format

CDA files are generally RIFF resources. The RIFF id of .CDA file is "CDDA" (43h, 44h, 44h, 41h). They contain only one data block called "fmt " (66h, 6dh, 74h, 20h). In current version of .CDA file, this block is 24 bytes long. Here's structure of it:

OffsetLengthDescription
00h02hCDA file version. Currently equals 1. If it has other value, following data may be out of date.
02h02hNumber of track.
04h04hCD disc serial number (the one stored in CDPLAYER.INI)
08h04hBeginning of the track in HSG format.
0Ch04hLength of the track in HSG format.
10h04hBeginning of the track in Red-Book format.
14h04hLength of the track in Red-Book format.

As you see, time is represented in two formats: HSG and Red-Book. HSG can be calculated as following:
    time = minute * 4500 + second * 75 + frame

Red-book is much easier to use, because it contains minutes, seconds and frames in unmodified form, byte-packed:
OffsetLengthDescription
00h01hFrame
01h01hSecond
02h01hMinute
03h01hnot used

Now, I'll show you an example file. First part is a hex dump of the file, the second is the explanation of the fields.

52 49 46 46 24 00 00 00 43 44 44 41 66 6D 74 20 RIFF$...CDDAfmt
18 00 00 00 01 00 04 00 B8 24 F6 00 F7 11 01 00 .........$......
B4 5C 00 00 0A 25 0F 00 20 10 05 00 .\...%.. ...

01 00 - first version of CDA file :)
04 00 - fourth track
B8 24 F6 00 - serial number of CD in CDPLAYER.INI [F623B8]

F7 11 01 00 - begining of track in HSG format
B4 5C 00 00 - length of track in HSG format

0A 25 0F 00 - begining of track in Red-Book format (15:37)
20 10 05 00 - length of track in Red-book format (05:16)

No comments: