PlaySound limitation?

PlaySound limitation?

Post by Tim Wallac » Thu, 14 Dec 2006 01:31:09


I posted this in a group that suggested I post it here instead.

I am writing a little app in which I need to play a WAV file based on a
value in an XML file. Various XML files are passed in with different WAV
files. I'm not including the WAVs as resources. If I call PlaySound and
use the filename approach, only part of the WAV is played (the WAVs are big,
around 32 meg each). I figured I'd try the stream approach...same result.
Can someone tell me either what magic I have to use to get a big WAV to play
via PlaySound or some other method whereby I can play a WAV file from a
console application? I need this app to work for my Christmas light/sound
display.

Let me share more data about my app in case it helps: the main thread
creates two threads, one to handle playing the WAV file and one to handle my
relay boards (I have two PCBs with relays I use to turn light strands on and
off). I use event objects to syncronize the starting of the threads (I want
them to start "simultaneously"). The main thread waits for these threads to
signal two other events to indicate processing is done. Once that wait is
satisfied, the application terminates.

Thanks.

Tim
 
 
 

PlaySound limitation?

Post by Alessandro » Thu, 14 Dec 2006 03:27:32

From: "Tim Wallace"


Why don't you just use DirectShow? It's a few more lines of
code, but that's what WMP and pther players use so, if the
WAV plays in them, it will play in your application. And
before you ask, you can use DirectShow in a console
application without windows of any kind.

This is all the code you need to duplicate
WinMM.DLL!PlaySound(SND_SYNC):

http://www.yqcomputer.com/

Notice that the very same code will also play MP3 or WMA
files or even videos.


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.yqcomputer.com/

 
 
 

PlaySound limitation?

Post by Chris P » Thu, 14 Dec 2006 05:46:08


To add to Alessandro's comments:


I think your files are too big for PlaySound.

If you're using C# or VB.NET I would use the built in AudioVideoPlayback
class. If your using C/C++ I would use DirectShow.

DirectShow can be a little daunting but for this simple application you
should have no problem. Just grab the current Platform SDK (Windows SDK),
and a recent DirectX SDK. Note if you are using Visual Studio 2005 you
want the Vista build of the Windows Platform SDK.

First build the baseclasses which are listed as samples, under
.\samples\Multimedia\DirectShow\BaseClasses
Load the project files from here to make this easy.
http://www.yqcomputer.com/


Read through the reference sample provided by Alessandro.

I also posted a full working sample project here for VS2005.

http://www.yqcomputer.com/

You need the following environment variables if you don't have all the
paths in your VS config.
DSHOWBASECLASSES=x:\SDK\Windows\Samples\Multimedia\DirectShow\BaseClasses\
WSDK_DIR=x:\SDK\Windows\
DXSDK_DIR=<directX install location automatic>

--
http://www.yqcomputer.com/
http://www.yqcomputer.com/
 
 
 

PlaySound limitation?

Post by Alessandro » Thu, 14 Dec 2006 06:13:11

From: "Chris P."


You don't need the BaseClasses for this task (lucky poster!
:-)).

--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.yqcomputer.com/
 
 
 

PlaySound limitation?

Post by Chris P » Thu, 14 Dec 2006 06:30:37

 
 
 

PlaySound limitation?

Post by Tim Wallac » Thu, 14 Dec 2006 07:13:57

Where can I find this download? I thought directshow was part of directx, I
was wrong, so I don't have it installed. I can find a link to order a CD,
but I need this application finished pronto for my Christmas lights and
sound display.

Tim
 
 
 

PlaySound limitation?

Post by The March » Thu, 14 Dec 2006 07:43:05


You can download it as part of an old DirectX or part of the Windows
(Platform) SDK. See my site for details.

--
Please read this before replying:
1. Dshow & posting help: http://www.yqcomputer.com/
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution
 
 
 

PlaySound limitation?

Post by Alessandro » Thu, 14 Dec 2006 07:45:33

From: "Tim Wallace"


If you had read Chris's post carefully: <<<Just grab the
current Platform SDK (Windows SDK), and a recent DirectX
SDK. Note if you are using Visual Studio 2005 you want the
Vista build of the Windows Platform SDK.>>>.


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.yqcomputer.com/
 
 
 

PlaySound limitation?

Post by Tim Wallac » Thu, 14 Dec 2006 07:55:11

I did read the post carefully. I "grabbed" that file and attempted to
install. I got an error when I ran it, that's why I was inquiring of a
better site. Should I not attempt to use the "web install" version?

Tim
 
 
 

PlaySound limitation?

Post by Alessandro » Thu, 14 Dec 2006 08:13:28

From: "Tim Wallace"


The are only 2 legal sources for the PSDK: an MSDN
subscription or the public MS web site. If you do not have a
subscription, you're stuck with the public download.

- SDK for Vista (both web setup and ISO image):
http://www.yqcomputer.com/

- SDK for XP/2003 (full):
http://www.yqcomputer.com/

- SDK for XP/2003 (ISO):
http://www.yqcomputer.com/

- SDK for XP/2003 (web):
http://www.yqcomputer.com/

I usually go with the full download.


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.yqcomputer.com/
 
 
 

PlaySound limitation?

Post by Tim Wallac » Thu, 14 Dec 2006 14:08:57

I was downloading while at a client site. When I got to my home office and
tried again, the download/install worked. Thanks for clearing that up for
me. Now, I only have to figure out my WaitForMultipleObjects doesn't stop
polling when my two events are signalled...

Thanks again.

Tim