home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / sound / dosound / thechip.lst < prev    next >
File List  |  1992-03-26  |  9KB  |  176 lines

  1. The Sound Chip:
  2.  
  3.   The Atari ST computers use a fairly common programmable sound chip. There 
  4. are three tone channels which can play simultaneously or independently.  
  5. The range of frequencies available are from 30Hz to 125,000Hz.  This range 
  6. far exceeds the limits of the ST's speaker as well as the human ear (middle
  7. C has a frequency of 261.6Hz). The desired frequencies must be passed to 
  8. the sound chip as a 12 bit period value.  This value is derived from the 
  9. formula:
  10.  
  11.     period = 125,000 / frequency (in Hz)
  12.  
  13.   Therefore, to hear a middle C tone, a period value of 478 is needed 
  14. (478 = 125,000 / 261.6).
  15.  
  16.   The first step to sounding a tone is to pass the period value to the 
  17. appropriate sound chip registers.  They are as follows:
  18.  
  19. Register    Bits    Description
  20.    0        0-7    Low byte of tone period for Channel A
  21.    1        0-3    High nibble of tone period for Channel A
  22.    2        0-7    Low byte of tone period for Channel B
  23.    3        0-3    High nibble of tone period for Channel B
  24.    4        0-7    Low byte of tone period for Channel C
  25.    5        0-3    High nibble of tone period for Channel C
  26.   
  27.   Notice that since the sound chip registers are byte sized, and the tone 
  28. period may be 12 bits (a value of 0 to 4096), 2 registers are needed to 
  29. store the tone period for each channel.  To hear the tone of middle C on 
  30. channel A, register 0 would be loaded with the value of 222 (the lower byte
  31. of 478) and register 1 would be loaded with a value of 256 (the high nibble
  32. of 478).
  33.  
  34.   The sound chip also has a register which controls a static type sound.  
  35. Any or all of the tone channels may be connected to this register, in which
  36. case the static will sound when that channel is enabled for noise (see 
  37. below) and its volume is set to a value greater than 0.
  38.  
  39. Register    Bits    Description
  40.    6        0-4    Noise period
  41.  
  42.   The range of values for this register are 0-31.  A value of 0 creates a 
  43. static type sound similar to a snare drum while a higher value deepens the 
  44. sound to the point of sounding like rushing wind.
  45.  
  46.   The next step to sounding a tone is to enable the appropriate channels 
  47. for sound and or noise.  This is accomplished by setting the appropriate 
  48. bits in register 7 as follows:
  49.  
  50. Register    Bits    Description
  51.    7        0    Enabling for Channel A tone.
  52.    7        1    Enabling for Channel B tone.
  53.    7        2    Enabling for Channel C tone.
  54.    7        3    Enabling for Channel A noise.
  55.    7        4    Enabling for Channel B noise.
  56.    7        5    Enabling for Channel C noise.
  57.    7        6    Enabling for Channel A I/O.
  58.    7        7    Enabling for Channel B I/O.
  59.  
  60.   A value of 0 in the desired bit will enable its function, while a value 
  61. of 1 (bit is set) will disable its function.  Therefore, to enable all 
  62. channels for tone but not for noise requires a value of 56 to be passed to 
  63. register 7.  Notice that bits 6 and 7 control the data flow for the ST's 
  64. two I/O ports and have nothing to do with sound functions.  Because of this,
  65. it is important not to change the settings of these bits or else you may 
  66. loose communication with your floppy drives.  The correct way to write to 
  67. this register is to first read its value in and then OR its current value 
  68. with your desired value for bits 0-5.
  69.  
  70.   The last step to hear a tone is to set the volume.  There are 3 registers
  71. which control the volumes for each of the three channels as follows:
  72.  
  73. Register    Bits    Description
  74.    8        0-4    Volume for Channel A
  75.    9        0-4    Volume for Channel B
  76.   10        0-4    Volume for Channel C
  77.  
  78.   Since there are four bits for the volume, there is a range of 0-31 for 
  79. its value.  However, when bit 4 is set in the volume register, the values 
  80. in bits 0-3 are ignored.  Volumes of 0-15 will sound as a constant tone 
  81. (0 being off, 15 being the loudest), while a volume of 16 (bit 4 set) means
  82. to use the wave envelope and the wave period as they are set in registers 
  83. 11-13 to control the volume. 
  84.  
  85.   The wave period determines how many cycles of the wave envelope should 
  86. occur in one second.  The range of values for this parameter are from 0 to 
  87. 65535.  The lower the value, the faster the wave envelope will cycle.  
  88. The higher the value, the slower the wave envelope will cycle.
  89.  
  90. Register    Bits    Description
  91.    11        0-7    Low byte of the wave period.
  92.    12        0-7    High byte of the wave period.
  93.  
  94.   The eight wave envelopes are as follows:
  95.  
  96. Value    Shape        Description
  97.   8    \|\|\|\|\    From max volume to 0, instant to max, cycle
  98.   9    \________    From max volume to 0 and hold at 0
  99.  10    \/\/\/\/\    From max volume to 0, gradual back to max, cycle
  100.  11    \|-------    From max volume to 0, instant to max and hold
  101.  12    /|/|/|/|/    From 0 volume to max, instant to 0, cycle
  102.  13    /--------    From 0 volume to max and hold at max
  103.  14    /\/\/\/\/    From 0 volume to max, gradual back to 0,cycle
  104.  15    /|_______    From 0 volume to max, instant to 0 and hold
  105.  
  106.   Note that some of the wave envelopes cycle through their shapes while 
  107. others terminate at a volume of 0 or 15.  To hear a tone with one of the 
  108. wave envelopes, first place the value of the desired wave envelope in 
  109. register 13, then set the wave period in registers 11 and 12, and finally 
  110. set the volume to 16.
  111.  
  112.   The best way to experiment with these registers is via the DoEffect 
  113. program.  In this program, all of the sound chip registers are presented 
  114. on one screen.  The various values can be changed quickly and easily and 
  115. the results can be heard right away.
  116.  
  117. Limitations of the Sound Chip:
  118.  
  119.   While quite capable of playing some very interesting music, the Sound 
  120. Chip does suffer from several limitations.  From the above descriptions of 
  121. the various registers, some of these may be fairly obvious.  For starters, 
  122. only 3 notes can be played at any one time.  Second, the noise period 
  123. applies to all channels enabled for noise (each channel cannot have a 
  124. different noise period at any given time).  Thirdly, the wave envelopes 
  125. come in standard pre-defined shapes and cannot be altered.  Lastly, all 
  126. channels that use a wave envelope must use the same wave envelope.  Other 
  127. less significant limitations exist, but do not become apparent until they 
  128. are experimented with.
  129.  
  130.   For example, let us consider two notes that we intend to play using wave 
  131. envelope number 9.  This envelope is particularly interesting because it 
  132. follows a pattern similar to most musical instruments.  Initially the 
  133. volume is at its maximum value and slowly decays to a value of 0.  We can 
  134. control how fast the volume decreases by adjusting the wave period 
  135. accordingly.  Now in our example, the first note to sound is a whole note.
  136. After a half note rest, we want another tone to begin sounding.  Since the 
  137. first note is still active, and the wave form is starting to decay, when 
  138. we attempt to sound the second note, its volume will follow the wave 
  139. envelope which is already in progress and at a value less than maximum 
  140. volume.  If the wave period was set to a relatively fast value, we may not 
  141. hear the second note at all since the wave envelope would be near or at a 
  142. volume of 0.  This particular wave envelope (like some of the others) does 
  143. not cycle but rather sustains at its final value (0 in this case).  In 
  144. order to cause additional notes to be heard with this wave envelope, 
  145. register 13 must be re-loaded with the value of this envelope (in this 
  146. case 9) each time you wish for the cycle of the envelope to start again.  
  147. Doing this however, has one side effect.  Each note that is currently being 
  148. played will have its volume reset to the new value of the wave envelope.  
  149. So in our example, if before the second note is played we put the wave 
  150. envelope back into register 13, what we will actually hear is a half note 
  151. of the first tone, followed by a half note of the first and second tone.
  152.  
  153.   There is an option within the DoSound program to control whether or not 
  154. you want the wave envelope to be placed back into register 13 whenever a 
  155. new note is encountered.  This feature is provided by measures.  If you 
  156. elect not to insert the wave for each note within the measure(s) in 
  157. question, and you are using a wave envelope that terminates at a value of 
  158. 0 or 15, a large wave period may be in order.  This will cause the wave 
  159. envelope to last longer over the measure(s).  Obviously this particular 
  160. problem is not evident with the wave envelopes that repeat their patterns.
  161. Additionally, it is worth noting that a complete song that requires many 
  162. registers 13 messages will require larger files than those that do not.  
  163. However, the sound quality provided by these particular waves, far out 
  164. weights the additional file lengths.
  165.  
  166.   Another method which has been provided within the DoSound program to 
  167. control these wave envelope message is within the volume dialog box.  
  168. Often it is not necessary for very short notes to make use of the wave 
  169. envelopes.  Therefore an option has been provided that will change the 
  170. volumes of all notes less than a specific length to a specific volume.  
  171. A common use of this feature would be to change all notes less than 13 
  172. clicks (an eighth note or shorter) to a volume of 14 or 15.  When this 
  173. is done, these notes will not interfere with longer notes which are making 
  174. use of a wave envelope.
  175.  
  176.