[comp.sys.mac.programmer] ErrorSound

hairston@henry.ece.cmu.edu (David Hairston) (11/04/90)

I'e tried every permutation of "ProcPtr" and "pascal" to get my
sound procedure to work as the error sound in an application
compiled under Think C 4.0.  All i get when executing an Alert()
is the sound (yeah!) and an "odd address" error (boo!).

how do _you_ get this to work?  actual examples preferred over
conjecture, thanx ...

  -dave-  
hairston@henry.ece.cmu.edu

hairston@henry.ece.cmu.edu (David Hairston) (11/07/90)

[hairston@henry.ece.cmu.edu (David Hairston) writes:]
[] how do _you_ get this to work?  actual examples preferred over
[] conjecture, thanx ...

kudos to: "Phil Shapiro" <phils@chaos.cs.brandeis.edu>
who provided a (ahem) sound example which worked.  the example also
reinforced the notion, RTFM, which i did but apparently not closely
enough (i overlooked the short argument to MySoundProc, which isn't
used in the example).  this works (assuming your 'snd ' resource is
preloaded and locked and has id 128, etc.):

pascal void MySoundProc(short sndNum)
{
    Handle mySound;
    OSErr err;
 
    mySound = GetResource('snd ', 128);
    err = SndPlay(0L, mySound, FALSE);
}

setup as in:
----------------
main()
{
    ...
    Init();
    ErrorSound(MySoundProc);
    ...
    Alert(...);
    ...
}

  -dave-  
hairston@henry.ece.cmu.edu