home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer: Getting Started / Internet Surfer - Getting Started (Wayzata Technology)(7231)(1995).bin / pc / textfile / faqs / audio / part1 < prev   
Encoding:
Internet Message Format  |  1995-01-01  |  63.0 KB

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