aboutsummaryrefslogtreecommitdiff
path: root/doc/ADATFS.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/ADATFS.txt')
-rw-r--r--doc/ADATFS.txt529
1 files changed, 529 insertions, 0 deletions
diff --git a/doc/ADATFS.txt b/doc/ADATFS.txt
new file mode 100644
index 0000000..e373690
--- /dev/null
+++ b/doc/ADATFS.txt
@@ -0,0 +1,529 @@
1HD24 ADAT file system format
2
3Reading ADAT HD24 disks
4-----------------------
5In the ADAT FST file system, the part of the file system
6that contains directory and song info is grouped in
732-bit words. When read on a regular PC, each group of
84 bytes will appear reversed. As such, when
9a sector contains a string 'TADATSF ', we should read this
10as 'ADAT FST'. In this document, we will assume that
11doing the byte swapping needed to properly read the sectors
12has already been done.
13
14It should be noted that the actual audio data has not
15undergone such byte swapping. As such, WAV data
16retrieved from the HD24 by FTP is stored in the same
17byte order as the data on disk.
18
19The sector size used on HD24 disks is 512 bytes.
20ADAT FST boasts disk support for disks up to 2 Terabyte.
21This is achieved by using 32-bit pointers that point to
22sector numbers. We will refer to these pointers as
23sectorpointers.
24
25Writing ADAT HD24 disks
26-----------------------
27Writing HD24 disks is slightly tricky, because FST
28filesystems contain backup copies of file system
29sectors to help guarantee data consistency.
30As a result, when we make an alteration to only the
31first copy of the file system structure on disk, the
32disk is considered inconsistent and the backup copy will
33be written back by the HD24 recorder at the next use.
34
35The backup data is stored at the end of the disk,
36in block-reverse order.
37The original order is something like this:
38
39block 0
40 sector 0
41block 1
42 sector 1
43block 2
44 sectors 2,3,4
45block 3
46 sectors 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
47block 4-102
48 1 sector of project info
49block 103-
50 song info block (2 sectors)
51 song allocation info block (5 sectors)
52
53The backup blocks are stored in reverse order,
54however each backup block maintains the original
55sector ordering. That is,
56
57block 0 has a backup at sector (end-0)
58 (where end=the last sector on disk)
59
60block 1 has a backup at sector (end-1)
61
62block 2, sectors 2,3,4 are backed up at sectors
63 end-4, end-3, end-2, respectively;
64
65block 3, sectors 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
66 are backed up at sectors
67 end-19,end-18,end-17,end-16,end-15,...end-5,
68 respectively.
69
70The validity of a block is indicated by a checksum which
71is stored in the last 4 bytes of a block (bytes 0x1FC,
720x1FD, 0x1FE, 0x1FF of the last sector of a block).
73
74The value of the checksum is such that sum of all 32-bit
75words in the block (which may span several sectors) is 0.
76When writing a block, we must make sure that the resulting
77checksum of the block adds up to 0 again.
78
79A second check refers to bytes 0x1f8-0x1fb of the last
80sector of a block. Bytes 0x1F8 and 0x1F9 contain the
81least significant 16 bit of the sector number at which
82the block starts. Thus, a project block which contains
831 sector and starts on sector 0x14 will contain the
84values 0x14, 0x00 on bytes 0x1f8 and 0x1f9; a song entry
852 sectors long, and ending on sector 0x78 will contain
86the byte values 0x77, 0x00 on offset 0x1f8 and 0x1f9,
87respectively (because the song entry starts on sector
880x77). Bytes 0x1FA and 0x1FB of the last sector of the
89block contain the bit-inverted value of 0x1F8 and 0x1F9**.
90
91** This paragraph assumes the sector is not byte-swapped
92as described in the first paragraph of the document.
93
94When a block is not equal to its backup, the checksum
95of both is validated. If one is valid and the other is
96not, the valid copy is written over the invalid copy.
97
98General ADAT FST layout
99-----------------------
100The general ADAT FST layout is as follows:
101
102-----------------------------------------------------------
103Sector 0 / Offset 0000:0000h
104Superblock, identifies drive as an ADAT FST drive.
105Size=512 bytes/0200h
106-----------------------------------------------------------
107Sector 1 / Offset 0000:0200h
108Drive info
109Size=512 bytes/0200h
110-----------------------------------------------------------
111Offset 0000:0400h
1123 sectors, Song Entry Usage Table
113Size=600h
114-----------------------------------------------------------
115Offset 0800h
11615 sectors, Drive Usage Table
117size=1e00h
118-----------------------------------------------------------
119 / Offset 0000:2800h
120Project info, 1 sector (512 bytes) per project entry
121Size: 99*200h=c600h
122-----------------------------------------------------------
123 / Offset 0000:ee00h
124Song info, 7 sectors (3584 bytes) per song entry
125-----------------------------------------------------------
126 Undo info
127-----------------------------------------------------------
128 Audio data
129-----------------------------------------------------------
130 File system backup
131-----------------------------------------------------------
132
133
134Superblock layout
135-----------------
136Offset 0-0fh Header line:
137 Offset 0 'ADAT FST'
138 Offset 8 Version number, e.g. '110 '
139 Offset 12 signature bytes: 55h, aah, cch, 33h
140Offset 10h-13h Size of audio block (0x480)
141Offset 14h-17h Number of audio blocks per allocation cluster
142Offset 18h-1fh 0 ?
143Offset 20h-23h 0 ?
144Offset 24h-27h 0 ?
145Offset 28h-2bh 1 ? sectors in superblock?
146Offset 2ch-2fh 1 ? sectors in drive info block
147
148Offset 30h-33h 2 ? sectornum of song entry usage table?
149Offset 34h-37h 3 ? sectors in song entry usage table?
150
151Offset 38h-3bh 5 ? sectornum containing allocation info?
152Offset 3ch-3fh 15/0fh - Number of sectors in allocation table?
153
154Offset 40h-43h 042fh=1071 ?? (anything to do with undo buffer?)
155 --
156 On 1.2gb drive this formats as 0x20 00 00 00
157 --
158Offset 44h-47h Number of free audio clusters on disk
159Offset 48h-4bh SectorPointer to project info
160Offset 4ch-4fh 1
161Offset 50h-53h Max allowed no. of projects?
162Offset 54h-57h Max allowed no. of songs per project?
163Offset 58h-5bh SectorPointer to first song info entry
164
165Offset 5ch-5fh 2 (sectors of song info entry w/o alloc info?)
166Offset 60h-63h 5 (sectors of alloc info per song entry?)
167Offset 64h-67h 7 (number of sectors that song info entries are apart?)
168Offset 68h-6bh current number of songs on disk
169Offset 78h-7bh 041fh (number of audio blocks reserved for undo buffer).
170 1055 audio blocks=72 track minutes at 48 khz
171 Multiply by contents of offset 14h-17h for number of sectors
172 in undo buffer.
173
174Offset 7ch-7fh Sector pointer to audio data block on disk (0x1397f6).
175Offset 80h-83h 32-bit word
176 number almost as big as number of sectors on disk
177
178 This number is related to that on offset 0084h and
179 always seems to have a difference of 0x14a46B to
180 the end of the disk.
181
182 0084h 0080h
183 40 gb disk:
184 0x04c92d7f - 0x04B48914 = 0x14A46B
185 120gb disk:
186 0x0df94baf - 0x0de4a744 = 0x14A46B
187
188 Perhaps the value is the number of allocatable sectors
189 on disk?
190 (1397f6 used in the beginning; an undo buffer is not
191 needed at the end of the drive)
192
193 0x10C75 used for actual filesystem.?
194 0x1397f6 (first data sector on drive) - (0x41f(size of undo buffer in audio blocks) * 0x480(size of audio block in sectors)) = 0x10C76
195 first data sector is not part of FS so this makes sense.
196
197offset 84h-87h 32-bit word, highest sector number on disk.
198 A backup of the first sector can be found here.
199offset 88h-1F7 (empty, zero - reserved for future use?)
200offset 1f8-1FF Checksum information.
201
202Drive info layout
203-----------------
204Sector 1
205Offset 0 8 byte drive name (for compatibility with
206 older ADAT FST versions), should be considered
207 obsolete. Replaced by name at offset 01bh.
208Offset 8-9 null bytes
209Offset 0ah-0bh 2 more bytes for drive name. Should be considered
210 obsolete
211Offset 10h SectorPointer to last active project.
212offset 20h List of 32-bit sector pointers to all projects.
213Offset 01b8h 64-byte drive name. Null-byte terminated
214 when shorter than 64 chars.
215
216Song Entry Usage Table
217----------------------
218FST 1.10 allows for 99 projects of 99 songs each, giving for
2199801 song entries. Each song entry is not necessarily pre-
220allocated to any given project; song entry 0 may belong to
221project 0, while song entry 1 may belong to another project.
222The Song Entry Usage Table provides a quick way to look up
223the next free song entry without having to go through all
224projects to see which song entries are in use.
225
226Each bit in the Song Entry Usage Table represents a song.
227When 0, the song entry is not in use; when 1, it is.
228
229Drive Usage Table
230-----------------
231Each bit in the Drive Usage Table represents a cluster. When 0, the
232cluster is free; when 1, the cluster is in use.
23332-bit words are filled one by one, least-significant bit first,
234until the entire word has the value 0xFFFFFFFF. In other words, the
235table starting with the following words have the meaning as described:
236
2370x1 contains 1 bit on -> first cluster allocated
2380x3 contains 2 bits on -> first 2 clusters allocated
2390x1f contains 5 bits on -> first 5 clusters allocated
2400x1ff contains 9 bits on -> first 9 clusters allocated.
241
242At the end of the drive usage table, some space seems to be reserved,
243possibly representing the backup of the file system info, or something
244along those lines. The last 32-bit word of the Drive Usage Table is a
245checksum. When all 32-bit words in the entire Drive Usage Table are
246summed, the result must be 0.
247
248Project info
249----------------------
250The project info consists of (by default) 99 entries of 512 bytes each.
251The actual number of projects is contained by the superblock.
252
253100 project entries would be 0xc800 bytes.
254As projects are numbered starting at 01, a maximum of 99 projects
255is possible, giving for 0xc600 bytes.
256
257How to distinguish between an empty project and an unused project entry?
258Answer: Sector 1 (Drive info) contains the project list.
259
260Projects not mentioned in the drive info project list are empty projects.
261
262Each project entry has the following layout:
263
264Offset 0 8-byte project name (obsolete)
265Offset 8 4-byte (2 bytes of which are partial project name too)
266offset 0ch-0fh Number of songs in use in project
267offset 10h-19bh Song info table (a list of 32-bit pointers to the
268 initial sectors of song info). Length of table should be
269 396 bytes for 99 songs per project.
270 First entry in the table is the last accessed song.
271 Zero char means unused entry.
272Offset 01b8h 64-byte project name. Null-byte terminated if project
273 name is less than 64 bytes long.
274
275Song info table
276---------------
277The song info table is part of a project entry. It is a list of 32-bit
278pointers to sectors containing song info.
279
280Song info
281------------------------
282Song info starts at disk offset 0xee00h, or at
283sector 119 (the 120th sector on disk) (depending on
284info in superblock).
285
286Each song entry has a length of 2 sectors and is immediately
287followed by 5 sectors of file allocation info.
288
289Locate points/loops and track slip info is included in the song
290entries.
291
292Offset 00h-03h 32-bit number indicating no. of audio blocks in song
293Offset 04h-07h ?0
294Offset 08h-0bh 32-bit number related to audio track interlacing.
295
296 1/512th of the number of samples per interlace block
297 before the audio switches to the next track.
298
299 Value of this field equals Cluster size/(tracks*3).
300
301Offset 0ch-0fh 32-bit number related to audio track interlacing.
302
303 number of sectors per interlace block
304 before the audio switches to the next track.
305
306 Value of this field equals audio block size
307 /no. of tracks.
308 Default audio block size is defined in superblock
309 (0x480 sectors)
310
311 An audio block size of 0x480 and 2 tracks gives a
312 block size of 0x240h sectors or 0x48000 bytes
313 (=294912 bytes).
314
315Offset 10h-13h Status flags????????????????????
316 Offset 0x12h bit 0x10h -> write protect?????
317
318Offset 28h-2Fh First 8 bytes of song name.
319 (Maintained for compatibility
320 with FST before 1.10-
321 Obsoleted by long filenames
322 at offset 3b8h)
323
324Offset 30h ?
325
326Offset 31h Number of physical tracks used by song.
327
328 Note:
329 The HD24 has a high sample rate
330 mode (88200 and 96000 samples per
331 second, respectively).
332
333 In high sample rate mode, two
334 physical tracks are used for each
335 logical track.
336
337 That is, a 12-track song in high
338 sample rate mode will use 24 tracks
339 on the machine. The number 24 is
340 then what is indicated.
341
342 This allows interlacing samples between
343 tracks for compatibility with systems
344 running at half the sample rate.
345 In high sample rate mode, the track layout
346 is:
347 physical track 0-1 -> samples of logical track 1
348 physical track 2-3 -> samples of logical track 2
349 physical track 4-5 -> samples of logical track 3
350 .. and so on. Even numbered samples (0,....)
351 are on even numbered tracks.
352
353Offset 32h-33h Two more filename characters for short filename,
354 used in obsolete FST 1.0 standard.
355
356Offset 34h-36h Sample rate in samples/second
357
358 Typical values are:
359
360 00h ach 44h -> 44100 Samples/sec
361 00h bbh 80b -> 48000 Samples/sec
362 01h 58h 88h -> 88200 Samoles/sec
363 01h 77h 00h -> 96000 Samples/sec
364
365Offset 37h Bit depth (18h or 24 by default)
366
367offset 38h-3bh Unsigned 32-bit number containing
368 number of samples in song.
369
370 For high sample rates, 2 tracks
371 are used for each sample;
372 therefore, a song that according
373 to this 32-bit number contains 44100
374 samples has the same duration at both
375 44100 and 88200 kHz.
376
377offset 3ch Write protect byte.
378
379 This byte contains 8 bits (0-7, where
380 7 is the most significant bit and 0 the
381 least significant bit. In other words
382 bit 7 has value 128, bit 0 has value 1)
383
384 Bit 2 is on when song is write protected
385 (value of the byte is 0x4 then), off when
386 song is write enabled.
387
388offset 58h-B7h Track slip info for track 1-24
389
390 Track slip is measured in number of samples.
391 E.g. for a song recorded at 48 khz, a value
392 of 480 decimal (0x1e0) means 1/100 second
393 (10 ms) of track slip.
394 Track slip is stored as a signed 32-bit number.
395 Valid values for the HD24 are -170..170 msec
396
397Offset 0b8h-1e3h Locate point block
398
399Offset 3b8h-3e7h Full song name, max 64 bytes;
400 terminated by null byte when less
401 than 64 bytes
402
403Offset 400h-???? File allocation info (see below)
404
405Locate point block
406------------------
407The locate point block consists of 24 locate point entries.s
408
409Locate point entry
410------------------
411Each locate point entry has the following layout:
412Offset 0-3 32-bit time code
413 The time code represents the sample number
414 within the song.
415Offset 4-11 The 8-byte locate point name
416
417Locate point 0 indicates the relative time offset of the
418song. This is usually 0, but may be set to other values for
419tape transfers.
420
421The locate point is a 32-bit unsigned integer which contains the
422sample number within the song. In other words, in a 44.1 khz
423song, the locate point 0:0:1:0 (hours/minutes/seconds/frames)
424is encoded as the number 44100. Thus, the locate point furthest
425in the song is 2^32=4294967296 samples.
426This is enough for 44.1khz songs with a length of 27 hours.
427
428File allocation info
429====================
430The file allocation info consists of file allocation entries.
431Each file allocation entry has the following format:
432
433Offset 00h-03h Starting sector number for audio block
434Offset 04h-07h Number of audio blocks in allocation block
435
436In a valid song, the the 32-bit word on offset 0 of the song
437info equals the total sum of the number of audio blocks in the
438file allocation info.
439
440In my disk image, I see songs that had been previously deleted;
441the song length in audio blocks is zero for these. This also
442goes for songs that have no audio data yet.
443
444Audio data layout
445=================
446The audio data of a FST file system is stored in a raw, uncompressed
447format. Audio data that consists of multiple channels is interlaced
448blockwise (as opposed to sample-by-sample interlacing).
449
450The data is stored as 24-bit signed little endian integer data.
451
452The typical audio block size as indicated in the superblock is
4530x480 sectors. In stereo audio, each subblock is then 1/2 audio blocks
454or 0x240 sectors per channel.
455
456As the number of tracks increases, the block size per track decreases
457proportionally.
458
459The default audio block size of 0x480 sectors lets itself be divided
460into 2,4,6,8,12,16,24 tracks (with a sample size of 24 bit). Each channel
461then takes up 0x240, 0x120, 0xc0, 0x90, 0x60, 0x48, 0x30 sectors,
462respectively assuming 0x480 blocks per sector. In high sample rate
463modes, channels are paired to accomodate for the doubled sample rate.
464This is why in high sample rate mode a max of 12 channels are possible,
465while the maximum song length is still over 27 hours on 88.2 kHz.
466
467
468Not yet accounted for in this document
469======================================
470
471How the undo buffer is used (however, this is not relevant because the
472undo buffer is cleared after each power off. It might as well exist
473in RAM only).
474
475How pitch info is stored in the songs
476auto play
477auto rtn
478auto rec
479
480HD24tools extensions to FST
481===========================
482An extension is proposed where a song on a HD24 drive is used as data
483area, to store non-audio information associated with a song or project.
484This would allow HD24 owners to store track notes, mix settings,
485protools projects and so on along with their songs.
486
487A degree of compatibility with the HD24 is desired; although the HD24
488will not be able to use the information, it should also not corrupt it.
489
490The HD24 does not offer unique file names; moreover, the position of a
491file is not constant within the FS. As a result, songs have no unique
492identifier that allows other data to be associated with them.
493
494It is proposed to use bytes 0x3a0-0x3bf of each song entry as unique
495identifier. Testing shows that the HD24 recorder does not touch these
496bytes, even after a scandisk operation. Moreover, when a song is copied
497to another drive, these bytes are copied over as well.
498
499A single HD24 song would provide ample storage space for most purposes.
500Additionally, by using a single song only, the negative impact to the
501end user is minimal as no users have ever been registered to actually
502create 99 project of 99 songs. To prevent the HD24 from corrupting the
503contents of the song, it can be created as 0-track song; previous
504experiments have shown that the track count is flexible. Having a song
505marked as 0 track prevents the HD24 from arming tracks or playing back
506audio from the song, and will give a user some feedback about the nature
507of the song, without causing the HD24 to claim that the song is corrupt.
508A track count of 0 survives a scandisk command, and it seems that the
509HD24 permits copying such songs to other drives.
510
511A possible way to store data in the song is to have the data song
512contain a FAT file system. The advantage of the FAT file system is
513that it is well documented, and probably there will be library code
514available that will ease the implementation of an embedded FAT
515system on HD24 drives.
516
517The root directory of the file system shall contain a 'songdata'
518dir. This data directory shall contain a subdirectory named after the
519ID of each song. Of course the file names need to be long enough; if
520this is not possible, a map file may be created to contain mappings
521from song ID to songname subdirectory ID.
522
523Data placed in the appropriate songname directory is automatically
524associated with the song. Should we so desire, we can also create a
525'projdata' directory.
526
527By keeping the songdata directory structure flat, songs can be moved
528across projects without losing their associated files.
529