Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mcnc!uvaarpa!murdoch!news From: pts@mendel.acc.Virginia.EDU (Paul T. Shannon) Newsgroups: comp.sys.next Subject: trouble understanding delegates and the Soundkit Message-ID: <1990Jul27.021809.7097@murdoch.acc.Virginia.EDU> Date: 27 Jul 90 02:18:09 GMT Sender: news@murdoch.acc.Virginia.EDU Organization: University of Virginia Lines: 42 I'm dipping a first, cautious toe into the waters of objective c. My project is simply to play a pre-recorded sound using the soundkit. The short program below works, but the program sometimes terminates before the sound is complete, and therefore the sound gets clipped. Various inelegant approaches skirt around the problem: 1. a busy loop after the play message, wasting time until the sound is done 2. using the c function SNDWait (0) works (though I'm not sure why: is the '0' tag the same as that used, at a low level, by the first sound to be sent the play message?). So, in trying to do it the right way, I've experimented with creating a delegate for the sound, which will receive the 'didplay' message. If this is the right approach, can anyone suggest what to do next? How do I establish a method for the soundDelegate so that I can subsequently ask it to wait until it receives the 'didplay' message? And if this is the wrong approach, will someone please point me in the right direction? - Paul Shannon pts@virginia.edu /*----------------------------------------------------------------------------*/ main (int argc, char **argv) { id aSound = [Sound new]; id soundDelegate = [Object new]; int success; [aSound setDelegate: soundDelegate]; success = [aSound readSoundfile: "/NextLibrary/Sounds/Basso.snd"]; printf ("success of readSoundfile: s\n", SNDSoundError (success)); success = [aSound play]; return 0; } /*----------------------------------------------------------------------------*/