cda music tracks file format


by wojtek kaniewski 1997

note: everything in this file is based on my own investigations.
all information that you'll find in this text file do not
come from microsoft corp.

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:

offset length description
00h 02h cda file version. currently equals 1. if it has
other value, following data may be out of date.
02h 02h number of track.
04h 04h cd disc serial number (the one stored in cdplayer.ini)
08h 04h beginning of the track in hsg format.
0ch 04h length of the track in hsg format.
10h 04h beginning of the track in red-book format.
14h 04h length 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:

offset length description
00h 01h frame
01h 01h second
02h 01h minute
03h 01h not 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 is [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)

that's all. it should be enough to write cda viewer :) if you need more
info or something isn't clear, feel free to write.

wojtek kaniewski
wojtekka@logonet.com.pl