home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / a / audio210.faq < prev    next >
Internet Message Format  |  1993-03-29  |  72KB

  1. From: guido@cwi.nl (Guido van Rossum)
  2. Subject: FAQ: Audio File Formats (version 2.10)
  3. Date: 11 Jan 93 17:42:16 GMT
  4.  
  5. Archive-name: audio-fmts/part1
  6. Submitted-by: Guido van Rossum <guido@cwi.nl>
  7. Version: 2.10
  8. Last-modified: 11-Jan-1993
  9.  
  10. FAQ: Audio File Formats (version 2.10)
  11. ======================================
  12.  
  13. Table of contents
  14. -----------------
  15.  
  16. Introduction
  17. Device characteristics
  18. Popular sampling rates
  19. Compression schemes
  20. Current hardware
  21. File formats            (including .mod)
  22. File conversions
  23. Playing audio files on UNIX
  24. Playing audio files on micros
  25. The Sound Site Newsletter
  26. Posting sounds
  27.  
  28. Appendices:
  29.  
  30.   FTP access for non-internet sites
  31.   AIFF Format (Audio IFF)
  32.   The NeXT/Sun audio file format
  33.   IFF/8SVX Format
  34.   Playing sound on a PC
  35.   The EA-IFF-85 documentation
  36.   US Federal Standard 1016 availability
  37.   Creative Voice (VOC) file format
  38.   RIFF WAVE (.WAV) file format
  39.   U-LAW and A-LAW definitions
  40.   AVR File Format
  41.   
  42.  
  43. Introduction
  44. ------------
  45.  
  46. This is version 2 of this FAQ, which I started in November 1991 under
  47. the name "The audio formats guide".  I bumped the major version number
  48. since the Subject and Newsgroups headers have changed to make the
  49. subject more informative and give the guide a wider audience.  I also
  50. added a Table of contents section at the top.
  51.  
  52. I am posting this about once a fortnight, either unchanged (just to
  53. inform new readers), or updated (if I learn more or when new hardware
  54. or software becomes popular).  I post to alt.binaries.sounds.{misc,d}
  55. and to comp.dsp, for maximal coverage of people interested in audio,
  56. and to news.answers, for easy reference.
  57.  
  58. A companion posting with subject "Change to: ..." is occasionally
  59. posted listing the diffs between a new version and the last.  This is
  60. not reposted, and it is suppressed when the diffs are bigger than the
  61. new version.
  62.  
  63. NEWSFLASH: This FAQ is now also available in distributed hypertext
  64. form!  If you have a WWW browser and direct Internet access you can
  65. point it to "http://voorn.cwi.nl/audio-formats/a00.html".  (WWW is the
  66. CERN World-Wide Web initiative; for more info, telnet or ftp to
  67. info.cern.ch.)
  68.  
  69. Send updates, comments and questions to <guido@cwi.nl>; flames to
  70. /dev/null.
  71.  
  72. I'd like to thank everyone who sent me mail with updates for previous
  73. versions.  The list of names is really too long to list you all...
  74.  
  75.   --Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
  76.   "Lobster thermidor aux crevettes with a mornay sauce garnished with
  77.   truffle pate, brandy and a fried egg on top and spam"
  78.  
  79.  
  80. Device characteristics
  81. ----------------------
  82.  
  83. In this text, I will only use the term "sample" to refer to a single
  84. output value from an A/D converter, i.e., a small integer number
  85. (usually 8 or 16 bits).
  86.  
  87. Audio data is characterized by the following parameters, which
  88. correspond to settings of the A/D converter when the data was
  89. recorded.  Naturally, the same settings must be used to play the data.
  90.  
  91. - sampling rate (in samples per second), e.g. 8000 or 44100
  92.  
  93. - number of bits per sample, e.g. 8 or 16
  94.  
  95. - number of channels (1 for mono, 2 for stereo, etc.)
  96.  
  97. Approximate sampling rates are often quoted in Hz or kHz ([kilo-]
  98. Hertz), however, the politically correct term is samples per second
  99. (samples/sec).  Sampling rates are always measured per channel, so for
  100. stereo data recorded at 8000 samples/sec, there are actually 16000
  101. samples in a second.  I will sometimes write 8 k as a shorthand for
  102. 8000 samples/sec.
  103.  
  104. Multi-channel samples are generally interleaved on a frame-by-frame
  105. basis: if there are N channels, the data is a sequence of frames,
  106. where each frame contains N samples, one from each channel.  (Thus,
  107. the sampling rate is really the number of *frames* per second.)  For
  108. stereo, the left channel usually comes first.
  109.  
  110. The specification of the number of bits for U-LAW (pronounced mu-law
  111. -- the u really stands for the Greek letter mu) samples is somewhat
  112. problematic.  These samples are logarithmically encoded in 8 bits,
  113. like a tiny floating point number; however, their dynamic range is
  114. that of 14 bit linear data.  Source for converting to/from U-LAW
  115. (written by Jef Poskanzer) is distributed as part of the SOX package
  116. mentioned below; it can easily be ripped apart to serve in other
  117. applications.  The official definition is the CCITT standard G.711.
  118.  
  119. There exists another encoding similar to U-LAW, called A-LAW, which
  120. is used as a European telephony standard.  There is less support for
  121. it in UNIX workstations.
  122.  
  123. (See the Appendix for some formulae describing U-LAW and A-LAW.)
  124.  
  125.  
  126. Popular sampling rates
  127. ----------------------
  128.  
  129. Some sampling rates are more popular than others, for various reasons.
  130. Some recording hardware is restricted to (approximations of) some of
  131. these rates, some playback hardware has direct support for some.  The
  132. popularity of divisors of common rates can be explained by the
  133. simplicity of clock frequency dividing circuits :-).
  134.  
  135. Samples/sec     Description
  136.  
  137. 5500            One fourth of the Mac sampling rate (rarely seen).
  138.  
  139. 7333            One third of the Mac sampling rate (rarely seen).
  140.  
  141. 8000            Exactly 8000 samples/sec is a telephony standard that
  142.                 goes together with U-LAW (and also A-LAW) encoding.
  143.                 Some systems use an slightly different rate; in
  144.                 particular, the NeXT workstation uses 8012.8210513,
  145.                 apparently the rate used by Telco CODECs.
  146.  
  147. 11 k            Either 11025, a quarter of the CD sampling rate,
  148.                 or half the Mac sampling rate (perhaps the most
  149.                 popular rate on the Mac).
  150.  
  151. 16000           Used by, e.g. the G.722 compression standard.
  152.  
  153. 18.9 k          CD-ROM/XA standard.
  154.  
  155. 22 k            Either 22050, half the CD sampling rate, or the Mac
  156.                 rate; the latter is precisely 22254.545454545454 but
  157.                 usually misquoted as 22000.  (Historical note:
  158.                 22254.5454... was the horizontal scan rate of the
  159.                 original 128k Mac.)
  160.  
  161. 32000           Used in digital radio, NICAM (Nearly-Instantaneous
  162.                 Companded Audio Multiplex [IBA/BREMA/BBC]) and other
  163.                 TV work, at least in the UK; also long play DAT and
  164.                 Japanese HDTV.
  165.  
  166. 37.8 k          CD-ROM/XA standard for higher quality.
  167.  
  168. 44056           This weird rate is used by professional audio
  169.                 equipment to fit an integral number of samples in a
  170.                 video frame.
  171.  
  172. 44100           The CD sampling rate.  (DAT players recording
  173.                 digitally from CD also use this rate.)
  174.  
  175. 48000           The DAT (Digital Audio Tape) sampling rate for
  176.                 domestic use.
  177.  
  178. Files samples on SoundBlaster hardware have sampling rates that are
  179. divisors of 1000000.
  180.  
  181. While professinal musicians disagree, most people don't have a problem
  182. if recorded sound is played at a slightly different rate, say, 1-2%.
  183. On the other hand, if recorded data is being fed into a playback
  184. device in real time (say, over a network), even the smallest
  185. difference in sampling rate can frustrate the buffering scheme used...
  186.  
  187. There may be an emerging tendency to standardize on only a few
  188. sampling rates and encoding styles, even if the file formats may
  189. differ.  The suggested rates and styles are:
  190.  
  191.     rate (samp/sec) style mono/stereo
  192.  
  193.     8000 8-bit U-LAW mono
  194.     22050 8-bit linear unsigned mono and stereo
  195.     44100 16-bit linear signed mono and stereo
  196.  
  197.  
  198. Compression schemes
  199. -------------------
  200.  
  201. Strange though it seems, audio data is remarkably hard to compress
  202. effectively.  For 8-bit data, a Huffman encoding of the deltas between
  203. successive samples is relatively successful.  For 16-bit data,
  204. companies like Sony and Philips have spent millions to develop
  205. proprietary schemes.
  206.  
  207. Public standards for voice compression are slowly gaining popularity,
  208. e.g. CCITT G.721 and G.723 (ADPCM at 32 and 24 kbits/sec).  (ADPCM ==
  209. Adaptive Delta Pulse Code Modulation.)  Free source code for a *fast*
  210. 32 kbits/sec ADPCM algorithm is available by ftp from ftp.cwi.nl as
  211. /pub/adpcm.shar.  (** NOTE: if you are using v1.0, you should get
  212. v1.1, released 17-Dec-1992, which fixes a serious bug -- the quality
  213. of v1.1 is claimed to be better than uLAW **)
  214.  
  215. There are also two US federal standards, 1016 (Code excited linear
  216. prediction (CELP), 4800 bits/s) and 1015 (LPC-10E, 2400 bits/s).  See
  217. also the appendix for 1016.
  218.  
  219. (Note that U-LAW and silence detection can also be considered
  220. compression schemes.)
  221.  
  222. Here's a note about audio codings by Van Jacobson <van@ee.lbl.gov>:
  223. Several people used the words "LPC" and "CELP" interchangably.  They
  224. are very different.  An LPC (Linear Predictive Coding) coder fits
  225. speech to a simple, analytic model of the vocal tract, then throws
  226. away the speech & ships the parameters of the best-fit model.  An LPC
  227. decoder uses those parameters to generate synthetic speech that is
  228. usually more-or-less similar to the original.  The result is
  229. intelligible but sounds like a machine is talking.  A CELP (Code
  230. Excited Linear Predictor) coder does the same LPC modeling but then
  231. computes the errors between the original speech & the synthetic model
  232. and transmits both model parameters and a very compressed
  233. representation of the errors (the compressed representation is an
  234. index into a 'code book' shared between coders & decoders -- this is
  235. why it's called "Code Excited").  A CELP coder does much more work
  236. than an LPC coder (usually about an order of magnitude more) but the
  237. result is much higher quality speech: The FIPS-1016 CELP we're working
  238. on is essentially the same quality as the 32Kb/s ADPCM coder but uses
  239. only 4.8Kb/s (the same as the LPC coder).
  240.  
  241. Finally, the comp.compression FAQ has some text on the 6:1 audio
  242. compression scheme used by MPEG (a video compression standard-to-be).
  243. It's interesting to note that video compression reaches much higher
  244. ratios (like 26:1).  This FAQ is ftp'able from rtfm.mit.edu
  245. [18.72.1.58] in directory /pub/usenet/news.answers/compression-faq,
  246. files part1 and part2.
  247.  
  248. Comp.compression also carries a regular posting "How to uncompress
  249. anything" by David Lemson <lemson@uiuc.edu>, which (tersely) hints on
  250. which program you need to uncompress a file whose name ends in .<foo>
  251. for almost any conceivable <foo>.  Ftp'able from ftp.cso.uiuc.edu
  252. (128.174.5.59) in the directory /doc/pcnet as the file compression.
  253.  
  254.  
  255. Current hardware
  256. ----------------
  257.  
  258. I am aware of the following computer systems that can play back and
  259. (sometimes) record audio data, with their characteristics.  Note that
  260. for most systems you can also buy "professional" sampling hardware,
  261. which supports much better quality, e.g. >= 44.1 k 16 bits stereo.
  262. The characteristics listed here are a rough estimate of the
  263. capabilities of the basic hardware only (and even here I am on thin
  264. ice, with systems becoming ever more powerful).
  265.  
  266. machine             bits            max sampling rate    #output channels
  267.  
  268. Mac                 8               22k                  1
  269. Apple IIgs          8               32k / >70k           8(st)
  270. PC/Soundblaster v1  8               13k / 22k            1
  271. PC/Soundblaster v2  8               15k / 44.1k          1
  272. PC/PAS-16           16              44.1k                ?(st)
  273. Atari ST            8               22k                  1
  274. Atari STe,TT        8               50k                  2
  275. Atari Falcon 030    16              50k                  8(st)
  276. Amiga               8               ~29k                 4(st)
  277. Sun Sparc           U-LAW           8k                   1
  278. Sun Sparcst. 10     U-LAW,8,16      48k                  1(st)
  279. NeXT                U-LAW,8,16      44.1k                1(st)
  280. SGI Indigo          8,16            48k                  4(st)
  281. Acorn Archimedes    ~U-LAW          ~180k                8(st)
  282. Sony RISC-NEWS      8, 16           37.8k                ?(st)
  283. VAXstation 4000     U-LAW           8k                   1
  284. Tandy 1000/*L*      8               22k                  3
  285. HP9000/705,710,425e U,A-LAW,8       8k                   1
  286.  
  287. 4(st) means "four voices, stereo"; sampling rates xx/yy are
  288. different recording/playback rates; *L* is any type with 'L' in it.
  289.  
  290. All these machines can play back sound without additional hardware,
  291. although the needed software is not always standard; only the Sun,
  292. NeXT and SGI come with standard sampling hardware (the NeXT only
  293. samples U-LAW at 8000 samples/sec from the built-in microphone port;
  294. you need a separate board for other rates).
  295.  
  296. The new VAXstation 4000 (VLC and model 60) series lets you PLAY audio
  297. (.au) files, and the package DECsound will let you do the recording.
  298. In fact, DECsound is given away free with Motif 1.1 and supports the
  299. VAXstation, Sun SPARCstation, DECvoice, and XMedia audio devices.  Sun
  300. sound files work without change.
  301.  
  302. The SGI Personal IRIS 4D/30 and 4D/35 have the same capabilities as
  303. the Indigo.
  304.  
  305. The new Apple Macs have more powerful audio hardware; the latest
  306. models have built-in microphones.
  307.  
  308. Software exists for the PC that can play sound on its 1-bit speaker
  309. using pulse width modulation (see appendix); the Soundblaster board
  310. records at rates up to 13 k and plays back up to 22 k (weird
  311. combination, but that's the way it is).
  312.  
  313. Here's some info about the newest Atari machine, the Falcon030.  This
  314. machine has stereo 16 bit CODECs and a 32 MHz Motorola 56001 that can
  315. handle 8 channels of 16 bit audio, up to 50 khz/channel with
  316. simultaneous playback and record.  The Falcon DMA sound engine is also
  317. compatible with the 8 bit stereo DMA used on the STe and TT. All of
  318. these systems use signed data.
  319.  
  320. On the NeXT, the Motorola 56001 DSP chip is programmable and you can
  321. (in principle) do what you want.  The SGI uses the same DSP chip but
  322. it can't be programmed by users -- SGI prefers to offer it as a shared
  323. system resource to multiple applications, thus enabling developers to
  324. program audio with their Audio Library and avoid code modifications
  325. for execution on future machines with different audio hardware, i.e. a
  326. different DSP.
  327.  
  328. The Amiga also has a 6-bit volume, which can be used to produce
  329. something like a 14-bit output for each voice.  The hardware can also
  330. use one of each voice-pair to modulate the other in FM (period) or AM
  331. (volume, 6-bits).
  332.  
  333. The Acorn Archimedes uses a variation on U-LAW with the bit order
  334. reversed and the sign bit in bit 0.  Being a 'minority' architecture,
  335. Arc owners are quite adept at converting sound/image formats from
  336. other machines, and it is unlikely that you'll ever encounter sound in
  337. one of the Arc's own formats (there are several).
  338.  
  339. CD-I machines form a special category.  The following formats are used:
  340.  
  341.      - PCM 44.1 kHz standard CD format
  342.      - ADPCM - Addaptive Delta PCM
  343.        - Level A 37.8 kHz 8-bit
  344.        - Level B 37.8 kHz 4-bit
  345.        - Level C 18.9 kHz 4-bit
  346.  
  347.  
  348. File formats
  349. ------------
  350.  
  351. Historically, almost every type of machine used its own file format
  352. for audio data, but some file formats are more generally applicable,
  353. and in general it is possible to define conversions between almost any
  354. pair of file formats -- sometimes losing information, however.
  355.  
  356. File formats are a separate issue from device characteristics.  There
  357. are two types of file formats: self-describing formats, where the
  358. device parameters and encoding are made explicit in some form of
  359. header, and "raw" formats, where the device parameters and encoding
  360. are fixed.
  361.  
  362. Self-describing file formats generally define a family of data
  363. encodings, where a header fields indicates the particular encoding
  364. variant used.  Headerless formats define a single encoding and usually
  365. allows no variation in device parameters (except sometimes sampling
  366. rate, which can be a pain to figure out other than by listening to the
  367. sample).
  368.  
  369. The header of self-describing formats contains the parameters of the
  370. sampling device and sometimes other information (e.g. a
  371. human-readable description of the sound, or a copyright notice).  Most
  372. headers begin with a simple "magic word".  (Some formats do not simply
  373. define a header format, but may contain chunks of data intermingled
  374. with chunks of encoding info.)  The data encoding defines how the
  375. actual samples are stored in the file, e.g. signed or unsigned, as
  376. bytes or short integers, in little-endian or big-endian byte order,
  377. etc.  Strictly spoken, channel interleaving is also part of the
  378. encoding, although so far I have seen little variation in this area.
  379.  
  380. Some file formats apply some kind of compression to the data, e.g.
  381. Huffman encoding, or simple silence deletion.
  382.  
  383. Here's an overview of popular file formats.
  384.  
  385.         Self-describing file formats
  386.         ----------------------------
  387.  
  388. extension, name   origin          variable parameters (fixed; comments)
  389.  
  390. .au or .snd       NeXT, Sun       rate, #channels, encoding, info string
  391. .aif(f), AIFF     Apple, SGI      rate, #channels, sample width, lots of info
  392. .aif(f), AIFC     Apple, SGI      same (extension of AIFF with compression)
  393. .iff, IFF/8SVX    Amiga           rate, #channels, instrument info (8 bits)
  394. .voc              Soundblaster    rate (8 bits/1 ch; can use silence deletion)
  395. .wav, WAVE        Microsoft       rate, #channels, sample width, lots of info
  396. .sf               IRCAM           rate, #channels, encoding, info
  397. none, HCOM        Mac             rate (8 bits/1 ch; uses Huffman compression)
  398. none, MIME        Internet        (see below)
  399. .mod or .nst      Amiga           (see below)
  400.  
  401. Note that the filename extension ".snd" is ambiguous: it can be either
  402. the self-describing NeXT format or the headerless Mac/PC format, or
  403. even a headerless Amiga format.
  404.  
  405. I know nothing for sure about the origin of HCOM files, only that
  406. there are a lot of them floating around on our system and probably at
  407. FTP sites over the world.  The filenames usually don't have a ".hcom"
  408. extension, but this is what SOX (see below) uses.  The file format
  409. recognized by SOX includes a MacBinary header, where the file
  410. type field is "FSSD".  The data fork begins with the magic word "HCOM"
  411. and contains Huffman compressed data; after decompression it it is 8
  412. bits unsigned data.
  413.  
  414. IFF/8SVX allows for amplitude contours for sounds (attack/decay/etc).
  415. Compression is optional (and extensible); volume is variable; author,
  416. notes and copyright properties; etc.
  417.  
  418. AIFF, AIFC and WAVE are similar in spirit but allow more freedom in
  419. encoding style (other than 8 bit/sample), amongst others.
  420.  
  421. There are other sound formats in use on Amiga by digitizers and music
  422. programs, such as IFF/SMUS.
  423.  
  424. Appendices describes the NeXT and VOC formats; pointers to more info
  425. about AIFF, AIFC, 8SVX and WAVE (which are too complex to describe
  426. here) are also in appendices.
  427.  
  428. DEC systems (e.g. DECstation 5000) use a variant of the NeXT format
  429. that uses little-endian encoding and has a different magic number
  430. (0x0064732E in little-endian encoding).
  431.  
  432. Standard file formats used in the CD-I world are IFF but on the disc
  433. they're in realtime files.
  434.  
  435. An interesting "interchange format" for audio data is described in the
  436. proposed Internet Standard "MIME", which describes a family of
  437. transport encodings and structuring devices for electronic mail.  This
  438. is an extensible format, and initially standardizes a type of audio
  439. data dubbed "audio/basic", which is 8-bit U-LAW data sampled at 8000
  440. samples/sec.
  441.  
  442. Finally, a somewhat different but popular format are "MOD" files,
  443. usually with extension ".mod" or ".nst" (they can also have a prefix
  444. of "mod.").  This originated at the Amiga but players now exist for
  445. many platforms.  MOD files are music files containing 2 parts: (1) a
  446. bank of digitized samples; (2) sequencing information describing how
  447. and when to play the samples.  See the appendix "The Amiga MOD Format"
  448. for a description of this file format.
  449.  
  450.         Headerless file formats
  451.         -----------------------
  452.  
  453. extension       origin          parameters
  454. or name
  455.  
  456. .snd, .fssd     Mac, PC         variable rate, 1 channel, 8 bits unsigned
  457. .ul             US telephony    8 k, 1 channel, 8 bit "U-LAW" encoding
  458. .snd?           Amiga           variable rate, 1 channel, 8 bits signed
  459.  
  460. It is usually easy to distinguish 8-bit signed formats from unsigned
  461. by looking at the beginning of the data with 'od -b <file | head';
  462. since most sounds start with a little bit of silence containing small
  463. amounts of background noise, the signed formats will have an abundance
  464. of bytes with values 0376, 0377, 0, 1, 2, while the unsigned formats
  465. will have 0176, 0177, 0200, 0201, 0202 instead.  (Using "od -c" will
  466. also show any headers that are tacked in front of the file.)
  467.  
  468. The Apple IIgs records raw data in the same format as the Mac, but
  469. uses a 0 byte as a terminator; samples with value 0 are replaced by 1.
  470.  
  471.  
  472. File conversions
  473. ----------------
  474.  
  475.     SOX
  476.     ---
  477.  
  478. The most versatile tool for converting between various audio formats
  479. is SOX ("Sound Exchange").  It can read and write various types of
  480. audio files, and optionally applies some special effects (e.g. echo,
  481. channel averaging, or rate conversion).
  482.  
  483. SOX recognizes all filename extensions listed above except ".snd",
  484. which would be ambiguous anyway, and ".wav" (but there's a patch, see
  485. below).  Use type ".au" for NeXT ".snd" files.  Mac and PC ".snd"
  486. files are completely described by these parameters:
  487.  
  488.       -t raw -b -u -r 11000
  489.  
  490. (or -r 22000 or -r 7333 or -r 5500; 11000 seems to be the most common
  491. rate).
  492.  
  493. The source for SOX, version 5, was posted to alt.sources, and should
  494. be widely archived.  To save you the trouble of hunting it down, it
  495. can be gotten by anonymous ftp from wuarchive.wustl.edu, in the
  496. directory usenet/alt.sources/articles, files 5581.Z through 5585.Z.
  497. (These files are compressed news articles containing shar files, if
  498. you hadn't guessed.)  I am sure many sites have similar archives, I'm
  499. just listing one that I know of and which carries a lot of this kind
  500. of stuff.  (Also see the appendix if you don't have Internet access.)
  501.  
  502. A compressed tar file containing the same version of SOX is available
  503. by anonymous ftp from ftp.cwi.nl [192.16.184.180], in /pub/sox*.tar.Z.
  504. You may be able to locate a nearer version using archie!
  505.  
  506. Ports of SOX:
  507.  
  508. - The source as posted should compile on any UNIX system with 4-byte
  509.   integers.
  510.  
  511. - A PC version is available by ftp from ftp.cwi.nl (see above) as
  512.   pub/sox4*.zip; also available from the garbo mail server.
  513.  
  514. - The latest Amiga SOX (corresponding to version 5) is available via
  515.   anonymous ftp to wuarchive.wustl.edu, files
  516.   systems/amiga/audio/utils/amisox*.  (See below for a non-SOX
  517.   solution.)
  518.  
  519. SOX usage hints:
  520.  
  521. - Often, the filename extension of sound files posted on the net is
  522.   wrong.  Don't give up, try a few other possibilities using the
  523.   "-t <type>" option.  Remember that the most common file type is
  524.   unsigned bytes, which can be indicated with "-t ub".  You'll have to
  525.   guess the proper sampling rate, but often it's 11k or 22k.
  526.  
  527. - In particular, with SOX version 4 (or earlier), you have to
  528.   specify "-t 8svx" for files with an .iff extension.
  529.  
  530. - When converting linear samples to U-LAW using the .au type for the
  531.   output file, you must specify "-U" for the output file, otherwise
  532.   you will end up with a file containing a NeXT/Sun header but linear
  533.   samples -- only the NeXT will play such files correctly.  Also, you
  534.   must explicitly specify an output sampling rate with "-r 8000".
  535.   (This may seem fixed for most cases in version 5, but it is still
  536.   occasionally necessary, so I'm keeping this warning in.)
  537.  
  538.         Sun Sparc
  539.         ---------
  540.  
  541. On Sun Sparcs, starting at SunOS 4.1, a program "raw2audio" is
  542. provided by Sun (in /usr/demo/SOUND -- see below) which takes a raw
  543. U-LAW file and turns it into a ".au" file by prefixing it with an
  544. appropriate header.
  545.  
  546.         NeXT
  547.         ----
  548.  
  549. On NeXTs, you can usually rename .au files to .snd and it'll work like
  550. a charm, but some .au files lack header info that the NeXT needs.
  551. This can be fixed by using sndconvert:
  552.  
  553.         sndconvert -c 1 -f 1 -s 8012.8210513 -o nextfile.snd sunfile.au
  554.  
  555.         SGI Indigo and Personal IRIS
  556.         ----------------------------
  557.  
  558. SGI supports "soundfiler" (in /usr/sbin), a program similar in
  559. spirit to SOX but with a GUI.  Soundfiler plays aiff, aifc, NeXT/Sun
  560. and .wav formats.  It can do conversions between any of these formats
  561. and to and from raw formats including mulaw.  It also does sample rate
  562. conversions.
  563.  
  564. Three shell commands are also provided that give the same functionality:
  565. "sfplay", "sfconvert", and "aifcresample" (all in /usr/sbin).
  566.  
  567.         Amiga
  568.         -----
  569.  
  570. Mike Cramer's SoundZAP can do no effects except rate change and it
  571. only does conversions to IFF, but it is generally much faster than
  572. SOX.  (Ftp'able from the same directory as amisox above.)
  573.  
  574.         Tandy
  575.         -----
  576.  
  577. The Tandy 1000 uses a (proprietary?) compressed format.  There is a
  578. PD Mac to Tandy conversion program called CONVERT.
  579.  
  580.  
  581. Playing audio files on UNIX
  582. ---------------------------
  583.  
  584. The commands needed to play an audio file depend on the file format
  585. and the available hardware and software.  Most systems can only
  586. directly play sound in their native format; use a conversion program
  587. (see above) to play other formats.
  588.  
  589.         Sun Sparcstation running SunOS 4.x
  590.         ----------------------------------
  591.  
  592. Raw U-LAW files can be played using "cat file >/dev/audio".
  593.  
  594. A whole package for dealing with ".au" files is provided by Sun on an
  595. experimental basis, in /usr/demo/SOUND.  You may have to compile the
  596. programs first.  (If you can't find this directory, either you are not
  597. running SunOS 4.1 yet, or your system administrator hasn't installed
  598. it -- go ask him for it, not me!)  The program "play" in this
  599. directory recognizes all files in Sun/NeXT format, but a SS 1 or 2 can
  600. play only those using U-LAW encoding at 8 k -- the SS 10 hardware
  601. plays other encodings, too.
  602.  
  603. If you ca't find "play", you can also cat a ".au" file to /dev/audio,
  604. if it uses U-LAW; the header will sound like a short burst of noise
  605. but the rest of the data will sound OK (really, the only difference in
  606. this case between raw U-LAW and ".au" files is the header; the U-LAW
  607. data is exactly the same).
  608.  
  609. Finally, OpenWindows 3.0 has a full-fledged audio tool.  You can drop
  610. audio file icons into it, edit them, etc.
  611.  
  612.         Sun Sparcstation running Solaris 2.0
  613.         ------------------------------------
  614.  
  615. Under SVR4 (and hence Solaris 2.0), writing to /dev/audio from the
  616. shell is a bad idea, because the device driver will flush its queue as
  617. soon as the file is closed.  Use "audioplay" instead.  The supported
  618. formats and sampling rates are the same as above.
  619.  
  620.         NeXT
  621.         ----
  622.  
  623. On NeXT machines, the standard "sndplay" program can play all NeXT
  624. format files (this include Sun ".au" files).  It supports at least
  625. U-LAW at 8 k and 16 bits samples at 22 or 44.1 k.  It attempts
  626. on-the-fly conversions for other formats.
  627.  
  628. Sound files are also played if you double-click on them in the file
  629. browser.
  630.  
  631.         SGI Indigo and Personal IRIS
  632.         ----------------------------
  633.  
  634. On SGI Indigo and the 4D/30 and /35 Personal IRIS workstations,
  635. "WorkSpace" plays audio files in .aiff, .aifc, .au, and .wav formats if
  636. you double click them and the sampling rate is one of 8000, 11025,
  637. 16000, 22050, 32000, 44100, or 48000.  On the Personal IRIS, you need
  638. to have the audio board installed (check the output from hinv) and you
  639. must run IRIX 3.3.2 or 4.0 or higher.  These files can also be played
  640. with "soundfiler" and "sfplay".  ".aiff" and ".aifc" files at the above
  641. sampling rates can also be played with playaifc.  (All in /usr/sbin)
  642.  
  643. There is no simple /dev/audio interface on these SGI machines.  (There
  644. was one on 4D/25 machines, reading and writing signed linear 8-bit
  645. samples at rates of 8, 16 and 32 k.)
  646.  
  647. A program "playulaw" was posted as part of the "radio 2.0" release
  648. that I posted to several source groups recently; it plays raw U-LAW
  649. files on the Indigo or Personal IRIS audio hardware.
  650.  
  651.         Sony NEWS
  652.         ---------
  653.  
  654. The Sony RISC-NEWS line (NWS-3250 laptop, NWS-37xx desktop, NWS-38xx
  655. desktop w/ IOP) also has builtin sound capabilities.  You can also buy
  656. external boards for the older NEWS machines or to add extra channels
  657. to the new machines.  In the default mode (8k/8-bit), Sun .au files
  658. are directly supported (you can 'cat' .au files to /dev/sb and have
  659. them play).
  660.  
  661.         Vaxstation 4000
  662.         ---------------
  663.  
  664. ".au" files can be played by COPYING them to device "SOA0:".  This
  665. device is set up by enabling the driver SODRIVER, as described below:
  666.  
  667. DEC's sound stuff is like most other new toy.  Hardware first, THEN the
  668. software.   DEC will soon be releasing a layered product called DECsound,
  669. which will let you record, play, and (possibly) manipulate sound files.
  670. Third party product(s) have ALREADY hit the market.
  671.  
  672. Enabling SODRIVER:   (you can use the following command file)
  673.  
  674. $!---------------- cut here -------------------------------
  675. $! sound_setup.com    enable SOUND driver
  676. $ run sys$system:sysgen
  677. connect soa0 /adapter=0 /csr=%x0e00 /vector=%o304 /driver=sodriver
  678. exit
  679. $ exit
  680. $!----------------- cut here ------------------------------------
  681.  
  682. The external audio port comes with a telephone-jack-like port.   For
  683. starters, you can plug a telephone RECEIVER right into this port to
  684. hear your first sound files.   After that, you can use the adapter
  685. (that came with the VaxStation), and plug in a small set of stereo
  686. speakers (the kind you'd plug into a WALKMAN, for example), for more
  687. volume.
  688.  
  689.         Others
  690.         ------
  691.  
  692. Most other UNIX boxes don't have audio hardware and thus can't play
  693. audio data.
  694.  
  695.  
  696. Playing audio files on micros
  697. -----------------------------
  698.  
  699. Most micros have at least a speaker built in, so theoretically all you
  700. need is the right software.  Unfortunately most systems don't come
  701. bundled with sound-playing software, so there are many public domain
  702. or shareware software packages, each with their own bugs and features.
  703. Most separate sound recording hardware also comes with playing
  704. software, most of which can play sound (in the file format used by
  705. that hardware) even on machines that don't have that hardware
  706. installed.
  707.  
  708. Chris S. Craig announces the following software for PCs:
  709.  
  710. ScopeTrax       This is a complete PC sound player/editor package.  Sounds
  711.                 can be played back at ANY rate between 1kHz to 65kHz through
  712.                 the PC speaker or the Sound Blaster.  It supports several
  713.                 file formats including VOC, IFF/8SVX, raw signed and raw
  714.                 unsigned.  A separate executable is provided to convert
  715.                 .au and mu-law to raw format.  ScopeTrax requires EGA/VGA
  716.                 graphics for editing and displaying sounds on a REALTIME
  717.                 oscilloscope.  The package also includes:
  718.                       * An expanded memory player which can play sounds
  719.                         larger than 640K in size.
  720.                       * Basic (rough) sound compression/uncompression
  721.                         utilities.
  722.                       * Complete documentation.
  723.                 The package is FREEWARE!  It is available on SIMTEL in the
  724.                 PD1:[MSDOS.SOUND] directory.
  725.  
  726. One of the appendices below contains a list of more programs to play
  727. sound on the PC.
  728.  
  729. For sounds on Atari STs - programs are in the atari/sound/players
  730. directory on atari.archive.umich.edu (141.211.164.8).
  731.  
  732. Malcolm Slaney from Apple writes:
  733.  
  734.  "We do have tools to play sound back on most of our Unix hosts.  We wrote
  735.  a program called TcpPlay that lets us read a sound file on a Unix host,
  736.  open a TCP/IP connection to the Mac on my desk, and plays the file.  We
  737.  think of it as X windows for sound (at least a step in that direction.)
  738.  
  739.  This software is available for anonymous FTP from ftp.apple.com.
  740.  Look for  ~ftp/pub/TcpPlay/TcpPlay.sit.hqx.
  741.  
  742.  Finally, there are MANY tools for working with sound on the Macintosh. Three
  743.  applications that come to mind immediately are SoundEdit (formerly by
  744.  Farralon and now by MacroMind/Paracomp), Alchemy and Eric Keller's Signalyze.
  745.  There are lots of other tools available for sound editing (including some
  746.  of the QuickTime Movie tools.)"
  747.  
  748. On a Tandy 1000, sounds can be played and recorded with DeskMate Sound
  749. (SOUND.PDM), or if they not stored in compressed format, they can also
  750. be played be a program called PLAYSND.  No indication of whether
  751. PLAYSND is PD or not. It hasn't been updated since March of 89.
  752.  
  753. On the Amiga, OmniPlay by David Champion <dgc3@midway.uchicago.edu>
  754. plays (but does not convert) several sound formats.  It allows Amiga
  755. users to play IFF-8SVX, AIFF, WAV, VOC, .au, .snd, and 8 bit raw
  756. (signed, unsigned, u-law) samples.  OmniPlay is available at the
  757. following FTP sites:
  758. * wuarchive.wustl.edu in /systems/amiga/audio/sampleplayers/oplay121.lha
  759. * amiga.physik.unizh.zh in music/oplay121.lha
  760.  
  761.  
  762. The Sound Site Newsletter
  763. -------------------------
  764.  
  765. An electronic publication with lots of info about digitised sound and
  766. sound formats, albeit mostly on micros, is "The Sound Site
  767. Newsletter".  So far, 8 issues have appeared, the last in January
  768. 1992.  Issues can be ftp'ed from saffron.inset.com, directory
  769. directory pub/rogue/newsletters, or from ccb.ucsf.edu,
  770. Pub/Sound_list/Sound.Newsletters.
  771.  
  772.  
  773. Posting sounds
  774. --------------
  775.  
  776. The newsgroup alt.binaries.sounds.misc is dedicated to postings
  777. containing sound.  (Discussions related to such postings belong in
  778. alt.binaries.sounds.d.)
  779.  
  780. There is no set standard for posting sounds; uuencoded files in most
  781. popular formats are welcome, if split in parts under 50 kBytes.  To
  782. accomodate automatic decoding software (such as the ":decode" command
  783. of the nn newsreader), please place a part indicator of the form
  784. (mm/nn) at the end of your subject meaning this is number mm of a
  785. total of nn part.
  786.  
  787. It is recommended to post sounds in the format that was used for the
  788. original recording; conversions to other formats often lose
  789. information and would do people with identical hardware as the poster
  790. no favor.  For instance, convering 8-bit linear sound to U-LAW loses
  791. the lower few bits of the data, and rate changing conversions almost
  792. always add noise.  Converting from U-LAW to linear requires expansion
  793. to 16 bit samples if no information loss is allowed!
  794.  
  795. U-LAW data is best posted with a NeXT/Sun header.
  796.  
  797. If you have to post a file in a headerless format (usually 8-bit
  798. linear, like ".snd"), please add a description giving at least the
  799. sampling rate and whether the bytes are signed (zero at 0) or unsigned
  800. (zero at 0200).  However, it is highly recommended to add a header
  801. that indicates the sampling rate and encoding scheme; if necessary you
  802. can use SOX to add a header of your choice to raw data.
  803.  
  804. Compression of sound files usually isn't worth it; the standard
  805. "compress" algorithm doesn't save much when applied to sound data
  806. (typically at most 10-20 percent), and compression algorithms
  807. specifically designed for sound (e.g. NeXT's) are usually
  808. proprietary.  (See also the section "Compression schemes" earlier.)
  809.  
  810.  
  811. Appendices
  812. ==========
  813.  
  814. Here are some more detailed pieces of info that I received by e-mail.
  815. They are reproduced here virtually without much editing.
  816.  
  817. ------------------------------------------------------------------------
  818. FTP access for non-internet sites
  819. ---------------------------------
  820.  
  821. From the sci.space FAQ:
  822.  
  823.     Sites not connected to the Internet cannot use FTP directly, but
  824.     there are a few automated FTP servers which operate via email.
  825.     Send mail containing only the word HELP to ftpmail@decwrl.dec.com
  826.     or bitftp@pucc.princeton.edu, and the servers will send you
  827.     instructions on how to make requests
  828.  
  829. Also:
  830.  
  831.     FAQ lists are available by anonymous FTP from pit-manager.mit.edu
  832.     (18.72.1.58) and by email from mail-server@pit-manager.mit.edu (send
  833.     a message containing "help" for instructions about the mail server).
  834.  
  835.  
  836. ------------------------------------------------------------------------
  837. AIFF Format (Audio IFF) and AIFC
  838. --------------------------------
  839.  
  840. This format was developed by Apple for storing high-quality sampled
  841. sound and musical instrument info; it is also used by SGI and several
  842. professional audio packages (sorry, I know no names).  An extension,
  843. called AIFC or AIFF-C, supports compression (see the last item below).
  844.  
  845. I've made a BinHex'ed MacWrite version of the AIFF spec (no idea if
  846. it's the same text as mentioned below) available by anonymous ftp from
  847. ftp.cwi.nl [192.16.184.180]; the file is /pub/AudioIFF1.2.hqx.  But
  848. you may be better off with the AIFF-C specs, see below.
  849.  
  850. Mike Brindley (brindley@ece.orst.edu) writes:
  851.  
  852. "The complete AIFF spec by Steve Milne, Matt Deatherage (Apple) is
  853. available in 'AMIGA ROM Kernal Reference Manual: Devices (3rd Edition)'
  854. 1991 by Commodore-Amiga, Inc.; Addison-Wesley Publishing Co.; 
  855. ISBN 0-201-56775-X, starting on page 435 (this edition has a charcoal
  856. grey cover).  It is available in most bookstores, and soon in many
  857. good librairies."
  858.  
  859. Finally, Mark Callow writes (in comp.sys.sgi):
  860.  
  861. "I have placed a PostScript version of the AIFF-C specification on
  862. sgi.sgi.com for public ftp.  It is in the file sgi/aiff-c.9.26.91.ps.
  863.  
  864. sgi.sgi.com's internet host number is (I think) 192.48.153.1."
  865.  
  866. ------------------------------------------------------------------------
  867. The NeXT/Sun audio file format
  868. ------------------------------
  869.  
  870. Here's the complete story on the file format, from the NeXT
  871. documentation.  (Note that the "magic" number is ((int)0x2e736e64),
  872. which equals ".snd".)  Also, at the end, I've added a litte document
  873. that someone posted to the net a couple of years ago, that describes
  874. the format in a bit-by-bit fashion rather than from C.
  875.  
  876. I received this from Doug Keislar, NeXT Computer.  This is also the
  877. Sun format, except that Sun doesn't recognize as many format codes.  I
  878. added the numeric codes to the table of formats and sorted it.
  879.  
  880.  
  881. SNDSoundStruct:  How a NeXT Computer Represents Sound
  882.  
  883. The NeXT sound software defines the SNDSoundStruct structure to  
  884. represent sound.  This structure defines the soundfile and Mach-O  
  885. sound segment formats and the sound pasteboard type.  It's also used  
  886. to describe sounds in Interface Builder.  In addition, each instance  
  887. of the Sound Kit's Sound class encapsulates a SNDSoundStruct and  
  888. provides methods to access and modify its attributes.
  889.  
  890. Basic sound operations, such as playing, recording, and cut-and-paste  
  891. editing, are most easily performed by a Sound object.  In many cases,  
  892. the Sound Kit obviates the need for in-depth understanding of the  
  893. SNDSoundStruct architecture.  For example, if you simply want to  
  894. incorporate sound effects into an application, or to provide a simple  
  895. graphic sound editor (such as the one in the Mail application), you  
  896. needn't be aware of the details of the SNDSoundStruct.  However, if  
  897. you want to closely examine or manipulate sound data you should be  
  898. familiar with this structure.
  899.  
  900. The SNDSoundStruct contains a header, information that describes the  
  901. attributes of a sound, followed by the data (usually samples) that  
  902. represents the sound.  The structure is defined (in  
  903. sound/soundstruct.h) as:
  904.  
  905. typedef struct {
  906.     int magic;               /* magic number SND_MAGIC */
  907.     int dataLocation;        /* offset or pointer to the data */
  908.     int dataSize;            /* number of bytes of data */
  909.     int dataFormat;          /* the data format code */
  910.     int samplingRate;        /* the sampling rate */
  911.     int channelCount;        /* the number of channels */
  912.     char info[4];            /* optional text information */
  913. } SNDSoundStruct;
  914.  
  915.  
  916.  
  917.  
  918. SNDSoundStruct Fields
  919.  
  920.  
  921.  
  922. magic
  923.  
  924. magic is a magic number that's used to identify the structure as a  
  925. SNDSoundStruct.  Keep in mind that the structure also defines the  
  926. soundfile and Mach-O sound segment formats, so the magic number is  
  927. also used to identify these entities as containing a sound.
  928.  
  929.  
  930.  
  931.  
  932.  
  933. dataLocation
  934.  
  935. It was mentioned above that the SNDSoundStruct contains a header  
  936. followed by sound data.  In reality, the structure only contains the  
  937. header; the data itself is external to, although usually contiguous  
  938. with, the structure.  (Nonetheless, it's often useful to speak of the  
  939. SNDSoundStruct as the header and the data.)  dataLocation is used to  
  940. point to the data.  Usually, this value is an offset (in bytes) from  
  941. the beginning of the SNDSoundStruct to the first byte of sound data.   
  942. The data, in this case, immediately follows the structure, so  
  943. dataLocation can also be thought of as the size of the structure's  
  944. header.  The other use of dataLocation, as an address that locates  
  945. data that isn't contiguous with the structure, is described in  
  946. "Format Codes," below.
  947.  
  948.  
  949.  
  950.  
  951.  
  952. dataSize, dataFormat, samplingRate, and channelCount
  953.  
  954. These fields describe the sound data.
  955.  
  956. dataSize is its size in bytes (not including the size of the  
  957. SNDSoundStruct).
  958.  
  959. dataFormat is a code that identifies the type of sound.  For sampled  
  960. sounds, this is the quantization format.  However, the data can also  
  961. be instructions for synthesizing a sound on the DSP.  The codes are  
  962. listed and explained in "Format Codes," below.
  963.  
  964. samplingRate is the sampling rate (if the data is samples).  Three  
  965. sampling rates, represented as integer constants, are supported by  
  966. the hardware:
  967.  
  968. Constant        Sampling Rate (samples/sec) 
  969.  
  970. SND_RATE_CODEC  8012.821        (CODEC input)
  971. SND_RATE_LOW    22050.0 (low sampling rate output)
  972. SND_RATE_HIGH   44100.0 (high sampling rate output)
  973.  
  974. channelCount is the number of channels of sampled sound.
  975.  
  976.  
  977.  
  978.  
  979.  
  980. info
  981.  
  982. info is a NULL-terminated string that you can supply to provide a  
  983. textual description of the sound.  The size of the info field is set  
  984. when the structure is created and thereafter can't be enlarged.  It's  
  985. at least four bytes long (even if it's unused).
  986.  
  987.  
  988.  
  989.  
  990.  
  991. Format Codes
  992.  
  993. A sound's format is represented as a positive 32-bit integer.  NeXT  
  994. reserves the integers 0 through 255; you can define your own format  
  995. and represent it with an integer greater than 255.  Most of the  
  996. formats defined by NeXT describe the amplitude quantization of  
  997. sampled sound data:
  998.  
  999. Value   Code    Format 
  1000.  
  1001. 0       SND_FORMAT_UNSPECIFIED  unspecified format 
  1002. 1       SND_FORMAT_MULAW_8      8-bit mu-law samples
  1003. 2       SND_FORMAT_LINEAR_8     8-bit linear samples
  1004. 3       SND_FORMAT_LINEAR_16    16-bit linear samples
  1005. 4       SND_FORMAT_LINEAR_24    24-bit linear samples
  1006. 5       SND_FORMAT_LINEAR_32    32-bit linear samples
  1007. 6       SND_FORMAT_FLOAT        floating-point samples
  1008. 7       SND_FORMAT_DOUBLE       double-precision float samples
  1009. 8       SND_FORMAT_INDIRECT     fragmented sampled data
  1010. 9       SND_FORMAT_NESTED       ?
  1011. 10      SND_FORMAT_DSP_CORE     DSP program
  1012. 11      SND_FORMAT_DSP_DATA_8   8-bit fixed-point samples
  1013. 12      SND_FORMAT_DSP_DATA_16  16-bit fixed-point samples
  1014. 13      SND_FORMAT_DSP_DATA_24  24-bit fixed-point samples
  1015. 14      SND_FORMAT_DSP_DATA_32  32-bit fixed-point samples
  1016. 15      ?
  1017. 16      SND_FORMAT_DISPLAY      non-audio display data
  1018. 17      SND_FORMAT_MULAW_SQUELCH        ?
  1019. 18      SND_FORMAT_EMPHASIZED   16-bit linear with emphasis
  1020. 19      SND_FORMAT_COMPRESSED   16-bit linear with compression
  1021. 20      SND_FORMAT_COMPRESSED_EMPHASIZED        A combination of the two above
  1022. 21      SND_FORMAT_DSP_COMMANDS Music Kit DSP commands
  1023. 22      SND_FORMAT_DSP_COMMANDS_SAMPLES         ?
  1024.  
  1025.  
  1026. Most formats identify different sizes and types of  
  1027. sampled data.  Some deserve special note:  
  1028.  
  1029.  
  1030. --      SND_FORMAT_DSP_CORE format contains data that represents a  
  1031. loadable DSP core program.  Sounds in this format are required by the  
  1032. SNDBootDSP() and SNDRunDSP() functions.  You create a  
  1033. SND_FORMAT_DSP_CORE sound by reading a DSP load file (extension  
  1034. ".lod") with the SNDReadDSPfile() function.
  1035.  
  1036. --      SND_FORMAT_DSP_COMMANDS is used to distinguish sounds that  
  1037. contain DSP commands created by the Music Kit.  Sounds in this format  
  1038. can only be created through the Music Kit's Orchestra class, but can  
  1039. be played back through the SNDStartPlaying() function.
  1040.  
  1041. --      SND_FORMAT_DISPLAY format is used by the Sound Kit's  
  1042. SoundView class.  Such sounds can't be played.  
  1043.  
  1044.  
  1045. --      SND_FORMAT_INDIRECT indicates data that has become  
  1046. fragmented, as described in a separate section, below.  
  1047.  
  1048.  
  1049. --      SND_FORMAT_UNSPECIFIED is used for unrecognized formats.
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055. Fragmented Sound Data
  1056.  
  1057. Sound data is usually stored in a contiguous block of memory.   
  1058. However, when sampled sound data is edited (such that a portion of  
  1059. the sound is deleted or a portion inserted), the data may become  
  1060. discontiguous, or fragmented.  Each fragment of data is given its own  
  1061. SNDSoundStruct header; thus, each fragment becomes a separate  
  1062. SNDSoundStruct structure.  The addresses of these new structures are  
  1063. collected into a contiguous, NULL-terminated block; the dataLocation  
  1064. field of the original SNDSoundStruct is set to the address of this  
  1065. block, while the original format, sampling rate, and channel count  
  1066. are copied into the new SNDSoundStructs.  
  1067.  
  1068.  
  1069. Fragmentation serves one purpose:  It avoids the high cost of moving  
  1070. data when the sound is edited.  Playback of a fragmented sound is  
  1071. transparent-you never need to know whether the sound is fragmented  
  1072. before playing it.  However, playback of a heavily fragmented sound  
  1073. is less efficient than that of a contiguous sound.  The  
  1074. SNDCompactSamples() C function can be used to compact fragmented  
  1075. sound data.
  1076.  
  1077. Sampled sound data is naturally unfragmented.  A sound that's freshly  
  1078. recorded or retrieved from a soundfile, the Mach-O segment, or the  
  1079. pasteboard won't be fragmented.  Keep in mind that only sampled data  
  1080. can become fragmented.
  1081.  
  1082.  
  1083.  
  1084. _________________________
  1085. >From mentor.cc.purdue.edu!purdue!decwrl!ucbvax!ziploc!eps Wed Apr  4  
  1086. 23:56:23 EST 1990
  1087. Article 5779 of comp.sys.next:
  1088. Path: mentor.cc.purdue.edu!purdue!decwrl!ucbvax!ziploc!eps
  1089. >From: eps@toaster.SFSU.EDU (Eric P. Scott)
  1090. Newsgroups: comp.sys.next
  1091. Subject: Re: Format of NeXT sndfile headers?
  1092. Message-ID: <445@toaster.SFSU.EDU>
  1093. Date: 31 Mar 90 21:36:17 GMT
  1094. References: <14978@phoenix.Princeton.EDU>
  1095. Reply-To: eps@cs.SFSU.EDU (Eric P. Scott)
  1096. Organization: San Francisco State University
  1097. Lines: 42
  1098.  
  1099. In article <14978@phoenix.Princeton.EDU>
  1100.         bskendig@phoenix.Princeton.EDU (Brian Kendig) writes:
  1101. >I'd like to take a program I have that converts Macintosh sound  
  1102. files
  1103. >to NeXT sndfiles and polish it up a bit to go the other direction as
  1104. >well.
  1105.  
  1106. Two people have already submitted programs that do this
  1107. (Christopher Lane and Robert Hood); check the various
  1108. NeXT archive sites.
  1109.  
  1110. >       Could someone please give me the format of a NeXT sndfile
  1111. >header?
  1112.  
  1113. "big-endian"
  1114.         0       1       2       3
  1115.         +-------+-------+-------+-------+
  1116. 0       | 0x2e  | 0x73  | 0x6e  | 0x64  |       "magic" number
  1117.         +-------+-------+-------+-------+
  1118. 4       |                               |       data location
  1119.         +-------+-------+-------+-------+
  1120. 8       |                               |       data size
  1121.         +-------+-------+-------+-------+
  1122. 12      |                               |       data format (enum)
  1123.         +-------+-------+-------+-------+
  1124. 16      |                               |       sampling rate (int)
  1125.         +-------+-------+-------+-------+
  1126. 20      |                               |       channel count
  1127.         +-------+-------+-------+-------+
  1128. 24      |       |       |       |       |       (optional) info  
  1129. string
  1130.  
  1131. 28 = minimum value for data location
  1132.  
  1133. data format values can be found in /usr/include/sound/soundstruct.h
  1134.  
  1135. Most common combinations:
  1136.  
  1137.          sampling  channel    data
  1138.              rate    count  format              
  1139. voice file   8012        1       1 =  8-bit mu-law
  1140. system beep 22050        2       3 = 16-bit linear
  1141. CD-quality  44100        2       3 = 16-bit linear
  1142.  
  1143. ------------------------------------------------------------------------
  1144. IFF/8SVX Format
  1145. ---------------
  1146.  
  1147. Newsgroups: alt.binaries.sounds.d,alt.sex.sounds
  1148. Subject: Format of the IFF header (Amiga sounds)
  1149. Message-ID: <2509@tardis.Tymnet.COM>
  1150. From: jms@tardis.Tymnet.COM (Joe Smith)
  1151. Date: 23 Oct 91 23:54:38 GMT
  1152. Followup-To: alt.binaries.sounds.d
  1153. Organization: BT North America (Tymnet)
  1154.  
  1155. The first 12 bytes of an IFF file are used to distinguish between an Amiga
  1156. picture (FORM-ILBM), an Amiga sound sample (FORM-8SVX), or other file
  1157. conforming to the IFF specification.  The middle 4 bytes is the count of
  1158. bytes that follow the "FORM" and byte count longwords.  (Numbers are stored
  1159. in M68000 form, high order byte first.)
  1160.  
  1161.                 ------------------------------------------
  1162.  
  1163. FutureSound audio file, 15000 samples at 10.000KHz, file is 15048 bytes long.
  1164.  
  1165. 0000: 464F524D 00003AC0 38535658 56484452    FORM..:.8SVXVHDR
  1166.       F O R M     15040 8 S V X  V H D R
  1167. 0010: 00000014 00003A98 00000000 00000000    ......:.........
  1168.             20    15000        0        0
  1169. 0020: 27100100 00010000 424F4459 00003A98    '.......BODY..:.
  1170.      10000 1 0    1.0   B O D Y     15000
  1171.  
  1172. 0000000..03 = "FORM", identifies this as an IFF format file.
  1173. FORM+00..03 (ULONG) = number of bytes that follow.  (Unsigned long int.)
  1174. FORM+03..07 = "8SVX", identifies this as an 8-bit sampled voice.
  1175.  
  1176. ????+00..03 = "VHDR", Voice8Header, describes the parameters for the BODY.
  1177. VHDR+00..03 (ULONG) = number of bytes to follow. 
  1178. VHDR+04..07 (ULONG) = samples in the high octave 1-shot part.
  1179. VHDR+08..0B (ULONG) = samples in the high octave repeat part.
  1180. VHDR+0C..0F (ULONG) = samples per cycle in high octave (if repeating), else 0.
  1181. VHDR+10..11 (UWORD) = samples per second.  (Unsigned 16-bit quantity.)
  1182. VHDR+12     (UBYTE) = number of octaves of waveforms in sample.
  1183. VHDR+13     (UBYTE) = data compression (0=none, 1=Fibonacci-delta encoding).
  1184. VHDR+14..17 (FIXED) = volume.  (The number 65536 means 1.0 or full volume.)
  1185.  
  1186. ????+00..03 = "BODY", identifies the start of the audio data.
  1187. BODY+00..03 (ULONG) = number of bytes to follow.
  1188. BODY+04..NNNNN      = Data, signed bytes, from -128 to +127.
  1189.  
  1190. 0030: 04030201 02030303 04050605 05060605
  1191. 0040: 06080806 07060505 04020202 01FF0000
  1192. 0050: 00000000 FF00FFFF FFFEFDFD FDFEFFFF
  1193. 0060: FDFDFF00 00FFFFFF 00000000 00FFFF00
  1194. 0070: 00000000 00FF0000 00FFFEFF 00000000
  1195. 0080: 00010000 000101FF FF0000FE FEFFFFFE
  1196. 0090: FDFDFEFD FDFFFFFC FDFEFDFD FEFFFEFE
  1197. 00A0: FFFEFEFE FEFEFEFF FFFFFEFF 00FFFF01
  1198.  
  1199. This small section of the audio sample shows the number ranging from -5 (0xFD)
  1200. to +8 (0x08).  Warning: Do not assume that the BODY starts 48 bytes into the
  1201. file.  In addition to "VHDR", chunks labeled "NAME", "AUTH", "ANNO", or 
  1202. "(c) " may be present, and may be in any order.  You will have to check the
  1203. byte count in each chunk to determine how many bytes to skip.
  1204.  
  1205. ------------------------------------------------------------------------
  1206. Playing sound on a PC
  1207. ---------------------
  1208.  
  1209. From: Eric A Rasmussen
  1210.  
  1211. Any turbo PC (8088 at 8 Mhz or greater)/286/386/486/etc. can produce a quality
  1212. playback of single channel 8 bit sounds on the internal (1 bit, 1 channel)
  1213. speaker by utilizing Pulse-Width-Modulation, which toggles the speaker faster
  1214. than it can physically move to simulate positions between fully on and fully
  1215. off.  There are several PD programs of this nature that I know of:
  1216.  
  1217. REMAC  - Plays MAC format sound files.  Files on the Macintosh, at least the
  1218.          sound files that I've ripped apart, seem to contain 3 parts.  The
  1219.          first two are info like what the file icon looks like and other
  1220.          header type info.  The third part contains the raw sample data, and
  1221.          it is this portion of the file which is saved to a seperate file,
  1222.          often named with the .snd extension by PC users.  Personally, I like
  1223.          to name the files .s1, .s2, .s3, or .s4 to indicate the sampling rate
  1224.          of the file. (-s# is how to specify the playback rate in REMAC.)
  1225.          REMAC provides playback rates of 5550hz, 7333hz, 11 khz, & 22 khz.
  1226. REMAC2 - Same as REMAC, but sounds better on higher speed machines.
  1227. REPLAY - Basically same as REMAC, but for playback of Atari ST sounds. 
  1228.          Apparently, the Atari has two sound formats, one of which sounds like
  1229.          garbage if played by REMAC or REPLAY in the incorrect mode.  The
  1230.          other file format works fine with REMAC and so appears to be 'normal'
  1231.          unsigned 8-bit data.  REPLAY provides playback rates of 11.5 khz,
  1232.          12.5 khz, 14 khz, 16 khz, 18.5 khz, 22khz, & 27 khz.
  1233.  
  1234. These three programs are all by the same author, Richard E. Zobell who does
  1235. not have an internet mail address to my knowledge, but does have a GEnie email
  1236. address of R.ZOBELL. 
  1237.  
  1238. Additionally, there are various stand-alone demos which use the internal
  1239. speaker, of which there is one called mushroom which plays a 30 second
  1240. advertising jingle for magic mushroom room deoderizers which is pretty
  1241. humerous.  I've used this player to playback samples that I ripped out of the
  1242. commercial game program Mean Streets, which uses something they call RealSound
  1243. (tm) to playback digital samples on the internal speaker. (Of course, I only do
  1244. this on my own system, and since I own the game, I see no problems with it.)
  1245.  
  1246. For owners of 8 Mhz 286's and above, the option to play 4 channel 8 bit sounds
  1247. (with decent quality) on the internal speaker is also a reality.  Quite a
  1248. number of PD programs exist to do this, including, but not limited to:
  1249.  
  1250. ModEdit, ModPlay, ScreamTracker, STM, Star Trekker, Tetra, and probably a few
  1251. more.  
  1252.  
  1253. All these programs basically make use of various sound formats used by the
  1254. Amiga line of computers.  These include .stm files, .mod files
  1255. [a.k.a. mod. files], and .nst files [really the same hing].  Also,
  1256. these programs pretty much all have the option to playback the 
  1257. sound to add-on hardware such as the SoundBlaster card, the Covox series of
  1258. devices, and also to direct the data to either one or two (for stereo)
  1259. parallel ports, which you could attach your own D/A's to.  (From what I have
  1260. seen, the Covox is basically an small amplified speaker with a D/A which plugs
  1261. into the parallel port.  This sounds very similiar to the Disney Sound System
  1262. (DSS) which people have been talking about recently.)  
  1263.  
  1264. ------------------------------------------------------------------------
  1265. The EA-IFF-85 documentation
  1266. ---------------------------
  1267.  
  1268. From: dgc3@midway.uchicago.edu
  1269.  
  1270. As promised, here's an ftp location for the EA-IFF-85 documentation.  It's
  1271. the November 1988 release as revised by Commodore (the last public release),
  1272. with specifications for IFF FORMs for graphics, sound, formatted text, and
  1273. more.  IFF FORMS now exist for other media, including structured drawing, and
  1274. new documentation is now available only from Commodore.
  1275.  
  1276. The documentation is at grind.isca.uiowa.edu [128.255.19.233], in the
  1277. directory /amiga/f1/ff185.  The complete file list is as follows:
  1278.  
  1279. DOCUMENTS.zoo    
  1280. EXAMPLES.zoo     
  1281. EXECUTABLE.zoo   
  1282. INCLUDE.zoo      
  1283. LINKER_INFO.zoo  
  1284. OBJECT.zoo       
  1285. SOURCE.zoo       
  1286. TP_IFF_Specs.zoo 
  1287.  
  1288. All files except DOCUMENTS.zoo are Amiga-specific, but may be used as a basis
  1289. for conversion to other platforms.  Well, I take that tentatively back.  I
  1290. don't know what TP_IFF_Specs.zoo contains, so it might be non-Amiga-specific.
  1291.  
  1292. ------------------------------------------------------------------------
  1293. US Federal Standard 1016 availability
  1294. -------------------------------------
  1295.  
  1296. From: Joe Campbell  N3JBC  jpcampb@afterlife.ncsc.mil  74040.305@compuserve.com
  1297.  
  1298. The U.S. DoD's Federal-Standard-1016 4800 bps code excited linear prediction
  1299. voice coder version 3.2 (CELP 3.2) Fortran and C simulation source codes are
  1300. now available for worldwide distribution at no charge (on DOS diskettes,
  1301. but configured to compile on Sun SPARC stations) from:
  1302.  
  1303. Bob Fenichel
  1304. National Communications System
  1305. Washington, D.C.  20305
  1306. 1-703-692-2124
  1307. 1-703-746-4960 (fax)
  1308.  
  1309. In addition to the source codes, example input and processed speech files
  1310. are included along with a technical information bulletin to assist in
  1311. implementation of FS-1016 CELP.  (An anonymous ftp site is being considered
  1312. for future releases.)
  1313.  
  1314. Copies of the FS-1016 document are available for $2.50 each from:
  1315.  
  1316. GSA Rm 6654
  1317. 7th & D St SW
  1318. Washington, D.C.  20407
  1319. 1-202-708-9205
  1320.  
  1321. The following articles describe the Federal-Standard-1016 4.8-kbps CELP
  1322. coder (it's unnecessary to read more than one):
  1323.  
  1324. Campbell, Joseph P. Jr., Thomas E. Tremain and Vanoy C. Welch,
  1325. "The Federal Standard 1016 4800 bps CELP Voice Coder," Digital Signal
  1326. Processing, Academic Press, 1991, Vol. 1, No. 3, p. 145-155.
  1327.  
  1328. Campbell, Joseph P. Jr., Thomas E. Tremain and Vanoy C. Welch,
  1329. "The DoD 4.8 kbps Standard (Proposed Federal Standard 1016),"
  1330. in Advances in Speech Coding, ed. Atal, Cuperman and Gersho,
  1331. Kluwer Academic Publishers, 1991, Chapter 12, p. 121-133.
  1332.  
  1333. Campbell, Joseph P. Jr., Thomas E. Tremain and Vanoy C. Welch, "The
  1334. Proposed Federal Standard 1016 4800 bps Voice Coder:  CELP," Speech
  1335. Technology Magazine, April/May 1990, p. 58-64.
  1336.  
  1337. For U.S. FED-STD-1016 (4800 bps CELP) _realtime_ DSP code
  1338. and information about products using this code, contact:
  1339.  
  1340. John DellaMorte
  1341. DSP Software Engineering
  1342. 165 Middlesex Tpk, Suite 206
  1343. Bedford, MA  01730
  1344. 1-617-275-3733
  1345. 1-617-275-4323 (fax)
  1346. dspse.bedford@channel1.com
  1347.  
  1348. DSP Software Engineering's code can run on a DSP Research's Tiger 30 board
  1349. (a PC board with a TMS320C3x and analog interface suited to development work)
  1350. or on Intellibit's AE2000 TMS320C31 based 3" by 2.5" card.
  1351.  
  1352. DSP Research                Intellibit
  1353. 1095 E. Duane Ave.          P.O. Box 9785
  1354. Sunnyvale, CA  94086        McLean, VA  22102-0785
  1355. (408)773-1042               (703)442-4781
  1356. (408)736-3451 (fax)         (703)442-4784 (fax)
  1357.  
  1358. From: tobiasr@monolith.lrmsc.loral.com (Richard Tobias )
  1359.  
  1360. For U.S. FED-STD-1016 (4800 bps CELP) _realtime_ DSP code and
  1361. information about products using this code using the AT&T DSP32C and
  1362. AT&T DSP3210, contact:
  1363.  
  1364. White Eagle Systems Technology, Inc.
  1365. 1123 Queensbridge Way
  1366. San Jose, CA 95120
  1367. (408) 997-2706
  1368. (408) 997-3584 (fax)
  1369. rjjt@netcom.com
  1370.  
  1371. ------------------------------------------------------------------------
  1372. Creative Voice (VOC) file format
  1373. --------------------------------
  1374.  
  1375. From: galt@dsd.es.com
  1376.  
  1377. (byte numbers are hex!)
  1378.  
  1379.     HEADER (bytes 00-19)
  1380.     Series of DATA BLOCKS (bytes 1A+) [Must end w/ Terminator Block]
  1381.  
  1382. - ---------------------------------------------------------------
  1383.  
  1384. HEADER:
  1385. =======
  1386.      byte #     Description
  1387.      ------     ------------------------------------------
  1388.      00-12      "Creative Voice File"
  1389.      13         1A (eof to abort printing of file)
  1390.      14-15      Offset of first datablock in .voc file (std 1A 00
  1391.                 in Intel Notation)
  1392.      16-17      Version number (minor,major) (VOC-HDR puts 0A 01)
  1393.      18-19      2's Comp of Ver. # + 1234h (VOC-HDR puts 29 11)
  1394.  
  1395. - ---------------------------------------------------------------
  1396.  
  1397. DATA BLOCK:
  1398. ===========
  1399.  
  1400.    Data Block:  TYPE(1-byte), SIZE(3-bytes), INFO(0+ bytes)
  1401.    NOTE: Terminator Block is an exception -- it has only the TYPE byte.
  1402.  
  1403.       TYPE   Description     Size (3-byte int)   Info
  1404.       ----   -----------     -----------------   -----------------------
  1405.       00     Terminator      (NONE)              (NONE)
  1406.       01     Sound data      2+length of data    *
  1407.       02     Sound continue  length of data      Voice Data
  1408.       03     Silence         3                   **
  1409.       04     Marker          2                   Marker# (2 bytes)
  1410.       05     ASCII           length of string    null terminated string
  1411.       06     Repeat          2                   Count# (2 bytes)
  1412.       07     End repeat      0                   (NONE)
  1413.  
  1414.       *Sound Info Format:       **Silence Info Format:
  1415.        ---------------------      ----------------------------
  1416.        00   Sample Rate           00-01  Length of silence - 1
  1417.        01   Compression Type      02     Sample Rate
  1418.        02+  Voice Data
  1419.  
  1420.  
  1421.   Marker#           -- Driver keeps the most recent marker in a status byte
  1422.   Count#            -- Number of repetitions + 1
  1423.                          Count# may be 1 to FFFE for 0 - FFFD repetitions
  1424.                          or FFFF for endless repetitions
  1425.   Sample Rate       -- SR byte = 256-(1000000/sample_rate)
  1426.   Length of silence -- in units of sampling cycle
  1427.   Compression Type  -- of voice data
  1428.                          8-bits    = 0
  1429.                          4-bits    = 1
  1430.                          2.6-bits  = 2
  1431.                          2-bits    = 3
  1432.                          Multi DAC = 3+(# of channels) [interesting--
  1433.                                        this isn't in the developer's manual]
  1434.  
  1435. ------------------------------------------------------------------------
  1436. RIFF WAVE (.WAV) file format
  1437. ----------------------------
  1438.  
  1439. RIFF is a format by Microsoft and IBM which is similar in spirit and
  1440. functionality as EA-IFF-85, but not compatible (and it's in
  1441. little-endian byte order, of course :-).  WAVE is RIFF's equivalent of
  1442. AIFF, and its inclusion in Microsoft Windows 3.1 has suddenly made it
  1443. important to know about.
  1444.  
  1445. Rob Ryan was kind enough to send me a description of the RIFF format.
  1446. Unfortunately, it is too big to include here (27 k), but I've made it
  1447. available for anonymous ftp as ftp.cwi.nl:/pub/RIFF-format.
  1448.  
  1449. And here's a pointer to the official description from Matt Saettler,
  1450. Microsoft Multimedia:
  1451.  
  1452. "The complete definition of the WAVE file format as defined by
  1453. IBM/Microsoft is available for anon. FTP from ftp.uu.net in the
  1454. vendor/microsoft/multimedia directory."
  1455.  
  1456. (Rob Ryan's version may actually be an extract from one of the files
  1457. stored there.)
  1458.  
  1459. ------------------------------------------------------------------------
  1460. U-LAW and A-LAW definitions
  1461. ---------------------------
  1462.  
  1463. [Adapted from information provided by duggan@cc.gatech.edu (Rick
  1464. Duggan) and davep@zenobia.phys.unsw.EDU.AU (David Perry)]
  1465.  
  1466. u-LAW (really mu-LAW) is
  1467.  
  1468.           sgn(m)   (     |m |)       |m |
  1469.    y=    ------- ln( 1+ u|--|)       |--| =< 1
  1470.          ln(1+u)   (     |mp|)       |mp|         
  1471.  
  1472. A-LAW is
  1473.  
  1474.      |     A    (m )                 |m |    1
  1475.      |  ------- (--)                 |--| =< - 
  1476.      |  1+ln A  (mp)                 |mp|    A     
  1477.    y=|
  1478.      | sgn(m) (        |m |)    1    |m |
  1479.      | ------ ( 1+ ln A|--|)    - =< |--| =< 1
  1480.      | 1+ln A (        |mp|)    A    |mp|         
  1481.  
  1482. Values of u=100 and 255, A=87.6, mp is the Peak message value, m is
  1483. the current quantised message value.  (The formulae get simpler if you
  1484. substitute x for m/mp and sgn(x) for sgn(m); then -1 <= x <= 1.)
  1485.  
  1486. Converting from u-LAW to A-LAW is in a sense "lossy" since there are
  1487. quantizing errors introduced in the conversion.
  1488.  
  1489. "..the u-LAW used in North America and Japan, and the
  1490. A-LAW used in Europe and the rest of the world and
  1491. international routes.."
  1492.  
  1493. References:
  1494.  
  1495. Modern Digital and Analog Communication Systems, B.P.Lathi., 2nd ed.
  1496. ISBN 0-03-027933-X
  1497.  
  1498. Transmission Systems for Communications
  1499. Fifth Edition
  1500. by Members of the Technical Staff at Bell Telephone Laboratories
  1501. Bell Telephone Laboratories, Incorporated
  1502. Copyright 1959, 1964, 1970, 1982
  1503.  
  1504. ------------------------------------------------------------------------
  1505. AVR File Format
  1506. ---------------
  1507.  
  1508. From: hyc@hanauma.Jpl.Nasa.Gov (Howard Chu)
  1509.  
  1510. A lot of PD software exists to play Mac .snd files on the ST. One other
  1511. format that seems pretty popular (used by a number of commercial packages)
  1512. is the AVR format (from Audio Visual Research). This format has a 128 byte
  1513. header that looks like this:
  1514.  
  1515.         char magic[4]="2BIT";
  1516.         char name[8];           /* null-padded sample name */
  1517.         short mono;             /* 0 = mono, 0xffff = stereo */
  1518.         short rez;              /* 8 = 8 bit, 16 = 16 bit */
  1519.         short sign;             /* 0 = unsigned, 0xffff = signed */
  1520.         short loop;             /* 0 = no loop, 0xffff = looping sample */
  1521.         short midi;             /* 0xffff = no MIDI note assigned,
  1522.                                    0xffXX = single key note assignment
  1523.                                    0xLLHH = key split, low/hi note */
  1524.         long rate;              /* sample frequency in hertz */
  1525.         long size;              /* sample length in bytes or words (see rez) */
  1526.         long lbeg;              /* offset to start of loop in bytes or words.
  1527.                                    set to zero if unused. */
  1528.         long lend;              /* offset to end of loop in bytes or words.
  1529.                                    set to sample length if unused. */
  1530.         short res1;             /* Reserved, MIDI keyboard split */
  1531.         short res2;             /* Reserved, sample compression */
  1532.         short res3;             /* Reserved */
  1533.         char ext[20];           /* Additional filename space, used
  1534.                                    if (name[7] != 0) */
  1535.         char user[64];          /* User defined. Typically ASCII message. */
  1536.  
  1537. -----------------------------------------------------------------------
  1538. The Amiga MOD Format
  1539. --------------------
  1540.  
  1541. From: norlin@mailhost.ecn.uoknor.edu (Norman Lin)
  1542.  
  1543. MOD files are music files containing 2 parts:
  1544.  
  1545. (1) a bank of digitized samples
  1546. (2) sequencing information describing how and when to play the samples
  1547.  
  1548. MOD files originated on the Amiga, but because of their flexibility
  1549. and the extremely large number of MOD files available, MOD players
  1550. are now available for a variety of machines (IBM PC, Mac, Sparc
  1551. Station, etc.)
  1552.  
  1553. The samples in a MOD file are raw, 8 bit, signed, headerless, linear
  1554. digital data.  There may be up to 31 distinct samples in a MOD file,
  1555. each with a length of up to 128K (though most are much smaller; say,
  1556. 10K - 60K).  An older MOD format only allowed for up to 15 samples in
  1557. a MOD file; you don't see many of these anymore.  There is no standard
  1558. sampling rate for these samples.
  1559.  
  1560. The sequencing information in a MOD file contains 4 tracks of
  1561. information describing which, when, for how long, and at what frequency
  1562. samples should be played.  This means that a MOD file can have up
  1563. to 31 distinct (digitized) instrument sounds, with up to 4 playing
  1564. simultaneously at any given point.  This allows a wide variety
  1565. of orchestrational possibilities, including use of voice samples
  1566. or creation of one's own instruments (with appropriate sampling
  1567. hardware/software).  The ability to use one's own samples as instruments
  1568. is a flexibility that other music files/formats do not share, and
  1569. is one of the reasons MOD files are so popular, numerous, and diverse.
  1570.  
  1571. 15 instrument MODs, as noted above, are somewhat older than 31
  1572. instrument MODs and are not (at least not by me) seen very often
  1573. anymore.  Their format is identical to that of 31 instrument MODs
  1574. except:
  1575.  
  1576. (1) Since there are only 15 samples, the information for the last (15th)
  1577.     sample starts at byte 440 and goes through byte 469.
  1578. (2) The songlength is at byte 470 (contrast with byte 950 in 31 instrument
  1579.     MOD)
  1580. (3) Byte 471 appears to be ignored, but has been observed to be 127.
  1581.     (Sorry, this is from observation only)
  1582. (4) Byte 472 begins the pattern sequence table (contrast with byte 952
  1583.     in a 31 instrument MOD)
  1584. (5) Patterns start at byte 600 (contrast with byte 1084 in 31 instrument MOD)
  1585.  
  1586. "ProTracker," an Amiga MOD file creator/editor, is available for ftp
  1587. everywhere as pt??.lzh.
  1588.  
  1589. From: Apollo Wong <apollo@ee.ualberta.ca>
  1590.  
  1591. From: M.J.H.Cox@bradford.ac.uk (Mark Cox)
  1592. Newsgroups: alt.sb.programmer
  1593. Subject: Re: Format for MOD files...
  1594. Message-ID: <1992Mar18.103608.4061@bradford.ac.uk>
  1595. Date: 18 Mar 92 10:36:08 GMT
  1596. Organization: University of Bradford, UK
  1597.  
  1598. wdc50@DUTS.ccc.amdahl.com (Winthrop D Chan) writes:
  1599. >I'd like to know if anyone has a reference document on the format of the
  1600. >Amiga Sound/NoiseTracker (MOD) files. The author of Modplay said he was going
  1601. >to release such a document sometime last year, but he never did. If anyone
  1602.  
  1603. I found this one, which covers it better than I can explain it - if you
  1604. use this in conjunction with the documentation that comes with Norman
  1605. Lin's Modedit program it should pretty much cover it.
  1606.  
  1607. Mark J Cox
  1608.  
  1609. /***********************************************************************
  1610.  
  1611. Protracker 1.1B Song/Module Format:
  1612. -----------------------------------
  1613.  
  1614. Offset  Bytes  Description
  1615. ------  -----  -----------
  1616.    0     20    Songname. Remember to put trailing null bytes at the end...
  1617.  
  1618. Information for sample 1-31:
  1619.  
  1620. Offset  Bytes  Description
  1621. ------  -----  -----------
  1622.   20     22    Samplename for sample 1. Pad with null bytes.
  1623.   42      2    Samplelength for sample 1. Stored as number of words.
  1624.                Multiply by two to get real sample length in bytes.
  1625.   44      1    Lower four bits are the finetune value, stored as a signed
  1626.                four bit number. The upper four bits are not used, and
  1627.                should be set to zero.
  1628.                Value:  Finetune:
  1629.                  0        0
  1630.                  1       +1
  1631.                  2       +2
  1632.                  3       +3
  1633.                  4       +4
  1634.                  5       +5
  1635.                  6       +6
  1636.                  7       +7
  1637.                  8       -8
  1638.                  9       -7
  1639.                  A       -6
  1640.                  B       -5
  1641.                  C       -4
  1642.                  D       -3
  1643.                  E       -2
  1644.                  F       -1
  1645.  
  1646.   45      1    Volume for sample 1. Range is $00-$40, or 0-64 decimal.
  1647.   46      2    Repeat point for sample 1. Stored as number of words offset
  1648.                from start of sample. Multiply by two to get offset in bytes.
  1649.   48      2    Repeat Length for sample 1. Stored as number of words in
  1650.                loop. Multiply by two to get replen in bytes.
  1651.  
  1652. Information for the next 30 samples starts here. It's just like the info for
  1653. sample 1.
  1654.  
  1655. Offset  Bytes  Description
  1656. ------  -----  -----------
  1657.   50     30    Sample 2...
  1658.   80     30    Sample 3...
  1659.    .
  1660.    .
  1661.    .
  1662.  890     30    Sample 30...
  1663.  920     30    Sample 31...
  1664.  
  1665. Offset  Bytes  Description
  1666. ------  -----  -----------
  1667.  950      1    Songlength. Range is 1-128.
  1668.  951      1    Well... this little byte here is set to 127, so that old
  1669.                trackers will search through all patterns when loading.
  1670.                Noisetracker uses this byte for restart, but we don't.
  1671.  952    128    Song positions 0-127. Each hold a number from 0-63 that
  1672.                tells the tracker what pattern to play at that position.
  1673. 1080      4    The four letters "M.K." - This is something Mahoney & Kaktus
  1674.                inserted when they increased the number of samples from
  1675.                15 to 31. If it's not there, the module/song uses 15 samples
  1676.                or the text has been removed to make the module harder to
  1677.                rip. Startrekker puts "FLT4" or "FLT8" there instead.
  1678.  
  1679. Offset  Bytes  Description
  1680. ------  -----  -----------
  1681. 1084    1024   Data for pattern 00.
  1682.    .
  1683.    .
  1684.    .
  1685. xxxx  Number of patterns stored is equal to the highest patternnumber
  1686.       in the song position table (at offset 952-1079).
  1687.  
  1688. Each note is stored as 4 bytes, and all four notes at each position in
  1689. the pattern are stored after each other.
  1690.  
  1691. 00 -  chan1  chan2  chan3  chan4
  1692. 01 -  chan1  chan2  chan3  chan4
  1693. 02 -  chan1  chan2  chan3  chan4
  1694. etc.
  1695.  
  1696. Info for each note:
  1697.  
  1698.  _____byte 1_____   byte2_    _____byte 3_____   byte4_
  1699. /                \ /      \  /                \ /      \
  1700. 0000          0000-00000000  0000          0000-00000000
  1701.  
  1702. Upper four    12 bits for    Lower four    Effect command.
  1703. bits of sam-  note period.   bits of sam-
  1704. ple number.                  ple number.
  1705.  
  1706. Periodtable for Tuning 0, Normal
  1707.   C-1 to B-1 : 856,808,762,720,678,640,604,570,538,508,480,453
  1708.   C-2 to B-2 : 428,404,381,360,339,320,302,285,269,254,240,226
  1709.   C-3 to B-3 : 214,202,190,180,170,160,151,143,135,127,120,113
  1710.  
  1711. To determine what note to show, scan through the table until you find
  1712. the same period as the one stored in byte 1-2. Use the index to look
  1713. up in a notenames table.
  1714.  
  1715. This is the data stored in a normal song. A packed song starts with the
  1716. four letters "PACK", but i don't know how the song is packed: You can
  1717. get the source code for the cruncher/decruncher from us if you need it,
  1718. but I don't understand it; I've just ripped it from another tracker...
  1719.  
  1720. In a module, all the samples are stored right after the patterndata.
  1721. To determine where a sample starts and stops, you use the sampleinfo
  1722. structures in the beginning of the file (from offset 20). Take a look
  1723. at the mt_init routine in the playroutine, and you'll see just how it
  1724. is done.
  1725.  
  1726. Lars "ZAP" Hamre/Amiga Freelancers
  1727.  
  1728. ***********************************************************************/
  1729.  
  1730. -- 
  1731. Mark J Cox -----
  1732. Bradford, UK ---
  1733.  
  1734. -----------------------------------------------------------------------
  1735.