
Sound Designer I File Format
 Sound Designer I file format is the original Digidesign sound file format first released in 1985. It is widely used and supported as evidenced by the many CD ROM discs with sound effects stored in this format. It is primarily used to store mono 16 bit short duration (on the order of seconds) audio samples. We recommend that you support this format for short sounds, but that you use Sound Designer II format as a primary format due to its flexibility.
 
 File Type: 'SFIL'
 
 Resource Fork
 The resource fork is not used.
 
 Data Fork
 The first 1336 bytes of the data fork contain the sound header (see the Pascal HeaderType record below) followed by the sample data itself. The most important fields are in bold. Default values are given in ( ) within the comment next to a field. Byte offsets are indicated to the left at various offsets. Fields with the comment DO NOT USE are for Sound Designer internal use and should not be changed except when initializing the file. The size of the data types are detailed in Inside Macintosh, Volume 1, page 86.
 
 typedef struct MarkerType
 {
  Boolean Free; // TRUE if this marker is free for use (TRUE/1).
  long Position; // Byte position in file (0).
  char Name[33]; // Name of the marker ("Untitled").
 } MarkerType;
 
 enum SideType {kLeftSide,kRightSide};
 
 typedef struct EditRecord
 {
  long HiAddr; // DO NOT USE (0).
  long LoAddr; // DO NOT USE (0).
  enum SideType ExtendSide; // DO NOT USE (0).
 } EditRecord;
 
 enum ScaleNames {kTime,kSampleNumber,kHexSampNum,kVolts,kPercent,kdbm,kUser};
 enum ModeType {kSelect,kDraw,kZoomSelect};
 
 typedef struct ZoomType
 {
  short v; // Vertical scale factor: positive = magnification
    // negative = reduction (-256).
  long h; // Horizontal scale factor: positive = magnification
    // negative = reduction (1)}
 } ZoomType;
 
 
 typedef struct ScaleType
 {
  long VFactor; // Scale factor for vertical axis tick units:    // positive = magnification,
    // negative = reduction (327).
  enum ScaleNames VType; // Type of vertical axis tick mark unit (4).
  char VString[34]; // Vertical axis tick units string ("%Scale").
  long HFactor; // Scale factor for horizontal axis tick units:
    // positive = magnification
    // negative = reduction (1).
  enum ScaleNames HType; // Type of horizontal axis tick mark unit (0).  char HString[34]; // Horizontal axis tick units string:
    // sec,msec,sec,samples ("sec").
 } ScaleType;
 
 typedef struct HeaderType
 {
  short HeaderSize; // Size in bytes of the file header (1336).
  short Version; // DO NOT USE (32).
  Boolean Preview; // DO NOT USE (0).
  WindowPtr WPtr; // DO NOT USE (0).
  WindowPeek WPeek; // DO NOT USE (0).
  long HInxPage,HInxLine; // DO NOT USE (0).
  long VInxPage,VInxLine; // DO NOT USE (0).
  long HCtlPage,HCtlLine; // DO NOT USE (0).
  long VCtlPage,VCtlLine; // DO NOT USE (0).
  long VOffset; // Position of vertical center of window in quantization
    // units ie -32768 to 32767 (0).
  long HOffset; // Position of left edge of sample window in #SAMPLES (0).
  short VOffConst; // DO NOT USE (0).
  ZoomType Zoom; // See above.
  ScaleType Scale; // See above.
  short VScrUpdate; // DO NOT USE (0).
  Ptr BufPtr; // DO NOT USE (0).
  Size BufBytes; // DO NOT USE (0).
  long BufOffset; // DO NOT USE (0).
  RgnHandle WaveRgn; // DO NOT USE (0).
  RgnHandle ClipArea; // DO NOT USE (0).
  RgnHandle ScaleArea; // DO NOT USE (0).
  Rect CtlWidth; // DO NOT USE (0).
  ControlHandle VScroll; // DO NOT USE (0).
  ControlHandle HScroll; // DO NOT USE (0).
  Size FileSize; // 2 * number of samples in this file ie number
    // of bytes of sound data.
  char BUName[66]; // Name of edit backup file.
  char FileName[66]; // Name of this file (Mac Filename).


 short BURefNum; // DO NOT USE (0).
  short refNum; // DO NOT USE (0).
  short vRefNum; // DO NOT USE (0).
  Boolean BufChanged; // DO NOT USE (0).
  Boolean FileChanged; // DO NOT USE (0).
  Boolean NoBackup; // DO NOT USE (0).
  enum ModeType Mode; // DO NOT USE (0).
  EditRecord Edit; // See above.
  long CursorPos; // Cursor position relative to window start (0).
  RgnHandle CursorRgn; // Cursor region in which it can be grasped (0).
  MarkerType MarkerData[10]; // See above.
  long MarkerOffset; // Offset to get relative time (0).
  long LoopStart; // Starting byte # of loop (-1).
  long LoopEnd; // Ending byte # of loop (-1).
  Boolean ZeroLineOn; // (FALSE/0).
  Boolean CursorOn; // (FALSE/0).
  Boolean ScalesOn; // (FALSE/0).
  Str255 Comment; // File comment (" ").
  long SampRate; // Sample rate in hertz ie 44100.
  long SampPeriod; // Sample period in microseconds.
  short SampSize; // Number of bits in a sample (16).
  char CodeType[34]; // Type of sample data ("Linear").
  Str255 UserStr1; // For user comments or reserved for future.
  Size BufSize; // Size of the RAM wave buffer in bytes.
  long Loop2Start; // Release loop start in bytes (-1).
  long Loop2End; // Release loop end in bytes (-1).
  Byte Loop1Type; // Type of loop: 1 = forward 2 = forward/backward.
  Byte Loop2Type; // Type of loop: 1 = forward 2 = forward/backward.
  short User4; // DO NOT USE (0).
 } HeaderType;
 
 Sound Designer I File Header Notes
 Shorts (2 bytes) and longs (4 bytes) are stored in Motorola 68000 format with the most significant bytes stored first, followed by the least significant bytes. For example, to store the hexadecimal value 0123 4567 as a long, we would store in ASCENDING memory locations: 01, 23, 45, 67. Leading zeros must be considered as part of the number.
 
 The total length of the header is 1336 bytes. It is the first thing in the file, so if a file is rewound to an offset of 0 from the beginning of the file, the file position marker will be pointing to the first byte in the header.
 
 If a default value is given for a variable in the header, it MUST be set to that value when creating the header for the first time. All default values for numeric data in the header are given in DECIMAL. A header variable with the comment "DO NOT USE" should be set to its default value when creating a file, and under no circumstances used otherwise.
 
 The notation for strings in the Macintosh is STR[NN] where NN is the length in bytes of the string. The actual string stored in memory or the header will have one extra byte preceding it. This byte contains the length of the string, NN. For example to store a STR[32] in the header, the first byte will be 32 (decimal), followed by 32 bytes of ASCII representing the string. A string constant is specified above by using quote marks ie (" "). DO NOT include the quote marks as part of the string itself. Note that the string values in the header give the MAXIMUM length of that string variable. If you wish to use a string which is shorter (and you usually will), then the first byte of that string should give the actual number of ASCII characters in the string you wish to use. For example, although FileName is specified as a char[66], you may wish to use less characters for a filename. If you wish to use "New File" as the filename, you would store the byte 08 (ie the length not including the length byte itself) followed by the ASCII values for the characters in the string "New File". The byte 08 says that there are 8 bytes in the string itself.
 
 End addresses, such as Loop End addresses are the address of the first byte AFTER the last byte IN THE LOOP. They DO NOT refer to the last byte of the loop. Start addresses, however, refer to the first byte of a selection.
 
 There are currently no user bytes available in the header for independent use. This does not preclude the possibility that there will be some date, however at this time you must assume that no bytes in the header may be used for any purpose other than described above. All bytes which are NOT listed above are reserved for use exclusively by Digidesign Inc. until further notice.

