[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using the Sound Manager in MacIvory
>Date: Thu, 1 Mar 90 11:07 PST
>From: Larry Baum <firstname.lastname@example.org>
>Subject: Using the Sound Manager in MacIvory
>According to the MacIvory Programmer's Reference, I should be able to
>access the following two functions:
>_SndPlay (channel sndhdl async)
>_SndNewChannel (chan synth init userroutine) -> newchan
>But if I do:
>(_SndPlay nil (_getresource "snd " 4) t)
>(_SndNewChannel nil 0 0 nil)
>in either case I get into the debugger with the error:
> mac-os-error-badchannel: Invalid channel queue length
Here is some code we use to play mac "snd " resources from a MacIvory:
;;; -*- Mode: LISP; Syntax: Common-lisp; Package: USER; Base: 10 -*-
;; general facilities for interacting with Mac sounds
;; Play a mac snd resource by name. Name is a string.
(defun play-mac-sound (name)
(let ((resource (condition-case ()
(mtb::_getnamedresource "snd " name)
(cerror "Continue into Debugger"
"Sound resource ~A not found"
(mtb:_sndplay 0 resource t)))
;; Return a list of all snd resources in the system file.
(defun all-mac-sounds ()
(mtb::do-rsrcs (ignore ignore name) ("snd " :all)
(push (format nil "~A" name) names))
(sort names #'string-lessp)))
(defun sound-menu ()
(let ((sound (tv:menu-choose (all-mac-sounds) "Play sound:")))
The only difference in the call to _sndplay from what you tried is that the
channel argument is 0, not nil. Perhaps the value NIL in "Inside MacIntosh" is
a predefined constant in MPW Pascal. I had to play with this quite a bit to
make it work too. It seems so simple now.
Dept. of Cognitive Science
U.C. San Diego