Menu
Forums
Login | Register

Home > Forums > OpenGL ES > Simple method for playing WAV file Page :  1 
Simple method for playing WAV file
Hi!
Im using for playing sound sndPlaySound() function, its weird but on emulator and real ppc i get buzzling sound... format of WAV file is good i think as i used this function on PC and it plays this file perfectly.
Any other simple method for playing sound?
Hi,

Have you tried using the PlaySound function rather than the sndPlaySound function?

Have a look at this page which may provide more information :

http://www.pocketpcdn.com/articles/playsound.html

Regards,
Grant
Hmmm i read somewhere that on PPC to use sndPlaySound... ill later check it.
thanks
Still the same, im getting buzzing sound :(
Hi,

Have you tried to go further by using the waveOut functions :

http://www.pocketpcdn.com/articles/pocketpcaudio.html

Regards,
Grant
I now know what was the problem...
It couldnt find those files, thats why it was buzzing (default windows sound but looped).

I now hardcoded paths and it works...
But i want to look for paths and generate it, but it seems PlaySound (or sndPlaySound). On PC it works good using the way described here in tuts for finding textures ect, but it doesnt work for Playsound on PPC (on PC in OpenGL works).

Can any1 help me by showing example how to force PlaySound to take path from array/string...

thx in advance

-=Guruma=-
Hi,

You can use the following code to get the full path on Windows CE:

TCHAR path[256];
char fullPath[256];

GetModuleFileName(NULL, path, 256);

TCHAR *pos = wcsrchr(path, '\\');
*(pos + 1) = '\0';
wcstombs(fullPath, path, 256);

Your current working directory will then be stored in fullpath. If you have a filename, you can just add this onto the path as follows:

strcat(fullPath, filename);

Hope this helps.

Regards,
Grant
The problem is is that it doesnt work :P
I wrote above that i used that way of finding paths like in tuts with textures... And PPC cant fins path to file using that :\ It works for me for opening files and textures but when i use it in PlaySound function... it doesnt work :P Or im on high :P Ill check it once again heh

thanks!

-=Guruma=-
Hi,

But you say if you put in the path manually as a string, it works?

Try concatenating the filename to the fullpath as shown above and then display it in a message box with the MessageBox function.

See if there is any difference between what you enter when it works and the value you pass in with a variable.

Regards,
Grant
Yes it works, and i mainly do exactly the same! :) But it doesnt work with this PlaySound function :\

http://download.yousendit.com/9EC475E86043AAC2

Here is project file with this function and how i use it, if ull have time check it :)
On PC using OpenGL it works... on PPC it doesnt heh

-=Guruma=-
No one knows how to make it run?

:(

-=Guruma=-
Well I found the answer for this long time ago and I see no one replied so ill maybe answer to my own question. Maybe it will help someone :)

If you fallowed zeus tutorials with loading texture files, and like me try to load in the same way WAV file in simple function PlaySound(), you will fail!
Answer to this is that you can't use char type for your string like in texture loading, you need to convert it to unicode string, then it will successfully open and play the sound. Here is the example code (fullPath and path from zeus tutorials, take a look in texture loading tutorials):

wcstombs(fullPath, path, 256);
strcat(fullPath, "Menu.wav");

wchar_t sound[1024];
MultiByteToWideChar(CP_ACP, 0, fullPath, -1, sound, 1024);

if (PlaySound(sound, NULL, SND_ASYNC|SND_LOOP|SND_FILENAME)==FALSE)
MessageBox(NULL, L"Can't locate Menu.wav!", L"Error", MB_OK);

Hopes that will help someone, it is really simplest way to play a sound in ur apps :)
Hi,

Well done on finding the solution. I'm very certain that this will definitely help many others.

Thanks a lot for posting the solution.

Regards,
Grant

Home > Forums > OpenGL ES > Simple method for playing WAV file Page :  1 

You need to be logged in to reply to this topic.


All Rights Reserved, © Zeus Communications, Multimedia & Development 2004-2005

Read the Disclaimer

Links