home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14946 < prev    next >
Encoding:
Text File  |  1992-09-03  |  3.0 KB  |  76 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!gumby!destroyer!terminator!potts
  3. From: potts@itl.itd.umich.edu (Paul Potts)
  4. Subject: Re: Sound Loop in a with a Modal Dialog?
  5. Message-ID: <1992Sep3.171925.11716@terminator.cc.umich.edu>
  6. Sender: news@terminator.cc.umich.edu (Usenet Owner)
  7. Organization: Instructional Technology Laboratory, University of Michigan
  8. References: <1992Sep3.145524.8874@utkux1.utk.edu>
  9. Date: Thu, 3 Sep 1992 17:19:25 GMT
  10. Lines: 64
  11.  
  12. In article <1992Sep3.145524.8874@utkux1.utk.edu> danny@utkux1.utk.edu (Danny W. McCampbell) writes:
  13. >Hi.  I want to play a sound continuously while a modal dialog is 
  14. >present on the screen.  I have successfully go the loop to work
  15. >without the modal dialog statement but the loop is only executed
  16. >twice when I call modal dialog.  Here is  some sample code:
  17. >
  18. >dialogtrue := true;
  19. >while dialogtrue do
  20. >begin
  21. >  FlushSndChannel(mySndChan);
  22. >  if SoundisStopped(mySndChan) then
  23. >  begin
  24. >    PlaytheSound(mySndChan);
  25. >  end;
  26. >  ModalDialog(nil, itemHit);            {Call Modal Dialog until the user clicks in the dialog}
  27. >  if itemHit = 1 then
  28. >    dialogtrue := false;
  29. >end;
  30. >StoptheSound(mySndChan);
  31. >DisposDialog(AboutDialog);                {Dispose of the Dialog}
  32. >
  33. >The sound plays only twice then stops playing.  Any ideas how I can
  34. >do this successfully?  Thanks in advance.
  35.  
  36. This seems somewhat convoluted. Can you post the actual code that you use
  37. to play the sound, and what your dialog should do? It makes a difference.
  38.  
  39. Keep in mind also that your sound will restart after each click on a button
  40. in the dialog, but while the dialog is on the screen, the sound could 
  41. stop playing and you would then be left sitting there waiting for something
  42. to happen (for one of the buttons in the dialog to get activated)
  43. for it to start up again.
  44.  
  45. For a dialog in which any of the buttons numbered other than zero
  46. should dismiss the dialog, I would do something like:
  47.  
  48. - start playing sound
  49. - itemHit =0;
  50. - while (!itemHit)
  51.        ModalDialog (nil, &itemHit);
  52. - Turn off sound
  53.  
  54. The technique for playing the sound might influence how you do this; for
  55. example, are you playing a long sample that might end while the user is
  56. deciding what to do with the dialog? If so, you could set it to loop. Are
  57. you dynamically playing notes such that you need to stuff freqDurationCmds
  58. into the sound queue? If so, you might want to do this from a filter
  59. procedure to your dialog. It could look at the sound queue during null
  60. events and if it is nearly empty, stuff some more notes into it.
  61.  
  62. You might consider stuffing a copy of the pointer to the sound channel in
  63. the dialog, so that your filter procedure could look at it when it runs
  64. without having to access a global. There are various ways to do this kind
  65. of thing if you are interested.
  66.  
  67. >
  68. >Danny McCampbell
  69.  
  70.  
  71. -- 
  72. "...remove protective cap. Hold atomizer with thumb at base and nozzle 
  73. between first and second fingers. Without tilting head, insert nozzle into 
  74. nostril. Fully depress rim with a firm, even stroke and sniff deeply."
  75. -advice for presidential candidates from Paul Potts - potts@itl.itd.umich.edu
  76.