home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / utilities / utilsf / ifftext / 8SVX next >
Text File  |  1993-06-24  |  28KB  |  667 lines

  1. "8SVX" IFF 8-Bit Sampled Voice
  2.  
  3. Date:   February 7, 1985
  4. From:   Steve Hayes and Jerry Morrison, Electronic Arts
  5. Status: Adopted
  6.  
  7. 1. Introduction
  8.  
  9. This memo is the IFF supplement for FORM "8SVX". An 8SVX is an IFF 
  10. "data section" or "FORM" (which can be an IFF file or a part of one) 
  11. containing a digitally sampled audio voice consisting of 8-bit samples. 
  12. A voice can be a one-shot sound orQwith repetition and pitch scalingQa 
  13. musical instrument. "EA IFF 85" is Electronic Arts' standard interchange 
  14. file format. [See "EA IFF 85" Standard for Interchange Format Files.]
  15.  
  16. The 8SVX format is designed for playback hardware that uses 8-bit 
  17. samples attenuated by a volume control for good overall signal-to-noise 
  18. ratio. So a FORM 8SVX stores 8-bit samples and a volume level.
  19.  
  20. A similar data format (or two) will be needed for higher resolution 
  21. samples (typically 12 or 16 bits). Properly converting a high resolution 
  22. sample down to 8 bits requires one pass over the data to find the 
  23. minimum and maximum values and a second pass to scale each sample 
  24. into the range -128 through 127. So it's reasonable to store higher 
  25. resolution data in a different FORM type and convert between them.
  26.  
  27. For instruments, FORM 8SVX can record a repeating waveform optionally 
  28. preceded by a startup transient waveform. These two recorded signals 
  29. can be pre-synthesized or sampled from an acoustic instrument. For 
  30. many instruments, this representation is compact. FORM 8SVX is less 
  31. practical for an instrument whose waveform changes from cycle to cycle 
  32. like a plucked string, where a long sample is needed for accurate 
  33. results.
  34.  
  35. FORM 8SVX can store an "envelope" or "amplitude contour" to enrichen 
  36. musical notes. A future voice FORM could also store amplitude, frequency, 
  37. and filter modulations.
  38.  
  39. FORM 8SVX is geared for relatively simple musical voices, where one 
  40. waveform per octave is sufficient, where the waveforms for the different 
  41. octaves follows a factor-of-two size rule, and where one envelope 
  42. is adequate for all octaves. You could store a more general voice 
  43. as a LIST containing one or more FORMs 8SVX per octave. A future voice 
  44. FORM could go beyond one "one-shot" waveform and one "repeat" waveform 
  45. per octave.
  46.  
  47. Section 2 defines the required property sound header "VHDR", optional 
  48. properties name "NAME", copyright "(c)J", and author "AUTH", the optional 
  49. annotation data chunk "ANNO", the required data chunk "BODY", and 
  50. optional envelope chunks "ATAK" and "RLSE". These are the "standard" 
  51. chunks. Specialized chunks for private or future needs can be added 
  52. later, e.g. to hold a frequency contour or Fourier series coefficients. 
  53. The 8SVX syntax is summarized in Appendix A as a regular expression 
  54. and in Appendix B as an example box diagram. Appendix C explains the 
  55. optional Fibonacci-delta compression algorithm.
  56.  
  57. Caution: The VHDR structure Voice8Header changed since draft proposal 
  58. #4! The new structure is incompatible with the draft version.
  59.  
  60.  
  61.  
  62. Reference:
  63.  
  64. "EA IFF 85" Standard for Interchange Format Files describes the underlying 
  65. conventions for all IFF files.
  66.  
  67. Amiga[tm] is a trademark of Commodore-Amiga, Inc.
  68.  
  69. Electronic Arts[tm] is a trademark of Electronic Arts.
  70.  
  71. MacWrite[tm] is a trademark of Apple Computer, Inc.
  72.  
  73.  
  74.  
  75. 2. Standard Data and Property Chunks
  76.  
  77. FORM 8SVX stores all the waveform data in one body chunk "BODY". It 
  78. stores playback parameters in the required header chunk "VHDR". "VHDR" 
  79. and any optional property chunks "NAME", "(c)J", and "AUTH" must all 
  80. appear before the BODY chunk. Any of these properties may be shared 
  81. over a LIST of FORMs 8SVX by putting them in a PROP 8SVX. [See "EA 
  82. IFF 85" Standard for Interchange Format Files.]
  83.  
  84. Background
  85.  
  86. There are two ways to use FORM 8SVX: as a one-shot sampled sound or 
  87. as a sampled musical instrument that plays "notes". Storing both kinds 
  88. of sounds in the same kind of FORM makes it easy to play a one-shot 
  89. sound as a (staccato) instrument or an instrument as a (one-note) 
  90. sound.
  91.  
  92. A one-shot sound is a series of audio data samples with a nominal 
  93. playback rate and amplitude. The recipient program can optionally 
  94. adjust or modulate the amplitude and playback data rate.
  95.  
  96. For musical instruments, the idea is to store a sampled (or pre-synthesized) 
  97. waveform that will be parameterized by pitch, duration, and amplitude 
  98. to play each "note". The creator of the FORM 8SVX can supply a waveform 
  99. per octave over a range of octaves for this purpose. The intent is 
  100. to perform a pitch by selecting the closest octave's waveform and 
  101. scaling the playback data rate. An optional "one-shot" waveform supplies 
  102. an arbitrary startup transient, then a "repeat" waveform is iterated 
  103. as long as necessary to sustain the note.
  104.  
  105. A FORM 8SVX can also store an envelope to modulate the waveform. Envelopes 
  106. are mostly useful for variable-duration notes but could be used for 
  107. one-shot sounds, too.
  108.  
  109. The FORM 8SVX standard has some restrictions. For example, each octave 
  110. of data must be twice as long as the next higher octave. Most sound 
  111. driver software and hardware imposes additional restrictions. E.g. 
  112. the Amiga sound hardware requires an even number of samples in each 
  113. one-shot and repeat waveform.
  114.  
  115. Required Property VHDR
  116.  
  117. The required property "VHDR" holds a Voice8Header structure as defined 
  118. in these C declarations and following documentation. This structure 
  119. holds the playback parameters for the sampled waveforms in the BODY 
  120. chunk. (See "Data Chunk BODY", below, for the storage layout of these 
  121. waveforms.)
  122.  
  123. #define ID_8SVX MakeID('8', 'S', 'V', 'X')
  124. #define ID_VHDR MakeID('V', 'H', 'D', 'R')
  125.  
  126. typedef LONG Fixed;     
  127.         /* A fixed-point value, 16 bits to the left of the point and 16 
  128.          * to the right. A Fixed is a number of 216ths, i.e. 65536ths.  */
  129.  
  130. #define Unity 0x10000L  /* Unity = Fixed 1.0 = maximum volume   */
  131.  
  132. /* sCompression: Choice of compression algorithm applied to the samples. */ 
  133.  
  134. #define sCmpNone       0        /* not compressed       */
  135. #define sCmpFibDelta   1        /* Fibonacci-delta encoding (Appendix C)  */ 
  136.  
  137. /* Can be more kinds in the future.     */
  138.  
  139. typedef struct {
  140.         ULONG oneShotHiSamples, /* # samples in the high octave 1-shot part */
  141.         repeatHiSamples,        /* # samples in the high octave repeat part */
  142.         samplesPerHiCycle;      /* # samples/cycle in high octave, else 0   */
  143.         UWORD samplesPerSec;    /* data sampling rate   */
  144.         UBYTE ctOctave,         /* # octaves of waveforms       */
  145.         sCompression;           /* data compression technique used      */
  146.         Fixed volume;           /* playback volume from 0 to Unity (full 
  147.                                  * volume). Map this value into the output 
  148.                                  * hardware's dynamic range.    */
  149.         } Voice8Header;
  150.  
  151. [Implementation details. Fields are filed in the order shown. The 
  152. UBYTE fields are byte-packed (2 per 16-bit word). MakeID is a C macro 
  153. defined in the main IFF document and in the source file IFF.h.]
  154.  
  155. A FORM 8SVX holds waveform data for one or more octaves, each containing 
  156. a one-shot part and a repeat part. The fields oneShotHiSamples and 
  157. repeatHiSamples tell the number of audio samples in the two parts 
  158. of the highest frequency octave. Each successive (lower frequency) 
  159. octave contains twice as many data samples in both its one-shot and 
  160. repeat parts. One of these two parts can be empty across all octaves.
  161.  
  162. Note: Most audio output hardware and software has limitations. The 
  163. Amiga computer's sound hardware requires that all one-shot and repeat 
  164. parts have even numbers of samples. Amiga sound driver software would 
  165. have to adjust an odd-sized waveform, ignore an odd-sized lowest octave, 
  166. or ignore odd FORMs 8SVX altogether. Some other output devices require 
  167. all sample sizes to be powers of two.
  168.  
  169. The field samplesPerHiCycle tells the number of samples/cycle in the 
  170. highest frequency octave of data, or else 0 for "unknown". Each successive 
  171. (lower frequency) octave contains twice as many samples/cycle. The 
  172. samplesPerHiCycle value is needed to compute the data rate for a desired 
  173. playback pitch.
  174.  
  175. Actually, samplesPerHiCycle is an average number of samples/cycle. 
  176.