[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting the mac's sound

	what I want to do is simply set and read the volume of the mac's speaker.
	I've tried (_setVol :check-error :do 7); however, it seems to have no effect
	Any help on this and the (_getVol -) counterpart would be appreciated.

The following ought to manage your sound volume as desired.  Macintosh
sound stuff seems to be in a state of partial implementation, subject to
change with MacOS 7?

(defvar SdVolume (%int-to-ptr #x260))
(defconstant SdRefNum -4)

(defun sound-volume ()
  (logand #x7 (%get-byte SdVolume))) 

(defun set-sound-volume (level)
  (let ((old-vol (sound-volume)))
    (%stack-block ((pb 30))
      (%put-ptr pb (%null-ptr) 12) ; nil in pre 2.0 MACL
      (%put-word pb sdrefnum 24)
      (%put-word pb 2 26)
      (%put-word pb (logand #x7 level) 28)
      (_control :check-error :a0 pb :d0)))

(defmacro with-sound-volume ((volume) &body forms)
  (let ((tmp (gensym)))
    `(let (,tmp)
           (setq ,tmp (set-sound-volume ,volume))
         (when ,tmp
           (set-sound-volume ,tmp))))))

Cris Johnson 
Price Waterhouse Technology Centre 
68 Willow Road, Menlo Park, CA 94025 
(415) 322-0606