1. Win32Lib: PlaySound parameters
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Nov 02, 1999
- 534 views
David, Can you give me some more information about PlaySound & its parameters? I'm using it to give voice to some math flash cards & my problem is that in SYNCHRONOUS mode (1,0) some related list boxes which are variously supposed to be made invisible & visible BEFORE the sounds begin to play, instead disappear & don't reappear until it is FINISHED playing (which looks bad), while in ASYNCHRONOUS mode (0,1) it only plays the LAST wave file requested (although it treats the list boxes ok). I like how ASYNC lets various user actions interrupt PlaySound, but I can't use it if I can't get it to play a sequence of waves one after another rather than just the last requested as it's doing. There appears to be a flag which can be set in the PlaySound function called "SND_NOSTOP" which if set returns false if PlaySound is busy already playing something, which would seem to let me put each successive wave to be played into a test loop to see if the previous one is finished or not; but I don't know how to set that flag in PlaySound. (I'm not sure that approach would still preserve the "interruptibility" I like about ASYNC mode, but I can't try it if I can't set the flag; I tried something similar with ASYNC by putting time delays between successive sounds, but while that worked to make a succession of wave files play, it made the list box controls disappear just like SYNC mode. If there were some way to send PlaySound async a "play list", that would seem to be optimal, but I suspect that's not an option.) Dan Moyer
2. Re: Win32Lib: PlaySound parameters
- Posted by David Cuny <dcuny at LANSET.COM> Nov 02, 1999
- 502 views
Dan Moyer wondered: > Can you give me some more information about PlaySound & its parameters? I've been following the discussion, but I really don't have *any* expertise here. Sorry. -- David Cuny
3. Re: Win32Lib: PlaySound parameters
- Posted by "Brian K. Broker" <bkb at CNW.COM> Nov 02, 1999
- 520 views
----- Original Message ----- From: Dan Moyer <DanMoyer at PRODIGY.NET> Sent: Monday, November 01, 1999 10:31 PM > Can you give me some more information about PlaySound & its parameters? The best place for info on the subject is MSDN (MS Developers' Network). Win32Lib defines 'PlaySound' as a procedure as opposed to a function (why is that? and what is the difference between 'PlaySound' and 'PlaySoundA' from Win32API.ew?) Anyways, check for more info on this function. Use Win32Lib's 'or_all' function for passing 'fdwSound'. i.e.) tmp = allocate_string(root_dir & MEDIA_DIR & wav_file) c_proc(xPlaySound, {tmp, NULL, or_all(SND_FILENAME, SND_ASYNC, SND_NOSTOP)}) Constant values can be found in Win32API.ew. You have an interesting idea that I will experiment with tomorrow. Let me know if you find a solution... -- Brian
4. Re: Win32Lib: PlaySound parameters
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Nov 02, 1999
- 561 views
Brian, Thanks! The "or_all" (& the api constants in win32api.ew) were what I needed to know to be able to set the flag for snd_nostop, & it appears at least to be accepted; but NOW I understand why you observed that PlaySound is a PROCEDURE in Win32Lib--I can't get a boolean return (to use in a loop between wave files to see if preceeding wave file is still playing), from a PROCEDURE! I had already found approximetly the MS site with info about PlaySound that you mentioned (that's where I found the SND_NOSTOP flag info), but it never occured to me that the FUNCTION they were mentioning WASN'T a function when it was wrapped in Win32Lib, not even when you first mentioned it; then I went to code the loop & discovered I didn't have any return to test against! (re PlaySound & PlaySoundA: there is also a PlaySoundW in the winmm.dll, & I make a guess that the A & W are internal modules to the main PlaySound in the dll ?) p.s.: I didn't use the "SND_FILENAME" you put in your "or_all" example, because I didn't understand what it was there for; what is it there for? David, I understand almost nothing about the API wrapping, so is there anything that can be done here to make use of the PlaySound FUNCTION?? Dan Moyer On Tue, 2 Nov 1999 02:26:36 -0800, Brian K. Broker <bkb at CNW.COM> wrote: >----- Original Message ----- >From: Dan Moyer <DanMoyer at PRODIGY.NET> >Sent: Monday, November 01, 1999 10:31 PM > > >> Can you give me some more information about PlaySound & its parameters? > >The best place for info on the subject is MSDN (MS Developers' Network). >Win32Lib defines 'PlaySound' as a procedure as opposed to a function (why is >that? and what is the difference between 'PlaySound' and 'PlaySoundA' from >Win32API.ew?) Anyways, check >for more info on this function. Use Win32Lib's 'or_all' function for >passing 'fdwSound'. > >i.e.) tmp = allocate_string(root_dir & MEDIA_DIR & wav_file) > c_proc(xPlaySound, {tmp, > NULL, > or_all(SND_FILENAME, SND_ASYNC, SND_NOSTOP)}) > >Constant values can be found in Win32API.ew. > >You have an interesting idea that I will experiment with tomorrow. Let me >know if you find a solution... > >-- Brian
5. Re: Win32Lib: PlaySound parameters
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Nov 02, 1999
- 537 views
Brian, Never mind my silly question about SND_FILENAME, it was CLEARLY described in the sixth sentence at the site you mentioned. I'd seen it before, but it just didn't register. <sigh> Dan
6. Re: Win32Lib: PlaySound parameters
- Posted by David Cuny <dcuny at LANSET.COM> Nov 02, 1999
- 513 views
Dan Moyer wrote: > I understand almost nothing about the API wrapping, so > is there anything that can be done here to make use of > the PlaySound FUNCTION?? I didn't have any documentation for the PlaySound function, so I just filched the code from a demo of Robert's. Robert declared the routine as a procedure, and so that's what I did as well. The 'A' and 'W' at the end of the function name designate if the routine takes as ANSI string (1 byte per character) or a Unicode (W=wide=2 bytes per character). If there is no 'A' or 'W', the 'A' is probably assumed. In C, all routines return a value - even if it's just NULL. If you don't use the value returned by the routine; i.e.: foo( bar ) then the C compiler just discards the result. So the distinction that Euphoria makes between a C procedure and function is a bit artificial. To convert the PlaySound call into a function, use define_c_func() instead of define_c_proc(), (for Win32Lib, use linkFunc and linkProc) and specify the type of value the routine returns (C_INT, C_LONG, C_POINTER, etc.). The prototype would look something like this: xPlaySound = linkFunc( winmm, "PlaySoundA", {C_INT, C_INT, C_INT}, C_INT ) Hope this helps! -- David Cuny
7. Re: Win32Lib: PlaySound parameters
- Posted by Bernie Ryan <bwryan at PCOM.NET> Nov 02, 1999
- 522 views
If you read the documentation in my WIN32API.LIB. The W and A meaning is explained "A" uses ASCII or ANSI strings "W" uses WIDE or UNICODE strings You probably want to use "A" . I would suggest that that you read my documentation for further information. Also playsnd is a function that returns bool which is C_SHORT. Bernie
8. Re: Win32Lib: PlaySound parameters
- Posted by Brian Broker <bkb at CNW.COM> Nov 02, 1999
- 509 views
- Last edited Nov 03, 1999
Dan, Have you come up with a solution? I've come up with one... It's not the most elegant but it works. Let me know and I'll clean up the code a bit for you. -- Brian
9. Re: Win32Lib: PlaySound parameters
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Nov 02, 1999
- 491 views
- Last edited Nov 03, 1999
Brian, Well, not a solution, but a re-definition of the problem. As far as I can see right now, my main problem is not actually with playsound, but with setVisible (true). (I went from playSound sync to playSound async to solve problem of setVisible not happening "soon" enough when playSound, but turns out that's a problem with setVisible, not playSound, I think.) If we can get setVisible fixed, I would still want to see what you did, tho, because playSound async would still only play last in sequence!! I made a demo of the setVisible problem & put it in another post. Dan On Tue, 2 Nov 1999 21:16:32 -0500, Brian Broker <bkb at CNW.COM> wrote: >Dan, > >Have you come up with a solution? I've come up with one... It's not the >most elegant but it works. Let me know and I'll clean up the code a bit >for you. > >-- Brian
10. Re: Win32Lib: PlaySound parameters
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Nov 02, 1999
- 509 views
- Last edited Nov 03, 1999
David, Yeah, that will probably at least let me experiment with the SND_NOSTOP flag in a test-if-finished loop for individual instances of playSound async. Thanks. Dan Moyer On Tue, 2 Nov 1999 08:43:12 -0800, David Cuny <dcuny at LANSET.COM> wrote: >Dan Moyer wrote: > >> I understand almost nothing about the API wrapping, so >> is there anything that can be done here to make use of >> the PlaySound FUNCTION?? > >I didn't have any documentation for the PlaySound function, so I just >filched the code from a demo of Robert's. Robert declared the routine as a >procedure, and so that's what I did as well. > >The 'A' and 'W' at the end of the function name designate if the routine >takes as ANSI string (1 byte per character) or a Unicode (W=wide=2 bytes per >character). If there is no 'A' or 'W', the 'A' is probably assumed. > >In C, all routines return a value - even if it's just NULL. If you don't use >the value returned by the routine; i.e.: > > foo( bar ) > >then the C compiler just discards the result. So the distinction that >Euphoria makes between a C procedure and function is a bit artificial. > >To convert the PlaySound call into a function, use define_c_func() instead >of define_c_proc(), (for Win32Lib, use linkFunc and linkProc) and specify >the type of value the routine returns (C_INT, C_LONG, C_POINTER, etc.). The >prototype would look something like this: > > xPlaySound = linkFunc( winmm, "PlaySoundA", {C_INT, C_INT, C_INT}, >C_INT ) > >Hope this helps! > >-- David Cuny