home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!malgudi.oar.net!uoft02.utoledo.edu!desire.wright.edu!jmatthews
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Still trying to get this stupid sound stuff to work...
- Message-ID: <1992Aug27.135443.3781@desire.wright.edu>
- From: jmatthews@desire.wright.edu
- Date: 27 Aug 92 13:54:43 EST
- References: <1992Aug26.192610.14018@utkux1.utk.edu>
- Organization: Wright State University
- Lines: 63
-
- In article <1992Aug26.192610.14018@utkux1.utk.edu>, danny@utkux1.utk.edu (Danny W. McCampbell) writes:
- > Will someone tell me what I can do to this code to cause the sound
- > to play transparently. What I mean is after the sound starts playing
- > a modal dialog is brought up. I want the user to be able to click
- > in the dialog and when he/she does the sound stops and the dialog
- > disappears. What is happening now is the sound sound starts playing,
- > the dialog comes up, but you cannot do anything until the sound
- > finishes. Check it out:
-
- When you call SndNewChannel, add a call back routine to let you know when
- the sound is done:
-
- procedure SndEnd (sndPtr: SndChannelPtr; theCmd: SndCommand);
- var
- a5: LongInt;
- begin
- a5 := SetA5(theCmd.param2);
- sndDone := true; {a global variable}
- a5 := SetA5(a5)
- end;
-
- procedure PlaySound (sndID: Integer);
- var
- sndPtr: SndChannelPtr;
- sndHdl: Handle;
- sndErr: OSErr;
- sndCmd: SndCommand;
- begin
- with sndCmd do {prepare a call back command}
- begin
- cmd := callBackCmd;
- param1 := 0;
- param2 := SetCurrentA5 {needed at interrupt time}
- end;
- sndPtr := SndChannelPtr(NewPtrClear(SizeOf(SndChannel)));
- if sndPtr <> nil then
- begin
- sndPtr^.qLength := stdQLength; {just to be sure}
- sndHdl := GetResource('snd ', sndID);
- if sndHdl <> nil then
- begin
- if SndNewChannel(sndPtr, 0, initMono, @SndEnd) = noErr then
- begin
- sndErr := SndPlay(sndPtr, sndHdl, true);
- {add a call back cmd to this channel's queue}
- sndErr := SndDoCommand(sndPtr, sndCmd, false);
- {continue execution while snd plays}
- DoOtherStuff; {while polling sndDone}
- sndErr := SndDisposeChannel(sndPtr, false)
- end;
- ReleaseResource(sndHdl)
- end;
- DisposPtr(Ptr(sndPtr))
- end
- end;
-
- If the user clicks on the ShutUp button before sndDone turns true, send
- a quietCmd (I think).
-
- o----------------------------------------------------------------------------o
- | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
- | "I'm a commensal .sig virus, indistinguishable from an ordinary organelle."|
- o----------------------------------------------------------------------------o
-