home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / sound / switchbp.sit / SwitchBeep.text < prev   
Encoding:
Text File  |  1990-01-08  |  3.2 KB  |  32 lines  |  [TEXT/ttxt]

  1. Here is SwitchBeep, the beep randomizer for the Sound cdev.
  2.  
  3. The Sound cdev uses snd resources in the System or Suitcase to replace the normal dull beep with a piece of digitized sound.  Many cool people have many cool sounds available in their Sound cdev.  Truly cool people have edited item 11 of the DITL in the Sound cdev to have dimensions like  22,158,253,313 so that they can see more than five sounds at a time.
  4.  
  5. Well, picking your own beep is nice, but since I have a large selection of beeps, I want a different one each day.  BeepShuffle, an INIT recently posted, changes the beep at EVERY beep which is a bit too often for me.  In addition, this provided no way to eliminate beeps which were inappropriate or too long.  It also involved another patch to SysBeep, which could crash.
  6.  
  7. SwitchBeep has none of these problems.  It simply reads the location where the current beep is stored (it's in the extended PRAM of the Plus and later machines) and changes it to a different snd id number.  It reads the disk for all the snd ids, but it patches nothing and allocates no memory.  It must run after Suitcase or Master Juggler, but the way it is named it will.
  8.  
  9. SwitchBeep will not work with SoundMaster or BeepINIT.  It only works if you are using snd resources and the Sound cdev.  If you want to randomize sounds in the others INITs, use my Randomizer INIT which is available in fine archives everywhere.  SwitchBeep will not run on a 512E, as Sound and Map won╒t, due to the lack of extended PRAM.
  10.  
  11. SwitchBeep is a Startup Document, also known as an INIT, so it has no interface whatsoever.  It just works.  It does have one adjustable feature, and that is a resource of type LONG that contains the maximum size of a beep SwitchBeep will use.  It is currently set to 100,000 bytes.  Any sounds longer than this will not be selected.  You can adjust this number with ResEdit. There is a template for it in SwitchBeep and  any ResEdit higher than 1.2 will automatically use it.  You should adjust it only if you have specific sounds you wish to exclude.  Keep in mind that you will exclude all sounds larger than that.  I plan on changing this to be a time related length instead of a size thing since a sound at 7.5 KHz can be longer and smaller than a sound at 22 KHz, but currently I don╒t even look at the speed of the sound.
  12.  
  13. This was all very difficult to do since the Sound cdev is completely undocumented.  I ended up disassembling it to find the proper calls to make and came up with these two crucial definitions:
  14.  
  15. FUNCTION GetBeep: Integer; INLINE $204F, $203C, $0002, $007C, $A051;
  16.  
  17. PROCEDURE SetBeep (theBeep: Integer); INLINE $204F, $203C, $0002, $007C, $A052;
  18.  
  19. These are essentially the heart of the INIT and can be used in any program to control the beep as modified by the Sound cdev.  Of course, these are reserved for Apple use and subject to change without notice, but I don╒t expect them to change real soon, if at all.
  20.  
  21. Feel free to send money, praise, comments, and complaints to me.
  22.  
  23. Jon Pugh
  24. PO Box 5509 L561
  25. Livermore, CA 94550
  26. (415) 423-4239
  27. pugh@ccc.nmfecc.gov
  28.  
  29. Modification History:
  30.  
  31. 1.0 First release
  32. 1.1 Changed check for sounds to not look up all snd resources.  Much faster with less IO.