1. Win32Lib: playing .wav usurps normal program flow?
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 28, 1999
- 587 views
David, I have three problems finishing my first Euphoria windows program (first two problems previously mentioned here earlier): 1. MODAL WINDOWS : if open modal, then minimize it, then REOPEN (not restore) it, close it, & click anywhere in main, HANGS UP; 2. SETTEXT IN A LABEL: if I concatenate quoted "text" & a sequence variable it puts BOTH in label, but if I concatenate sequence variable & quoted "text", it only puts sequence variable there; 3. PLAYING WAVE FILE USURPS "setVisible" in program flow: I added some sound to a program, & "setVisible" seems to be relating weirdly with the sound playing; my program flow first sets some controls visible, & then plays a .wav file, but what actually happens is that the sound plays first, & then the controls become visible when the sound is finished playing. This results in a very dorky look, because significant expanses of the screen disappear for an unpalatable length of time (while the .wav is playing), before something finally shows back there. I hope there's some way to make this not work like this? In case the specific method I chose to use to play the wave file is responsible, & someone could suggest a better way, here's what I did, lifted from Hecnor's multiplication exercise in the archive: -- TO PLAY A .WAV FILE: procedure playsound(sequence wave) atom file file = allocate_string(wave) c_proc(xPlaySound, {file, 1, 0}) free(file) end procedure In case there isn't a better way to play a wave, here's a demo I made of the problem (using your IDE, which works real nice!): (NOTE THAT YOU HAVE TO NAME SOME (short) .WAV FILE TO 'test.wav' FIRST) -- demo of problem with .wav sound happening before setVisible, -- even though setVisible is commanded before playsound. include Win32Lib.ew without warning 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, 1, 0}) free(file) end procedure ------------------------------------ procedure TheWindow_onOpen () -- TEST INSTRUCTIONS: setText(LText5,"Before you perform this test, name some .wav file 'test.wav' and put it into the programs directory. Click the button; some text SHOULD show BEFORE test.wav plays; it doesn't.") --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, Normal ) Hope you can help, Dan Moyer
2. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by Greg Harris <blackdog at CDC.NET> Oct 28, 1999
- 566 views
On Thu, 28 Oct 1999 07:25:16 -0400, Dan Moyer <DanMoyer at PRODIGY.NET> wrote: Hi Dan, Your example was set to synchronous playback. You want async playback using the SND_ASYNC flag. Instead of: procedure playsound(sequence wave) atom file file = allocate_string(wave) c_proc(xPlaySound, {file, 1, 0}) free(file) end procedure 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 >David, > >I have three problems finishing my first Euphoria windows program (first >two problems previously mentioned here earlier): > >1. MODAL WINDOWS : if open modal, then minimize it, then REOPEN (not >restore) it, close it, & click anywhere in main, HANGS UP; > >2. SETTEXT IN A LABEL: if I concatenate quoted "text" & a sequence variable >it puts BOTH in label, but if I concatenate sequence variable & quoted >"text", it only puts sequence variable there; > >3. PLAYING WAVE FILE USURPS "setVisible" in program flow: > >I added some sound to a program, & "setVisible" seems to be relating >weirdly with the sound playing; my program flow first sets some controls >visible, & then plays a .wav file, but what actually happens is that the >sound plays first, & then the controls become visible when the sound is >finished playing. This results in a very dorky look, because significant >expanses of the screen disappear for an unpalatable length of time (while >the .wav is playing), before something finally shows back there. I hope >there's some way to make this not work like this? > >In case the specific method I chose to use to play the wave file is >responsible, & someone could suggest a better way, here's what I did, >lifted from Hecnor's multiplication exercise in the archive: > >-- TO PLAY A .WAV FILE: >procedure playsound(sequence wave) >atom file > file = allocate_string(wave) > c_proc(xPlaySound, {file, 1, 0}) > free(file) >end procedure > >In case there isn't a better way to play a wave, here's a demo I made of >the problem (using your IDE, which works real nice!): > >(NOTE THAT YOU HAVE TO NAME SOME (short) .WAV FILE TO 'test.wav' FIRST) > >-- demo of problem with .wav sound happening before setVisible, >-- even though setVisible is commanded before playsound. > >include Win32Lib.ew >without warning > >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, 1, 0}) > free(file) >end procedure >------------------------------------ >procedure TheWindow_onOpen () > >-- TEST INSTRUCTIONS: > setText(LText5,"Before you perform this test, name some .wav file >'test.wav' and put it into the programs directory. Click the button; some >text SHOULD show BEFORE test.wav plays; it doesn't.") > >--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, Normal ) > > >Hope you can help, >Dan Moyer
3. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Oct 28, 1999
- 548 views
Greg Harris wrote: > Your example was set to synchronous playback. > You want async playback using the SND_ASYNC flag. That sounds right to me. I've added the playSound to Win32Lib, so the GlassWorks game can click and beep. I'll try to stick it in the bleeding edition soon. -- David Cuny
4. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Oct 28, 1999
- 548 views
Hello, >2. SETTEXT IN A LABEL: if I concatenate quoted "text" & a sequence variable >it puts BOTH in label, but if I concatenate sequence variable & quoted >"text", it only puts sequence variable there; I don't know for sure but something that hasn't been suggested yet is the possibility that the string in the sequence variable could have a cariage return on the end hence wrapping all remaining text to the next line and possibly out of the label or form area. later, Lewis Townsend ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
5. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 28, 1999
- 536 views
- Last edited Oct 29, 1999
Greg, THANKS! Your synchronous playback suggestion worked just fine in my demo, & I suspect it will do exactly the same in my program. Dan 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 >
6. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 28, 1999
- 529 views
- Last edited Oct 29, 1999
Hi Lewis, That's an interesting thought that hadn't occured to me; but what I didn't explain was that the sequence variable I'm using is an item from a list control, & when I "added" the items to the list, I just put simple text into quotes, no CR there, so I don't see how that could be the problem. Any other thoughts? Here's a snippet of code that displays BOTH the quoted text & list item: this=getItem(List1,here) setText(Label1, "times " & this) And this snippet displays ONLY the item from the list: this=getItem(List1,here) setText(Label1, this & "times ") Dan On Thu, 28 Oct 1999 19:50:28 GMT, Lewis Townsend <keroltarr at HOTMAIL.COM> wrote: >Hello, > >>2. SETTEXT IN A LABEL: if I concatenate quoted "text" & a sequence variable >>it puts BOTH in label, but if I concatenate sequence variable & quoted >>"text", it only puts sequence variable there; > >I don't know for sure but something that hasn't been >suggested yet is the possibility that the string in the >sequence variable could have a cariage return on the end >hence wrapping all remaining text to the next line and >possibly out of the label or form area. > >later, >Lewis Townsend > >______________________________________________________ >Get Your Private, Free Email at http://www.hotmail.com
7. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by David Cuny <dcuny at LANSET.COM> Oct 29, 1999
- 547 views
Dan Moyer wrote: >And this snippet displays ONLY the item from the list: > this=getItem(List1,here) > setText(Label1, this & "times ") > My suspicion is that getItem includes a '0' (string terminator in C) at the end of the string, so when you pass the concatonated string using setText, it looks something like this: { ... 0, 't', 'i', 'm', 'e', 's' } The zero prevents the rest of the string from being seen. You can test it by changing the code to: setText(Label1, this[1..length(this)-1] & "times ") I'll try to check it out myself when I'm not trying to put a hyperactive two-year old to bed. -- David Cuny
8. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 29, 1999
- 558 views
David, I really don't know how you manage to respond to SO many questions, write code, work, AND get a hyper 2 year old to bed, but THANKS! It's a good thing for a lot of us that you don't also need to sleep! :) Your suggestion to use: "setText(Label1, this[1..length(this)-1] & "times ")" to allow displaying the concatenation of a list item ("this")and quoted text in a label worked in my program. Wolfgang Fritz also suggested the same solution (thanks Wolfgang!), and I think you had mentioned the possible nature of the problem in an earlier post, but until I read your last post I had no idea where an extraneous character could be coming from, so thanks again for both the fix AND the explanation. Maybe getItem could be fixed to not pass that trailing "0"? Dan Moyer On Fri, 29 Oct 1999 00:10:46 -0700, David Cuny <dcuny at LANSET.COM> wrote: >Dan Moyer wrote: > >>And this snippet displays ONLY the item from the list: >> this=getItem(List1,here) >> setText(Label1, this & "times ") >> > >My suspicion is that getItem includes a '0' (string terminator in C) at the >end of the string, so when you pass the concatonated string using setText, >it looks something like this: > > { ... 0, 't', 'i', 'm', 'e', 's' } > >The zero prevents the rest of the string from being seen. You can test it by >changing the code to: > > setText(Label1, this[1..length(this)-1] & "times ") > >I'll try to check it out myself when I'm not trying to put a hyperactive >two-year old to bed. > >-- David Cuny
9. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by Kat <KSMiTH at PELL.NET> Oct 29, 1999
- 534 views
> David, > > I really don't know how you manage to respond to SO many questions, write > code, work, AND get a hyper 2 year old to bed, but THANKS! It's a good > thing for a lot of us that you don't also need to sleep! :) I have wondered about this a *lot* ! What's the secret, David? Kat
10. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by David Cuny <dcuny at LANSET.COM> Oct 29, 1999
- 535 views
Dan Moyer wrote: >Maybe getItem could be fixed to not pass that trailing "0"? Yes, this is a bug I should have taken care of before. I'll correct it. Thanks! -- David Cuny
11. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by Ad Rienks <kwibus at ZONNET.NL> Oct 29, 1999
- 532 views
I still think Lewis' suggestion is right. Try: this = this[1..length(this)-1] before the setText line. Hope this helps ----- Oorspronkelijk bericht ----- Van: Dan Moyer <DanMoyer at PRODIGY.NET> Aan: <EUPHORIA at LISTSERV.MUOHIO.EDU> Verzonden: vrijdag 29 oktober 1999 5:39 Onderwerp: Re: Win32Lib: playing .wav usurps normal program flow? > Hi Lewis, > > That's an interesting thought that hadn't occured to me; but what I didn't > explain was that the sequence variable I'm using is an item from a list > control, & when I "added" the items to the list, I just put simple text > into quotes, no CR there, so I don't see how that could be the problem. > Any other thoughts? > > Here's a snippet of code that displays BOTH the quoted text & list item: > this=getItem(List1,here) > setText(Label1, "times " & this) > > And this snippet displays ONLY the item from the list: > this=getItem(List1,here) > setText(Label1, this & "times ") > > Dan > > > On Thu, 28 Oct 1999 19:50:28 GMT, Lewis Townsend <keroltarr at HOTMAIL.COM> > wrote: > > >Hello, > > > >>2. SETTEXT IN A LABEL: if I concatenate quoted "text" & a sequence > variable > >>it puts BOTH in label, but if I concatenate sequence variable & quoted > >>"text", it only puts sequence variable there; > > > >I don't know for sure but something that hasn't been > >suggested yet is the possibility that the string in the > >sequence variable could have a cariage return on the end > >hence wrapping all remaining text to the next line and > >possibly out of the label or form area. > > > >later, > >Lewis Townsend > > > >______________________________________________________ > >Get Your Private, Free Email at http://www.hotmail.com
12. Re: Win32Lib: playing .wav usurps normal program flow?
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Oct 29, 1999
- 544 views
- Last edited Oct 30, 1999
Ad, You're absolutely right, Lewis' suggestion did work, I just didn't bother to try it because I didn't understand HOW it could be relevant!! Then David gave me both an explanation as to how a character could pop up from getItem that I didn't put there, and a code example (same as yours, same as Wolfgang's, same as anyone who can actually code would have suggested), & then I tried it & it worked perfectly. If I could actually code worth beans I would have taken Lewis' suggestion & used it to make the obvious code, tested it, & found my problem solved. Thanks to everyone who suggested stripping off the last character, & to those who gave code example, and to David for explaining HOW it could be happening. Dan Moyer On Fri, 29 Oct 1999 19:34:02 +0200, Ad Rienks <kwibus at ZONNET.NL> wrote: >I still think Lewis' suggestion is right. Try: > this = this[1..length(this)-1] >before the setText line. > >Hope this helps > >----- Oorspronkelijk bericht ----- >Van: Dan Moyer <DanMoyer at PRODIGY.NET> >Aan: <EUPHORIA at LISTSERV.MUOHIO.EDU> >Verzonden: vrijdag 29 oktober 1999 5:39 >Onderwerp: Re: Win32Lib: playing .wav usurps normal program flow? > > >> Hi Lewis, >> >> That's an interesting thought that hadn't occured to me; but what I didn't >> explain was that the sequence variable I'm using is an item from a list >> control, & when I "added" the items to the list, I just put simple text >> into quotes, no CR there, so I don't see how that could be the problem. >> Any other thoughts? >> >> Here's a snippet of code that displays BOTH the quoted text & list item: >> this=getItem(List1,here) >> setText(Label1, "times " & this) >> >> And this snippet displays ONLY the item from the list: >> this=getItem(List1,here) >> setText(Label1, this & "times ") >> >> Dan >> >> >> On Thu, 28 Oct 1999 19:50:28 GMT, Lewis Townsend <keroltarr at HOTMAIL.COM> >> wrote: >> >> >Hello, >> > >> >>2. SETTEXT IN A LABEL: if I concatenate quoted "text" & a sequence >> variable >> >>it puts BOTH in label, but if I concatenate sequence variable & quoted >> >>"text", it only puts sequence variable there; >> > >> >I don't know for sure but something that hasn't been >> >suggested yet is the possibility that the string in the >> >sequence variable could have a cariage return on the end >> >hence wrapping all remaining text to the next line and >> >possibly out of the label or form area. >> > >> >later, >> >Lewis Townsend >> > >> >______________________________________________________ >> >Get Your Private, Free Email at http://www.hotmail.com