home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!gumby!kzoo!k044477
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Subject: Re: Still trying to get this stupid sound stuff to work...
- Message-ID: <1992Aug27.161727.23885@hobbes.kzoo.edu>
- Organization: Kalamazoo College
- References: <1992Aug26.192610.14018@utkux1.utk.edu>
- Date: Thu, 27 Aug 1992 16:17:27 GMT
- Lines: 49
-
- danny@utkux1.utk.edu (Danny W. McCampbell) writes:
- >What is happening now is the sound sound starts playing,
- >the dialog comes up, but you cannot do anything until the sound
- >finishes.
- >
- > [Silly Modula-2-ish header stuff removed :-]
- >
- > begin
- > mySndChan := nil;
- > mySndHandle := GetResource('snd ', soundID);
- > if mySndHandle <> nil then
- > begin
- > err := SndPlay(mySndChan, mySndHandle, kAsync);
- > if err <> noErr then
- > ExitToShell;
- > end;
- > end;
-
- If the Sound Manager allocates your memory for you, which it is doing
- since you passed it a reference to a NULL SndChannelPtr, it won't let
- you play async. Them's the breaks. If you allocate the memory
- yourself, you can play async, but then you have to worry about
- deallocating it.
-
- Usually, you'll see someone write a callback routine that will set a
- flag to let you know that the sound's done; then your program will
- check the flag every so often, and SndDisposeChannel() and DisposPtr()
- on the memory when it sees it set. Personally, I don't do this
- because I can never remember whether SndPlay() will give me a callback.
- (I'm a masochist, I use SndDoCommand() and other nasty stuff instead of
- the happy, cheerful, easy-to-use-as-long-as-you're-synchronous high
- level calls.) And you really _should_ dispose of the channel shortly
- after the sound's done, or the system beep may not play, and other
- unfriendly stuff.
-
- But, ignoring the deallocation problem, you might write:
-
- begin
- mySndChan := NewPtrClear(sizeof(SndChannel)); { does Pascal have sizeof!? }
- mySndChan.qLength := stdQLength; { stdQLength = 128, BTW }
- ...
- err := SndPlay(mySndChan, mySndHandle, kAsync);
- ...
- end;
- --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- Memo to myself:
- Do The Dumb Things I Gotta Do.
- Touch The Puppet Head.
-