home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14626 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  2.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!malgudi.oar.net!uoft02.utoledo.edu!desire.wright.edu!jmatthews
  2. Newsgroups: comp.sys.mac.programmer
  3. Subject: Re: Still trying to get this stupid sound stuff to work...
  4. Message-ID: <1992Aug27.135443.3781@desire.wright.edu>
  5. From: jmatthews@desire.wright.edu
  6. Date: 27 Aug 92 13:54:43 EST
  7. References: <1992Aug26.192610.14018@utkux1.utk.edu>
  8. Organization: Wright State University 
  9. Lines: 63
  10.  
  11. In article <1992Aug26.192610.14018@utkux1.utk.edu>, danny@utkux1.utk.edu (Danny W. McCampbell) writes:
  12. > Will someone tell me what I can do to this code to cause the sound
  13. > to play transparently.  What I mean is after the sound starts playing
  14. > a modal dialog is brought up.  I want the user to be able to click
  15. > in the dialog and when he/she does the sound stops and the dialog
  16. > disappears.  What is happening now is the sound sound starts playing,
  17. > the dialog comes up, but you cannot do anything until the sound 
  18. > finishes.  Check it out:
  19.  
  20. When you call SndNewChannel, add a call back routine to let you know when
  21. the sound is done:
  22.  
  23.   procedure SndEnd (sndPtr: SndChannelPtr; theCmd: SndCommand);
  24.     var
  25.       a5: LongInt;
  26.   begin
  27.     a5 := SetA5(theCmd.param2);
  28.     sndDone := true; {a global variable}
  29.     a5 := SetA5(a5)
  30.   end;
  31.  
  32.   procedure PlaySound (sndID: Integer);
  33.     var
  34.       sndPtr: SndChannelPtr;
  35.       sndHdl: Handle;
  36.       sndErr: OSErr;
  37.       sndCmd: SndCommand;
  38.   begin
  39.     with sndCmd do {prepare a call back command}
  40.       begin
  41.         cmd := callBackCmd;
  42.         param1 := 0;
  43.         param2 := SetCurrentA5 {needed at interrupt time}
  44.       end;
  45.     sndPtr := SndChannelPtr(NewPtrClear(SizeOf(SndChannel)));
  46.     if sndPtr <> nil then
  47.       begin
  48.         sndPtr^.qLength := stdQLength; {just to be sure}
  49.         sndHdl := GetResource('snd ', sndID);
  50.         if sndHdl <> nil then
  51.           begin
  52.             if SndNewChannel(sndPtr, 0, initMono, @SndEnd) = noErr then
  53.               begin
  54.                 sndErr := SndPlay(sndPtr, sndHdl, true);
  55.         {add a call back cmd to this channel's queue}
  56.                 sndErr := SndDoCommand(sndPtr, sndCmd, false);
  57.         {continue execution while snd plays}
  58.                 DoOtherStuff; {while polling sndDone}
  59.                 sndErr := SndDisposeChannel(sndPtr, false)
  60.               end;
  61.             ReleaseResource(sndHdl)
  62.           end;
  63.         DisposPtr(Ptr(sndPtr))
  64.       end
  65.   end;
  66.  
  67. If the user clicks on the ShutUp button before sndDone turns true, send 
  68. a quietCmd (I think).
  69.  
  70. o----------------------------------------------------------------------------o
  71. | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
  72. | "I'm a commensal .sig virus, indistinguishable from an ordinary organelle."|
  73. o----------------------------------------------------------------------------o
  74.