Here is SwitchBeep, the beep randomizer for the Sound cdev.

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.

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.

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.

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.

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.

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:

FUNCTION GetBeep: Integer; INLINE $204F, $203C, $0002, $007C, $A051;

PROCEDURE SetBeep (theBeep: Integer); INLINE $204F, $203C, $0002, $007C, $A052;

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.

Feel free to send money, praise, comments, and complaints to me.

Jon Pugh
PO Box 5509 L561
Livermore, CA 94550
(415) 423-4239
pugh@ccc.nmfecc.gov

Modification History:

1.0 First release
1.1 Changed check for sounds to not look up all snd resources.  Much faster with less IO.