Introduction
Sound Designer II is the audio file of Digidesign’s Sound Designer II editor, which later became the sound file of Pro Tools. Its file type is Sd2f. It is a two-part file in the classic Macintosh sense:
the data fork holds nothing but the samples, and the resource fork holds the few facts a player needs to read them.
The data fork has no header. It starts at its first byte with the samples of the first frame, big-endian, most significant byte first, the channels alternating. The file does not store its length: the number of frames is the length of the data fork divided by the size of a frame.
The sample size, the sample rate and the number of channels are three text resources in the resource fork. Away from a Macintosh the resource fork is often lost, so a bare .sd2 file is only a run of samples whose rate, size and channel count must be told to the player.
The data fork
0Frame 0 one sample for each channel, big-endian, signedchannels × sample size…Frame 1 and on the same, to the end of the forkto the end
The Digidesign document describes 8-bit and 16-bit samples. libsndfile and Apple’s Core Audio also read and write 24-bit and 32-bit samples, so the sample size is 1, 2, 3 or 4 bytes. The document calls the byte order “little endian” but the samples are most significant byte first, which is what every reader and writer examined here does (see Divergence).
The number of frames is the length of the data fork divided by the channels times the sample size. A fork whose length is not a whole number of frames has stray bytes at its end, and the explorer says so.
The resource fork
The resource fork is a Macintosh Resource Manager file: a 16-byte header, the resources’ data, and a map of types, references and names. Sound Designer II needs three STR (Pascal string) resources:
STR1000, sample-size: the bytes in one sample, as a decimal string.STR1001, sample-rate: the sample rate in hertz, as a decimal string with decimals, for example44100.0000.STR1002, channels: the number of channels, as a decimal string.
Digidesign also reserves the resource types beginning sd and dd, and defines three: sdDD (document data), sdML (markers) and sdLL (loops). All three have ID 1000. The Resource fork and STR resources page gives the layout of the fork and the strings, and
Markers, loops and document data gives the three records.
Other containers
A file with both forks cannot be stored on a file system without forks, so it travels wrapped: MacBinary (a 128-byte header, then the two forks each padded to a multiple of 128 bytes), AppleSingle (both forks as entries of one file) or AppleDouble (the resource fork in a separate ._name file next to the data fork). The explorer reads all three, and a bare resource fork;
see MacBinary, AppleSingle and AppleDouble.
What the explorer shows
The explorer finds the container, reads the resource fork with the Resource Manager layout (header, data, type list, reference lists, name list, every byte in the structure tree), takes the sample size, rate and channels from STR 1000, 1001 and 1002, and draws the waveform and plays the sound. It lists the resources, the strings, the markers, the loops and the document data in tables, and reports a parameter that is missing, a fork that is not a whole number of frames, a marker beyond the end of the sound and a record cut short.
For a data fork on its own, the options bar asks for the sample size (8, 16, 24 or 32 bits), the channels and the rate, as a resource fork would have said them. They are used only when the file has no resource fork with the parameters.
Divergence from the specification
- Byte order. The Digidesign document calls the sample order “little endian”. Files written by Apple’s Core Audio (
afconvert -f Sd2f) and the layout libsndfile reads and writes are most significant byte first; the explorer reads them so, and the sound it makes agrees with Core Audio’s own conversion to WAV, sample for sample. - Sample sizes. The document names 8 and 16 bits. libsndfile accepts 1 to 4 bytes and Core Audio writes 8, 16, 24 and 32 bits; so does the explorer.
- Strings. The resource data of the three strings is a Pascal string (a length byte and the text), read as a decimal number. libsndfile reads them with
strtolafter the length byte and also looks at the string “Photoshop” as a stop; the explorer reads by the length byte. If the rate is 4 or less and the sample size above 4, libsndfile takes them to be swapped (a writer’s mistake it names in a comment); the explorer does the same. - Resources written by Core Audio. Core Audio puts the resource data in the order rate, size, channels and the type list’s IDs as 1001, 1000, 1002, with names sample-rate, sample-size and channels and no
sdMLresource; libsndfile writes 1000, 1001, 1002 and ansdMLof its own. A reader finds the strings by ID, not by position.
Not described
- The
sdDDrecord is described in full (420 bytes; see the records): its sizes up toCursorPoscome from the document, the rest from Pascal’s alignment rules and from 24 real records. - The resources
sdCP(2 bytes),ddRL(18 bytes),SDOC(2 bytes) andWsta(IDs 1 to 4, 26 bytes each) that the Sound Designer II program itself writes are described byte by byte in the records, from the program’s own code; no published document describes them. Each 56-byteddRLregion record is described in full, including its region number and its 64-bit time stamp. - The playlist resource
sdP2(one for each playlist) and the oldsdPL1000 the program reads but no longer writes are described byte by byte in the records. A playlist stores its SMPTE start time (four bytes, 01:00:00:00 by default when the On-Line command is on or a device with handler ID $3D is found on the Apple Desktop Bus at start-up), the fade-out and fade-in lengths (Fixed numbers of seconds) and the two fade curves (points of a fractional position and a gain up to $7FFFFF, joined by straight lines). The fields $2C and $2E are only limited to 1 to 16 and 0 to 16 on reading; the program does nothing else with them.
Sources
- Digidesign, Digidesign Developer Documentation 4.0 (April 1990), pages 33 to 36: the Sound Designer II file format, the
STRresources and thesdDD,sdMLandsdLLrecords. - libsndfile,
src/sd2.c: the reader and writer of the resource fork, the string quirks and the sample sizes. - Apple, More Macintosh Toolbox, “Resource File Format”: the resource header, map, type list, reference list and name list.
- Leonard Rosenthol, MacBinary III specification (as
macbin3.h, Info-ZIP’s copy), and the MacBinary II standard: the 128-byte header and the CRC. - N. Borenstein and P. Faltstrom, RFC 1740, MIME Encapsulation of Macintosh Files (AppleSingle and AppleDouble).
- Apple Core Audio,
afconvert -f Sd2f,afinfo: files written and read on macOS to check the layout and the samples. - Sample files with no resource fork from toolsfairy.com’s sample page, read as data forks (16-bit big-endian stereo).
- The sources, their SHA-256 and the sample files with their builder are in the site’s research folder (
research/sd2f/SOURCES.md).
Links
Software
- libsndfile – the library whose
sd2.creads and writes the format
Reference
- RFC 1740 – AppleSingle and AppleDouble