home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!gumby!destroyer!terminator!potts
- From: potts@itl.itd.umich.edu (Paul Potts)
- Subject: Re: Sound Loop in a with a Modal Dialog?
- Message-ID: <1992Sep3.171925.11716@terminator.cc.umich.edu>
- Sender: news@terminator.cc.umich.edu (Usenet Owner)
- Organization: Instructional Technology Laboratory, University of Michigan
- References: <1992Sep3.145524.8874@utkux1.utk.edu>
- Date: Thu, 3 Sep 1992 17:19:25 GMT
- Lines: 64
-
- In article <1992Sep3.145524.8874@utkux1.utk.edu> danny@utkux1.utk.edu (Danny W. McCampbell) writes:
- >Hi. I want to play a sound continuously while a modal dialog is
- >present on the screen. I have successfully go the loop to work
- >without the modal dialog statement but the loop is only executed
- >twice when I call modal dialog. Here is some sample code:
- >
- >dialogtrue := true;
- >while dialogtrue do
- >begin
- > FlushSndChannel(mySndChan);
- > if SoundisStopped(mySndChan) then
- > begin
- > PlaytheSound(mySndChan);
- > end;
- > ModalDialog(nil, itemHit); {Call Modal Dialog until the user clicks in the dialog}
- > if itemHit = 1 then
- > dialogtrue := false;
- >end;
- >StoptheSound(mySndChan);
- >DisposDialog(AboutDialog); {Dispose of the Dialog}
- >
- >The sound plays only twice then stops playing. Any ideas how I can
- >do this successfully? Thanks in advance.
-
- This seems somewhat convoluted. Can you post the actual code that you use
- to play the sound, and what your dialog should do? It makes a difference.
-
- Keep in mind also that your sound will restart after each click on a button
- in the dialog, but while the dialog is on the screen, the sound could
- stop playing and you would then be left sitting there waiting for something
- to happen (for one of the buttons in the dialog to get activated)
- for it to start up again.
-
- For a dialog in which any of the buttons numbered other than zero
- should dismiss the dialog, I would do something like:
-
- - start playing sound
- - itemHit =0;
- - while (!itemHit)
- ModalDialog (nil, &itemHit);
- - Turn off sound
-
- The technique for playing the sound might influence how you do this; for
- example, are you playing a long sample that might end while the user is
- deciding what to do with the dialog? If so, you could set it to loop. Are
- you dynamically playing notes such that you need to stuff freqDurationCmds
- into the sound queue? If so, you might want to do this from a filter
- procedure to your dialog. It could look at the sound queue during null
- events and if it is nearly empty, stuff some more notes into it.
-
- You might consider stuffing a copy of the pointer to the sound channel in
- the dialog, so that your filter procedure could look at it when it runs
- without having to access a global. There are various ways to do this kind
- of thing if you are interested.
-
- >
- >Danny McCampbell
-
-
- --
- "...remove protective cap. Hold atomizer with thumb at base and nozzle
- between first and second fingers. Without tilting head, insert nozzle into
- nostril. Fully depress rim with a firm, even stroke and sniff deeply."
- -advice for presidential candidates from Paul Potts - potts@itl.itd.umich.edu
-