[comp.sys.mac.programmer] Changing Mac's Volume: How?

mithomas@bsu-cs.bsu.edu (Michael Thomas Niehaus) (09/01/89)

The subject says it all:  How do you go about changing the volume from within
an application.  I am doing this right now:

thePRAM = GetSysPPtr();
BitAnd( *(thePRAM->volClik),0x9F );
BitOr( *(thePRAM->volClik),(newVol*256));
WriteParam();

This changes the volume in the parameter RAM.  I know that for sure.  It
also changes the value of the low-memory SPVolCtl to what it should be.
But, the volume doesn't actually change.  The Control Panel shows the volume
as what I set it to, but if I try to make a sound, it will be at the same old
volume.  Unless I click on the Control Panel's volume control (without moving
the slider).  So I assume that the Control Panel is doing something that I
am not.  So what could that be?

Any suggestions would be appreciated.

-Michael

-- 
Michael Niehaus        UUCP: <backbones>!{iuvax,pur-ee}!bsu-cs!mithomas
Apple Student Rep      ARPA:  mithomas@bsu-cs.bsu.edu
Ball State University  AppleLink: ST0374 (from UUCP: st0374@applelink.apple.com)

d88-jwa@nada.kth.se (Jon W{tte) (09/02/89)

In article <10068@bsu-cs.bsu.edu> mithomas@bsu-cs.bsu.edu (Michael Thomas Niehaus) writes:
>The subject says it all:  How do you go about changing the volume from within
>an application.  I am doing this right now:

[ Sort of technical code deleted ]

>This changes the volume in the parameter RAM.  I know that for sure.  It
>also changes the value of the low-memory SPVolCtl to what it should be.
>But, the volume doesn't actually change.  The Control Panel shows the volume

How about SetSoundVol((int) Volume); ? I see no wrong in this easy-to-use,
well-documented Toolbox call. Sometimes you get too technical to see the
obvious :-) (Oh, by the way: You shouldn't change the volume in PRAM, since
this is a) considered a brach of the HIGL and you risk the wrath of the
HITP (Human Interface Thought Police) and b) subject to change without
notice (well, almost :-)) The user can do this through the Control Panel
if he wants to do it.

Unless you're writing a "General" cdev substitute, of course...

Happy Hacking !

(Oh, by the way, SetSoundVol is on page 233 of IM-II, and there's even no
TechNote about it, so I think it's still valid, all according to my XRef)
-- 
This is your fortune from h+@nada.kth.se:
Quoting one is plagiarism.  Quoting many is research.