nga911

am using a        PlaySound("dot.wav", NULL, SND_FILENAME | SND_SYNC);

to play dot.wav file it works but hangs the program till it stops,is there any way to make it play smothly.

or can i use          waveOutOpen  to play it  

 if(yes)

{

    how

}

 

 



Re: Visual C++ General PlaySound() hangs my program help

einaros

In such cases, check the documentation of the function you are using. The SND_SYNC flag you are passing means that the function will not return till the sound has completed playing. Replace that flag with SND_ASYNC, and it should return immediately while the sound is still playing.




Re: Visual C++ General PlaySound() hangs my program help

nga911

but i hav

else if(input[m]=='C')
{

PlaySound("dash.wav", NULL, SND_FILENAME | SND_SYNC);
PlaySound("dot.wav", NULL, SND_FILENAME | SND_SYNC);
PlaySound("dash.wav", NULL, SND_FILENAME | SND_SYNC);
PlaySound("dot.wav", NULL, SND_FILENAME | SND_SYNC);


}

if i chose SND_ASYNC it will play all at the same time





Re: Visual C++ General PlaySound() hangs my program help

Allaudeen_N_ff93ad

Hi pal,

Just try with other Argument other than SND_SYNC....





Re: Visual C++ General PlaySound() hangs my program help

TilakGopi

Hi,

Create a thread and play sounds in the thread procedure.

That's what a thread is for(smooth running of application).

 

Thanx,

Ch.T.Gopi Kumar.






Re: Visual C++ General PlaySound() hangs my program help

einaros

nga911 wrote:

but i hav

else if(input[m]=='C')
{

PlaySound("dash.wav", NULL, SND_FILENAME | SND_SYNC);
PlaySound("dot.wav", NULL, SND_FILENAME | SND_SYNC);
PlaySound("dash.wav", NULL, SND_FILENAME | SND_SYNC);
PlaySound("dot.wav", NULL, SND_FILENAME | SND_SYNC);


}

if i chose SND_ASYNC it will play all at the same time

So you want them to play one at a time, but without halting the program If that's the case, I suggest you look into making your application threaded, or just let the application "hang". If you decide to multi-thread it, make use of a synchronized input queue (deque<char>, wrapped with CriticalSections, or similar). Have one thread accept the input (and do whatever else your application does, like show a GUI), and a worker check the queue one letter at a time and play those sounds.






Re: Visual C++ General PlaySound() hangs my program help

nga911

sory what is a thread ,can you show me an example ( a realy simple one).



Re: Visual C++ General PlaySound() hangs my program help

TilakGopi

Hi,

A thread is a light weight process(ofcourse ,child to the main process).When u create a thread, u have to pass the threadprocedure(a function with particular prototype) in which u have to write code,which can hang the application if it is written outside threadproc.

For more info about thread:

http://www.cafeaulait.org/course/week11/03.html

http://www.science.uva.nl/ict/ossdocs/java/tutorial/java/threads/definition.html

http://msdn2.microsoft.com/en-us/library/ms682453.aspx

and for examples:

http://www.codersource.net/published/view/310/threading_in_vc.aspx

http://www.codeguru.com/cpp/w-d/dislog/threads/article.php/c5027/

http://www.codersource.net/codersource_mfc_prog.html

http://www.codeproject.com/threads/

Hope , u can understand better about threads ,after reading this stuff.

Thanx,

Ch.T.Gopi Kumar.