1. ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 29, 1999
- 593 views
Ok, now I've got myself in a bind: I didn't give enough information about the playSound/setVisible problem I'm having. Greg's suggestion that I use asynchronous parameters to make a wave file play without hindering the display of an invisible control worked just fine in my DEMO of the problem, but NOT in my program, because my demo was an inadequate abstract of my program problem. (sigh!) My program actually plays a SUCCESSION of wave files (by a succession of playsounds), to implement "reading" a math flash card (eg,"one" "plus" "one" "equals" "two"), and when I make the PlaySound asynchronous, it only plays the LAST wave file in the sequence. NG. So if I make PlaySound ASYNCHRONOUS, it allows user actions to interupt a sound, and lets invisible controls be set visible before the sound occurs (when that's what the program flow is), BUT, it won't play a complete SEQUENCE of wave files one after another, just the last one; but if I make PlaySound SYNCHRONOUS, it WILL play each specified wave file in sequence, but it WON'T set invisible controls visible before the sound, even when the program says to. I have this bad feeling that both playing a succession of wave files & setVisible a control before the sound can't be done together? Any thoughts?? Dan Moyer On Thu, 28 Oct 1999 09:23:20 -0400, Greg Harris <blackdog at CDC.NET> wrote: >Hi Dan, >Your example was set to synchronous playback. You want async playback >using the SND_ASYNC flag. ><snip> >Try: >>procedure playsound(sequence wave) > atom file > file = allocate_string(wave) > c_proc(xPlaySound, {file, 0, 1}) > free(file)>end procedure>>(Coded on the fly.. should work :)>>Regards,> >Greg Harris>
2. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Greg Harris <blackdog at CDC.NET> Oct 29, 1999
- 536 views
Hi Dan, Sounds like you are the victim of one sound at a time syndrome. It's a hardware feature on most sound cards. My SB Live! can mix sounds realtime but most SB compatibles cannot. You probably will have to use sync sounds and use a work around or figure some way to tell if the first sound is finished before you start the next one. Sorry I can't be of any more help. Maybe use DirectX's DirectSound? Regards, Greg Harris ----- Original Message ----- From: Dan Moyer <DanMoyer at PRODIGY.NET> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Friday, October 29, 1999 6:25 AM Subject: ina bind: MULTIPLE playSound(async) vs setVisible > Ok, now I've got myself in a bind: I didn't give enough information about > the playSound/setVisible problem I'm having. > > Greg's suggestion that I use asynchronous parameters to make a wave file > play without hindering the display of an invisible control worked just fine > in my DEMO of the problem, but NOT in my program, because my demo was an > inadequate abstract of my program problem. (sigh!) My program actually > plays a SUCCESSION of wave files (by a succession of playsounds), to > implement "reading" a math flash card (eg,"one" "plus" "one" "equals" > "two"), and when I make the PlaySound asynchronous, it only plays the LAST > wave file in the sequence. NG. > > So if I make PlaySound ASYNCHRONOUS, it allows user actions to interupt a > sound, and lets invisible controls be set visible before the sound occurs > (when that's what the program flow is), BUT, it won't play a complete > SEQUENCE of wave files one after another, just the last one; > > but if I make PlaySound SYNCHRONOUS, it WILL play each specified wave file > in sequence, but it WON'T set invisible controls visible before the sound, > even when the program says to. > > I have this bad feeling that both playing a succession of wave files & > setVisible a control before the sound can't be done together? > > Any thoughts?? > > Dan Moyer
3. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Brian Broker <bkb at CNW.COM> Oct 29, 1999
- 536 views
On Fri, 29 Oct 1999 06:25:31 -0400, Dan Moyer <DanMoyer at PRODIGY.NET> wrote: >but if I make PlaySound SYNCHRONOUS, it WILL play each specified wave file >in sequence, but it WON'T set invisible controls visible before the sound, >even when the program says to. > >I have this bad feeling that both playing a succession of wave files & >setVisible a control before the sound can't be done together? > >Any thoughts?? > >Dan Moyer Hmmm... this is a strange one. I've been experimenting with this issue and I've come up with nothing. I used your previous example to experiment and if you click the "CLICK HERE" button multiple times (before the first playback finishes) it will play the sound multiple times before the control becomes visible. (At first I thought that it might show up after playing the first sound...) Bernie, do you have any ideas? You seem to know quite a bit about the Windows API. All that win32lib is doing for 'setVisible' is calling the Windows function 'ShowWindow'. Why would 'PlaySound' prevent a ShowWindow, even when called after ShowWindow (and even when triggered multiple times...) I'm stumped, Brian
4. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Brian Broker <bkb at CNW.COM> Oct 29, 1999
- 521 views
Further experimentation: I added the playsound to the Restart_onClick function: procedure Restart_onClick () setVisible(LText2,False) playsound("test.wav") end procedure and here there is no problem... The control becomes invisible before the sound is played. But I still don't see why it doesn't work the same when making the control visible...
5. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 29, 1999
- 533 views
- Last edited Oct 30, 1999
Brian, I'm not totally sure about this, but when I was testing this problem to see what I could understand about it, I THINK I found that the "setVisible false" is NOT what makes the control disappear in this situation, re your test. What I remember doing is this: in my application, I am actually making a combination of labels & list boxes selectivly show or not show, & that's what is not being set visible when they should when a sound is played AFTER they're told to be visible; so, as a test, I rigged the program so that the code which should make one set of controls INVISIBLE and a new set VISIBLE when a button is clicked, had the portion that would make the current set invisible commented out , and when I tested it, THE CURRENT CONTROL DISAPPEARED ANYWAY on button click; then when the "new" control became visible after the sound played, the old control THEN showed up superimposed over it (since it wasn't set invisible). But even though it hadn't been set invisible, it DID disappear on the initial button click. So my guess is that something about the initial action of the setVisible command erases the control specified BEFORE it checks for whether or not the parameter is true or false, and THEN the sound routine takes over, leaving the control not there until the sound is finished playing, and THEN the setVisible parameter is checked & the control is either made visible or made invisible. Does that seem at all likely to be happening? It would explain your result, if that is what is going on, though I'm not sure what it might say about a fix. I'll have to check my myrid sequence of test versions to see if what I described doing & seeing is accurate, but I think it is. On Fri, 29 Oct 1999 18:41:29 -0400, Brian Broker <bkb at CNW.COM> wrote: >Further experimentation: I added the playsound to the Restart_onClick >function: > >procedure Restart_onClick () > setVisible(LText2,False) > playsound("test.wav") >end procedure > >and here there is no problem... The control becomes invisible before the >sound is played. But I still don't see why it doesn't work the same when >making the control visible...
6. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 29, 1999
- 552 views
- Last edited Oct 30, 1999
All, I've thought up a possible work around to my problem of playing multiple wave files interfering with the orderly setVisible of relevant controls, but I don't know how to implement it. Since the asynchronous playSound WILL play ONE wave AND allow previous setVisible commands to occur properly first, what I thought to do is: "on the fly" (as the program executes, not before hand), read the sound data in each desired wave file in sequence, putting the data into ONE BIG data structure which temporarily combines all the desired spoken words, & then send that single data structure to playSound? (I don't THINK that would take too long to do for each flash card, but I'm not really sure.) If that sounds reasonable, the problem becomes that I don't know how to do it, in terms of the format of wave files, how to combine them into one correct data structure, & whether & how to send that to playSound, since it isn't a file. Any thoughts/suggestions ??
7. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Bernie Ryan <bwryan at PCOM.NET> Oct 29, 1999
- 560 views
- Last edited Oct 30, 1999
This code works Bernie ------------------------------< cut >------------------------------------ -- demo of problem with .wav sound happening before setVisible, -- even though setVisible is commanded before playsound. include Win32Lib.ew without warning --- BELOW ARE MY ADDED CONSTANTS bernie constant True = -1, False = 0, ALWAYS_NULL = 0 global constant TheWindow = create( Window, "Sound/setVisible Problem", 0, 100, 100, 684, 388,0), LText2 = create( LText, "LText2", TheWindow, 132, 96, 444, 76, 0 ), Restart = create( PushButton, "RESTART", TheWindow, 248, 264, 132, 36, 0 ), DoTest = create( PushButton, "CLICK HERE", TheWindow, 248, 192, 132, 40, 0), LText5 = create( LText, "LText5", TheWindow, 136, 8, 408, 80, 0 ) --------------------------------------- -- TO PLAY A .WAV FILE: procedure playsound(sequence wave) atom file file = allocate_string(wave) c_proc(xPlaySound, {file, ALWAYS_NULL, SND_ASYNC}) free(file) end procedure ------------------------------------ procedure TheWindow_onOpen () -- TEST INSTRUCTIONS: setText(LText5,"THIS WORKS ON A AWE32 SOUNDCARD") --TEXT TO SHOW WHEN BUTTON CLICKED ; MAKE IT INVISIBLE FOR NOW: setFont(LText2,"Arial", 15,Bold) setText(LText2,"This text should have shown BEFORE anything was spoken!") setVisible(LText2,False) end procedure onOpen[TheWindow] = routine_id("TheWindow_onOpen") ----------------------------------- --DO THE TEST: procedure DoTest_onClick () setVisible(LText2,True)-- TEXT should become VISIBLE; playsound("test.wav") -- THEN sound should happen. end procedure onClick[DoTest] = routine_id("DoTest_onClick") ------------------------------------ -- RESET TO DO TEST AGAIN: procedure Restart_onClick () setVisible(LText2,False) end procedure onClick[Restart] = routine_id("Restart_onClick") ---------------------------------------------------------------------- WinMain( TheWindow ) -----------------------< cut >------------------------------------------
8. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 30, 1999
- 555 views
Bernie, Yes, it does, (with minor mods: delete reassign of constants True & False), but only for playing ONE wave file, & I need to play a succession of them. If I use async & then try to play a succession of waves, to vocally read a math flash card ("one.wav" "plus.wav" "one.wav" "equals.wav" "two.wav"), it only plays the LAST wave file (presumably because it is intended to be interuptable & do only whatever is the last thing requested). My best thought so far is to combine the various desired multiple wave files into a temporary data structure as needed while program is running (like: tempwav = "one.wav" & "plus.wav" & "one.wav" & "equals.wav" & "two.wav), and send that to playSound, BUT, I don't know how to combine the waves in correct way, nor how to send them to async playsound as data rather than file. Dan On Fri, 29 Oct 1999 22:08:18 -0400, Bernie Ryan <bwryan at PCOM.NET> wrote: >This code works > >Bernie > >------------------------------< cut >------------------------------------ > >-- demo of problem with .wav sound happening before setVisible, >-- even though setVisible is commanded before playsound. > >include Win32Lib.ew >without warning > > >--- BELOW ARE MY ADDED CONSTANTS bernie >constant True = -1, False = 0, ALWAYS_NULL = 0 > >global constant >TheWindow = create( Window, "Sound/setVisible Problem", 0, 100, 100, 684, >388,0), >LText2 = create( LText, "LText2", TheWindow, 132, 96, 444, 76, 0 ), >Restart = create( PushButton, "RESTART", TheWindow, 248, 264, 132, 36, 0 ), >DoTest = create( PushButton, "CLICK HERE", TheWindow, 248, 192, 132, 40, 0), >LText5 = create( LText, "LText5", TheWindow, 136, 8, 408, 80, 0 ) >--------------------------------------- >-- TO PLAY A .WAV FILE: >procedure playsound(sequence wave) >atom file > file = allocate_string(wave) > c_proc(xPlaySound, {file, ALWAYS_NULL, SND_ASYNC}) > free(file) >end procedure >------------------------------------ >procedure TheWindow_onOpen () > >-- TEST INSTRUCTIONS: > setText(LText5,"THIS WORKS ON A AWE32 SOUNDCARD") > >--TEXT TO SHOW WHEN BUTTON CLICKED ; MAKE IT INVISIBLE FOR NOW: > setFont(LText2,"Arial", 15,Bold) > setText(LText2,"This text should have shown BEFORE anything was spoken!") > setVisible(LText2,False) >end procedure > >onOpen[TheWindow] = routine_id("TheWindow_onOpen") >----------------------------------- >--DO THE TEST: >procedure DoTest_onClick () > setVisible(LText2,True)-- TEXT should become VISIBLE; > playsound("test.wav") -- THEN sound should happen. >end procedure > >onClick[DoTest] = routine_id("DoTest_onClick") >------------------------------------ >-- RESET TO DO TEST AGAIN: >procedure Restart_onClick () > setVisible(LText2,False) >end procedure > >onClick[Restart] = routine_id("Restart_onClick") >---------------------------------------------------------------------- >WinMain( TheWindow ) > >-----------------------< cut >------------------------------------------
9. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 30, 1999
- 546 views
Brian, I think my comments about your test were irrelevant, on two counts. First, the "asynchronous" mode for playSound fixes the problem, at least when playing ONE wave file (it remains for me to find out how to make it work with MULTIPLE wave files); second, although my code did perform as I remembered, (blanking out a control sort of independent of its being set invisible), it was simply because I had a NUMBER of similar controls placed at the same location (on purpose), and while I wasn't setting the control under question invisible, I WAS setting all the OTHERS invisible, & I think that was responsible for the blanking I was seeing (as it "interacted" with SYNCHRONOUS playSound). But as you observed, it still doesn't explain why setVisible false will work correctly when placed before synchronous playSound, and setVisible True won't. Dan Moyer On Fri, 29 Oct 1999 20:31:50 -0400, Dan Moyer <DanMoyer at PRODIGY.NET> wrote: >Brian, > >I'm not totally sure about this, but when I was testing this problem to see >what I could understand about it, I THINK I found that the "setVisible >false" is NOT what makes the control disappear in this situation, re your >test. What I remember doing is this: > >in my application, I am actually making a combination of labels & list >boxes selectivly show or not show, & that's what is not being set visible >when they should when a sound is played AFTER they're told to be visible; > > so, as a test, I rigged the program so that the code which should make one >set of controls INVISIBLE and a new set VISIBLE when a button is clicked, >had the portion that would make the current set invisible commented out , >and when I tested it, THE CURRENT CONTROL DISAPPEARED ANYWAY on button >click; then when the "new" control became visible after the sound played, >the old control THEN showed up superimposed over it (since it wasn't set >invisible). But even though it hadn't been set invisible, it DID disappear >on the initial button click. > >So my guess is that something about the initial action of the setVisible >command erases the control specified BEFORE it checks for whether or not >the parameter is true or false, and THEN the sound routine takes over, >leaving the control not there until the sound is finished playing, and THEN >the setVisible parameter is checked & the control is either made visible or >made invisible. > >Does that seem at all likely to be happening? It would explain your >result, if that is what is going on, though I'm not sure what it might say >about a fix. I'll have to check my myrid sequence of test versions to see >if what I described doing & seeing is accurate, but I think it is. > >On Fri, 29 Oct 1999 18:41:29 -0400, Brian Broker <bkb at CNW.COM> wrote: > >>Further experimentation: I added the playsound to the Restart_onClick >>function: >> >>procedure Restart_onClick () >> setVisible(LText2,False) >> playsound("test.wav") >>end procedure >> >>and here there is no problem... The control becomes invisible before the >>sound is played. But I still don't see why it doesn't work the same when >>making the control visible...
10. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Nov 02, 1999
- 585 views
- Last edited Nov 03, 1999
Hello, This may not be the kind of fix you are looking for but it seems that if you made all of your sound files exactly the same length you could have you program check for time passed since the last sound was started in order to know when to start the next one. This way you're only playing one sound at a time. Lewis Townsend ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
11. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Nov 02, 1999
- 555 views
- Last edited Nov 03, 1999
Lewis, Yeah, I tried something like that, using an approximate time delay, but the problem is that then the problem that ASYNC On Tue, 2 Nov 1999 21:00:19 GMT, Lewis Townsend <keroltarr at HOTMAIL.COM> wrote: >Hello, > >This may not be the kind of fix you are looking for but it seems >that if you made all of your sound files exactly the same length >you could have you program check for time passed since the last >sound was started in order to know when to start the next one. >This way you're only playing one sound at a time. > >Lewis Townsend > >______________________________________________________ >Get Your Private, Free Email at http://www.hotmail.com
12. Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Nov 02, 1999
- 536 views
- Last edited Nov 03, 1999
sorry all, I was typing too fast & hit the wrong key & previous message was sent incomplete :( Lewis, Yeah, I tried something like that, using an approximate time delay, but the problem is that then the problem that ASYNC had "solved" (controls not setVisible when they should) re-presented itself. The problem is apparently NOT playsound sync or async, but in setVisible. I included a demo of this in next post. Thanks for trying, tho! Dan On Tue, 2 Nov 1999 21:00:19 GMT, Lewis Townsend <keroltarr at HOTMAIL.COM> wrote: >Hello, > >This may not be the kind of fix you are looking for but it seems >that if you made all of your sound files exactly the same length >you could have you program check for time passed since the last >sound was started in order to know when to start the next one. >This way you're only playing one sound at a time. > >Lewis Townsend >