Computing.Net > Forums > Programming > PlaySound() API

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PlaySound() API

Reply to Message Icon

Name: Dr. Nick
Date: January 8, 2004 at 01:18:31 Pacific
OS: WinXP Pro SP1a
CPU/Ram: P4 2.0Ghz / 1024MB
Comment:

Odd question here that maybe someone can answer...

I've been trying to play a wav file using the simple PlaySound() API in Windows XP. The problem I'm suddenly running into is that larger wav files are not being played. The function is not returning a false value as it does if the call fails (not enough memory, no audio devices, etc). Smaller wavs play with no problem.

The magic number seems to be about 13.5MB. Much past that and the wav will not play. I know it's not a memory issue because between physical and virtual memory I have about 2GB.

Just wondering if anyone here has used PlaySound before and/if it's caused them any problems. The weird thing is that I've used PlaySound before on wavs up to almost 80MB and the only issue is that it takes a few seconds to load the file into memory. Once that's done the file played fine. I've let the little app I wrote sit for some time after telling it to play, but nothing ever happens.

My other thought was that maybe something is messed up on my system. I wrote a tiny test app that simply test's PlaySound on a wav you specify. If you want too see if it will play large wavs on your system, the file is here:

ftp://drnick.no-ip.org/software/PlaySoundTest.exe

Anonymous user, no pass. Should work, but Serv-U's been a little flaky.

Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: anonproxy
Date: January 9, 2004 at 00:12:00 Pacific
Reply:

Works fine on 13.7 MB wav and 29 MB wav. Either your machine or the context of the function is the problem (admittedly, I don't have any guesses to a context with this result). This function (along with its MCI counterpart) is inefficient with larger files (buffering 30-80 MB is ridiculous in most situations), though simple to use. A streaming buffer through directsound might be better. Your other option is to control the stream yourself.

Have you tried asynchronous play?

Does this problem appear in the first call of the function? What are the flags?

Some (boring) sound files tested here.


0

Response Number 2
Name: Dr. Nick
Date: January 9, 2004 at 00:53:43 Pacific
Reply:

Hey, thanks for the reply!

First, I'm calling PlaySound like this:

PlaySound("wav_path.wav", NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT)

I am playing it asynchronously, and have tried using different flags but none seem to make a difference.

I've also tried using many different wav files thinking that maybe the ones I was trying to use (converted MP3) were somehow incompatible for one reason or another. I tried one of the 30MB wavs from the link you posted, but no joy.

I'm going to take a look at the DirectSound, but I am curious as to why this is refusing to play on my machine, though it's kinda nice to know that it does work on others.


0

Response Number 3
Name: Dr. Nick
Date: January 9, 2004 at 01:06:29 Pacific
Reply:

Hmmm. Well, I tried it on someone else's XP box here and it worked on a 70MB file. I suppose it must be something off on my machine. The question is what in the world it might be.


0

Response Number 4
Name: anonproxy
Date: January 9, 2004 at 11:07:03 Pacific
Reply:

Can you play the large files in a regular player?


0

Response Number 5
Name: Dr. Nick
Date: January 9, 2004 at 18:32:14 Pacific
Reply:

Yep. Both the Sound Recorder Accessory (sndrec32.exe) and Winamp have no problems playing large wav files. I haven't been able to think of any reason why I shouldn't be able to play it.


0

Related Posts

See More



Response Number 6
Name: anonproxy
Date: January 9, 2004 at 22:54:32 Pacific
Reply:

So your audio subsystem and driver are fine (as to be expected). The file seems stuck between the system call and the driver. Using the MCI methods you might be able to troubleshoot this further with a fairly clean debug. MS doesn't recommend large files sizes through this API method (example given is 100k, for the total of several files I believe).

There are other, undocumented factors at work here.


0

Response Number 7
Name: Rajesh
Date: January 19, 2004 at 10:08:37 Pacific
Reply:

I have tried

const int SND_SYNC = 0x0;

[DllImport("CoreDll.DLL", EntryPoint="PlaySound", SetLastError=true)]
private extern static bool

PlaySound(string lpszSound,IntPtr hMod,int fdwSound);

PlaySound("Loopy.wav", IntPtr.Zero, SND_SYNC);

I am working for PocketPC2003.
But it doesn't play any sound.

Could you please help me.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: PlaySound() API

Auto Sound Play in vb www.computing.net/answers/programming/auto-sound-play-in-vb/14369.html

finding a poker game api www.computing.net/answers/programming/finding-a-poker-game-api/9194.html

C++ PlaySound() error www.computing.net/answers/programming/c-playsound-error/13543.html