[comp.binaries.mac] SwitchBeep 1.1

PUGH@ccc.nmfecc.gov (Jon Pugh) (03/22/90)

[SwitchBeep 1.1]

Here is SwitchBeep 1.1, the beep randomizer for the Sound cdev.  In
this version I have changed the way I read the sound resources so that
it doesn't do unnecessary reads from the disk, resulting in faster
operation.

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 a specific sound 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.

I would love to hear from people who are using this and do or don't like
it.  I'm just wondering how many people are interested in this sort of
thing.

Jon

   N         L                  pugh@ccc.nmfecc.gov
    M    A    L   National Magnetic Fusion Energy Computer Center
     F    T    N      Lawrence Livermore National Laboratory
      E         L                PO Box 5509 L-561
       C                    Livermore, California 94550
        C                         (415) 423-4239


---
(This file must be converted with BinHex 4.0)

:$P0hDA4MD%*PCA!ZFfPd!&0*9#&6593K!!!!!!ii!!!!!+pi8dP8)3!#!!!11(*
-BA8"!!!!!!!!!!)!#P0hDA4MD%*PCA!ZG'9iG"-J!(d6+J"p%cVr!!!$rrrrSi#
NIi!!4#R1!%&3h!"%NhS$HJ%0!#X!!3!!!%3Tk%P15946Gd*`!3DKT"@DSFjNqJ!
!"`%!!!!!!!!&R3!!!!!$3`!!!!!!!!!!SAN!!!3)#-#!K)!&$JCmek""%LG8LNJ
a%Q4)NBB*S%KjBT&)&5P&3$3*NmE0MSC*&%bjNiE1'$4#bT5"-dB!`BG*U+`8!UF
J`Cm!F1Um`p-Rd+0)!`S)4DU#TU-(!L6B!`++R$4f`Y!T!q))QcGL`V#C!k*2J`4
S%jKjiiB1%DeKG)!`dZ4*(6T3lTj-UjBYAMTbj%)"[$IYfVC"b+L4Db30RM*N#U1
&Sc8)Qc4Rh!Kq8j+1j!4`hV$*-a+2h#4Ybj`T)qFc`3F+BXjN8XE0'6TSL$"aFS6
J#K8V@lk8$3G%+K!aFZ$)!8)*fkTecU"T!#Fk'L"ZfTJT-fD-Lc0[l"!N)2!,T)!
"f$LaiNrI#`5J8VbiJ-602hherr'Vhci9UKmZh2F$$rrmii3Z!#J!`KHJU1#%&dl
8X9j!,b`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