home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 348.lha / chatterbox_v1.0 / README < prev    next >
Text File  |  1990-02-14  |  12KB  |  279 lines

  1.  
  2. chatterbox - have the Amiga play IFF audio sample files when events occur
  3.  
  4. Version 1.0 -- first public release
  5.  
  6. Copyright (C) 1989 by Karl Lehenbauer, All Rights Reserved
  7.   This code is freely redistributable (and reusable) for 
  8.   noncommercial purposes providing this notice is retained.
  9.  
  10.  
  11. Intro
  12. -----
  13.  
  14. Chatterbox is largely the result of two evenings work, the 22nd and 23rd 
  15. of May, 1989.  One reason for the fast start was that I was able to reuse
  16. a lot of code from some other Amiga programs I've written.
  17.  
  18. In any case, Chatterbox allows one to load and play sounds on the occurence
  19. of several detectable events, such as disk insertion and deletion, calling
  20. the DisplayBeep function, a time interval elapsing, preferences chaging,
  21. activation and deactivation of Chatterbox's window, and eventually, other 
  22. events as well.  In order that it not eat up your precious "chip" RAM,
  23. chatterbox uses your "fast" RAM (if you have any) to cache the loaded
  24. sounds, only copying them to chip RAM when it's to play them.
  25.  
  26. There are a maximum of 32 sounds that may be defined for each type of
  27. event that Chatterbox can play sounds for, although hard disk users may
  28. have many more sounds triggered by timer events (more on this later).
  29.  
  30.  
  31. Running Chatterbox
  32. ------------------
  33.  
  34. If you got Chatterbox on a disk and everything's set up properly, you should
  35. be able to click open the disk, then doubleclick on the chatterbox icon, and
  36. off it goes.  If you downloaded this from somewhere or something, you may
  37. have to set it up yourself.  If so, please examine the "Configuring 
  38. Chatterbox" section following this one.
  39.  
  40. Chatterbox can also be run from the CLI.  Thus, it could be started
  41. automatically by your boot sequence (by starting it from your 
  42. s:startups-sequence).  You'll need to do a "run" or "runback" on it
  43. if you do start it in the startup sequence, as it does not return
  44. until you exit it by clicking the close gadget in the Chatterbox window,
  45. select the "quit" option in Chatterbox's pull-down menu or entering
  46. Control-C in the window of the CLI from which Chatterbox was started.
  47.  
  48.  
  49. Configuring Chatterbox
  50. ----------------------
  51.  
  52. Chatterbox looks in ChatterBox: for a configuration file named "config.data".
  53. ChatterBox: should be the name of the floppy containing the config file and
  54. all the sounds, or it can be an assign to a directory on your hard disk,
  55. floppy, RAM disk, or whatever.  The format for config.data is very simple.
  56. A number of keywords may occur in column one of a line.  After a line
  57. containing a keyword (and possibly, optional parameters), a number of file
  58. names are specified, with a blank in column one and the name starting in
  59. column two.  Chatterbox is pretty stupid about this, so it is important
  60. that you adhere to this format.  For example, if you wanted to play the
  61. sound of a toilet flush (named "Toilet") or a car crash (named "CarCrash")
  62. when a disk is removed while chatterbox is running, you would put the
  63. following three lines in your config.data file:
  64.  
  65. diskout
  66.  Toilet
  67.  CarCrash
  68.  
  69. Note that the keywords must be all lower case.  The keywords and their
  70. functions are explained below:
  71.  
  72.     diskin - play a sound when a disk is inserted
  73.     diskout - play a sound when a disk is removed
  74.     activate - play a sound when chatterbox's window is activated
  75.     deactivate - play a sound when chatterbox's window is deactivated
  76.     beep - play a sound on the next occurence of a DisplayBeep
  77.     timer - play a sound every so often (default is every five minutes)
  78.     preferences - play a sound when preferences change (weird, but hey)
  79.  
  80. Following the keyword, specify the names of the sample files, one to a
  81. line with a blank in column one and the name starting in column two,
  82. up to 32 sounds.  If a sound is repeated in more than one event's list,
  83. it will still only be loaded once.  A sample config.data file occurs at 
  84. the end of this document.
  85.  
  86.  
  87. Memory Considerations
  88. ---------------------
  89.  
  90. There are two types of memory on the Amiga, "chip" and "fast."  So-called
  91. chip RAM is memory that can be accessed by the custom chips in the Amiga.
  92. When a sound is played, it must reside in chip RAM.  Graphics displays
  93. must reside in chip RAM when they are being displayed, and some other
  94. things as well. Sounds, too, must reside in chip RAM when they're being
  95. played.  Amigas right now have 512K bytes of chip RAM, although 
  96. the forthcoming "fat Agnes" will raise that limit to one megabyte.
  97.  
  98. "Fast" RAM is basically any RAM that is not "chip."  Unlike chip RAM, the
  99. custom chips cannot access fast RAM.  Fast RAM is called "fast" because
  100. the 68000 microprocessor can access this memory without delays caused by
  101. the custom chips stealing memory cycles from the CPU.  (Don't worry at
  102. the idea of the custom chips slowing the 68000, as the blitter, for example,
  103. is much more efficient doing what it does that the 68000 would be in the
  104. same number of cycles.)  Note that not all fast RAM is fast.  Specifically,
  105. the second 512K of RAM that comes in the Amiga 2000 and the internal 512K
  106. RAM upgrade for the Amiga 500 are wired to ultimately support the "fat Agnes"
  107. chip.  As such, they still incur the performance hits when the blitter is
  108. in heavy use and/or lots of other DMA (hires display, etc) is occuring.
  109.  
  110. As mentioned before, if you have fast RAM (or any non-chip RAM, as above),
  111. Chatterbox loads and maintains its sounds in non-chip RAM, copying them
  112. to chip RAM only as needed, and freeing them when they're done playing.
  113. It's rather clever about it, like it won't free until it's completely
  114. done if it's playing multiple times.
  115.  
  116. Chatterbox tries to chew up as much memory as you ask it to.  This means
  117. it can cause low memory situations on your machine.  If you run into 
  118. problems, don't ask it to load as many sounds.  It would be a relatively
  119. trivial thing for Chatterbox to insure that and adequate amount of memory
  120. remained by refusing to load any more sounds when the available memory
  121. dropped below a certain limit.  It would be driven by a line in the command
  122. file.  But I'm burnt out on it and will be saving that for a new version.
  123.  
  124.  
  125. Sound File Format
  126. -----------------
  127.  
  128. Sounds files are expected to be in IFF 8SVX format.  Perfect Sound and
  129. Audiomaster files are known to be compatible.
  130.  
  131.  
  132. Using Chatterbox with a Hard Disk
  133. ---------------------------------
  134.  
  135. To install Chatterbox on a hard disk, simply create a directory containing
  136. all the sample files you want to use and a config.data file, and do an
  137. 'assign ChatterBox:' to that directory.  (For example, if the sounds were
  138. in fs1:data/sounds, use 'assign ChatterBox: fs1:data/sounds')  Then, put
  139. chatterbox in your C: or run it explicitly in your s:startup-sequence, or
  140. whatever, and, as long as no floppy is inserted called ChatterBox at the
  141. time (and perhaps later), you'll get your samples off hard disk.
  142.  
  143. An additional feature for hard disk users is the "noload" option for sounds
  144. that are to play when the timer event trips.  Noload is selected by having
  145. it be the first word after 'timer' on the timer command line.  If minimum
  146. and maximum time intervals are specified on the line, they come after
  147. the "noload" keyword.  If "noload" is selected, Chatterbox will defer
  148. loading in any of the sounds associated with the timer event until needed.
  149. (This is not useful for floppy-only operation unless you can dedicate a
  150. drive to sounds or don't mind randomly obeying requesters for them.)
  151.  
  152. If noload is selected, Chatterbox loads and plays the sound at the time
  153. it is to play it, rather than the usual loading of all the sounds at the
  154. beginning and random play from them.  When it is finished, it deallocates
  155. the sound.  When "noload" is selected and certain sounds in the list of
  156. sounds to play for the timer event are the same as sounds for other events,
  157. Chatterbox plays but does not load the sound from disk (as it is already 
  158. memory-resident), nor does it deallocate the sound when finished.
  159.  
  160. A total of 256 deferred timer sounds may be defined.
  161.  
  162.  
  163. Configuring The Timer Event
  164. ---------------------------
  165.  
  166. In addition to the "noload" option, the "timer" keyword can additionally
  167. have a low and high number of seconds.  The specifies the range of time
  168. chatterbox will want between speaking.  For example,
  169.  
  170. timer noload 300 600
  171.  
  172. ...would tell chatterbox not to load the sounds defined for timer events
  173. until they're played, and to wait from between five and ten minutes between
  174. playing them.
  175.  
  176. timer 3600 3600
  177.  
  178. ...would tell chatterbox to play a sound once an hour, and the abcense of
  179. the "noload" option tells it to load in all the sounds listed to be played
  180. on the occurence of timer events.
  181.  
  182.  
  183. Chatterbox's Sound Selection Algorithms
  184. ---------------------------------------
  185.  
  186. Chatterbox implements "random selection without replacement" in determining
  187. what sample to play next when more than one sample is defined to play for
  188. a given function.  What this means is that each sound will play at least
  189. one time before a given sound repeats, for a given "pass" through the list
  190. of sounds.  Note that sounds may still occasionally occur back-to-back.  
  191. For example, if there are four sounds for a certain event type and 
  192. chatterbox plays the third sound last, then after playing the last sound, 
  193. chatterbox rerandomizes the sounds (as it does) and, by chance, ends up 
  194. with the third sound first, the third sound will be heard to play twice in 
  195. a row.  Nonetheless, you will hear all the other sounds defined for that 
  196. event before you hear the third sound an additional time.  This may be
  197. changed later -- it's an easy fix.
  198.  
  199. Note that if 'noload' is selected, Chatterbox does not do random selection
  200. without repacement for timer events.  The idea is that you have a boatload
  201. of samples on disk and they're not playing that often, so you don't really 
  202. care so much about hearing repeats.
  203.  
  204.  
  205. Source Code
  206. -----------
  207.  
  208. The source code is included, at least it was when I shipped it out.
  209. The code was written to run under Manx Aztec C 3.6a.  You should be
  210. able to compile and go.
  211.  
  212. Note that the file windows.pw is a Power Windows 2.0 file.  Power Windows
  213. was used to generate the file windows.c, which is included in the
  214. distribution.
  215.  
  216.  
  217.  
  218. Only A Programmer Would Say "That's not a bug."
  219. -----------------------------------------------
  220.  
  221. If you exit Chatterbox by clicking in its "close window" gadget and the
  222. Chatterbox window was not active, Chatterbox will begin playing a sound
  223. then kill it right away as it exits.  This is because when you click the
  224. close gadget on an inactive window, Intuition sends a "window activated" 
  225. message (which can trigger Chatterbox to play a sound) then it sends a 
  226. "close window" message which tells Chatterbox to exit.  I suppose the
  227. fix would be to receive the window activate and delay a bit before starting
  228. the sound, allowing the receipt of a close to cancel the sound, but that
  229. would mean a delay in starting the sound on the activate.  Alternatively,
  230. it could wait until all sounds had finished playing on a "close window"
  231. before exiting. I'm just gonna leave it the way it is, at least for now.
  232.  
  233.  
  234. Anyway, have fun with it.
  235.  
  236.  
  237. Karl Lehenbauer @ The Hacker's Haven, 26-May-89
  238. (Usenet: uunet!sugar!karl, Internet/BITNET: karl@sugar.hackercorp.com)
  239. 3918 Panorama
  240. Missouri City, Texas  77459
  241. (713) 274-5184 (daytime)
  242.  
  243.  
  244.  
  245. Sample config.data file
  246. -----------------------
  247.  
  248. This sample file plays the sound "disk_inserted" when a disk inserted
  249. message is received by Chatterbox, "disk_removed" when one is removed,
  250. "window_activated" when the Chatterbox window is activated, 
  251. "window_deactivated" when it is deactivated, preferences_changed when
  252. preferences change, "low_bell" when a DisplayBeep call is made, and
  253. "bass_snap", "bell", "drip", "hammer", "rise", "whip", "synth_echo",
  254. "low_bell", or "low_smash" once every 20 to 120 seconds, loading the
  255. timer sounds from hard disk when they're needed.
  256.  
  257. diskin
  258.  disk_inserted
  259. diskout
  260.  disk_removed
  261. timer noload 20 120
  262.  bass_snap
  263.  bell
  264.  drip
  265.  hammer
  266.  rise
  267.  whip
  268.  synth_echo
  269.  low_bell
  270.  low_smash
  271. beep
  272.  low_bell
  273. activate
  274.  window_activated
  275. deactivate
  276.  window_deactivated
  277. preferences
  278.  preferences_changed
  279.