[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@atc.boeing.com (Larry Baum)
    
    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
    
    According to Inside Macintosh Vol. 5, the corresponding toolbox
    routines, SndPlay and SndNewChannel, should work if you pass NIL as the
    first argument; i.e. the toolbox will generate a channel for you if you
    don't have one in hand to pass as the first argument.  Without this
    capability I don't see how to gat a channel to begin with.
    
    But if I do:
    
    (_SndPlay nil (_getresource "snd " 4) t)
    
    or
    
    (_SndNewChannel nil 0 0 nil)
    
    in either case I get into the debugger with the error:
    
    mac-os-error-badchannel: Invalid channel queue length
    
The (understandable) mistake you are making is assuming that NIL in
Pascal is the same thing as nil in Lisp.  They're not the same thing,
they're just spelled similarly.  NIL and FALSE in Pascal are represented
as 0 in Lisp, and TRUE is represented as 1.

(_SndPlay 0 (_GetResource "snd " 4) 1) works for me.

I wish we had a "higher level" interface to the Macintosh toolbox, where
a Macintosh sound-channel was represented as a Lisp object, instead of
the same number that would appear in a C program, and where there was
the usual type-checking that we've all come to expect in Lisp.  But
presently we don't.  Also, it's a bug that _SndPlay didn't report an
error that you had used NIL where a 32-bit integer was expected.  The
toolbox interface doesn't have nearly enough checking for invalid
arguments.  The interface to the Macintosh toolbox available from Lisp
is at exactly the same low level as the interface available from C and
Pascal.