473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sound advice

Can anybody point me to or give a simple source example of a managed C++
application that can play a wav sound file? I know a little about
playSound(), but it doesn't seem to like to compile (even though it's
'recognized' via type-ahead in the editor). Required header files might be
my problem, not sure...

Thanx in advance! :)
Nov 17 '05 #1
2 1637
"Peteroid" <pe************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Can anybody point me to or give a simple source
example of a managed C++
application that can play a wav sound file?
Yup, try this:

#include <windows.h>

#using <mscorlib.dll>
using namespace System;

int main()
{
Console::WriteLine(S"Play sound test ...");

PlaySound("file.wav", 0, SND_FILENAME);

return 0;
}

Change "file.wav" to be the full path to a multimedia file.
I know a little about playSound(), but it doesn't
seem to like to compile (even though it's 'recognized'
via type-ahead in the editor). Required header files
might be my problem, not sure...


Compilers can be so picky ... :-)

Seriously, it is often wise to post a _few lines_ of code and the _exact_
text of the error message you get from the compiler. More often than not
someone here will be able to decipher it for you. And on those rare
occasions when no one can spot the error, it can be escalated to someone who
does.

Regards,
Will
Nov 17 '05 #2
Thanx for responding!

I tried the code snipet below, and I get a lot of errors. After a little
experimentation, I've narrowed it down to not liking the inclusion of
"windows.h". It needs it to recognize PlaySound() and SND_FILENAME, but a
subset of the errors it gives with windows.h are as follows:

C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\ObjIdl.h(7385): error C2371: 'IDataObject' :
redefinition; different basic types

C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\ObjIdl.h(7894): error C2371: 'IMessageFilter' :
redefinition; different basic types

c:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\ServProv.h(92): error C2872: 'IServiceProvider'
: ambiguous symbol
:
:
etc.

and other errors that look like just these same errors being repeated many
times. I'm doing a MANAGED windows program, is that the problem?

[==Peter==]

"William DePalo [MVP VC++]" <wi***********@mvps.org> wrote in message
news:O3**************@TK2MSFTNGP09.phx.gbl...
"Peteroid" <pe************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Can anybody point me to or give a simple source
example of a managed C++
application that can play a wav sound file?
Yup, try this:

#include <windows.h>

#using <mscorlib.dll>
using namespace System;

int main()
{
Console::WriteLine(S"Play sound test ...");

PlaySound("file.wav", 0, SND_FILENAME);

return 0;
}

Change "file.wav" to be the full path to a multimedia file.
I know a little about playSound(), but it doesn't
seem to like to compile (even though it's 'recognized'
via type-ahead in the editor). Required header files
might be my problem, not sure...


Compilers can be so picky ... :-)

Seriously, it is often wise to post a _few lines_ of code and the

_exact_ text of the error message you get from the compiler. More often than not
someone here will be able to decipher it for you. And on those rare
occasions when no one can spot the error, it can be escalated to someone who does.

Regards,
Will

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: anton muhin | last post by:
Hello everybody! I need advice and expertise of the community for the following problem. I'm going to make a psycholinguistic experiment. In this experiment the auditor is asked to listen to...
3
by: Gil | last post by:
I'm trying to write a page that allows me to change the background midi that's playing. I've been going crazy consulting Google Groups, and coming up with ingenious solutions, some of which kind...
4
by: Peter | last post by:
I've embedded a midi file as background sound in my "index.html" which links to other pages on the site and I want the the same background sound to play on all pages "without interruption (and...
0
by: Soon Lee | last post by:
Hi all is it possible to custom or write to the registor that control the ac97 card and write our own sound player with it? please advice -- WebSite : http://soonlee.agreatserver.com
1
by: Jon Lehrer | last post by:
Hoping for some advice: I would like to write some code that controls the "window's sound recorder" that I embedded in my program with OLE. I can do this with Excel...
0
by: djc | last post by:
Playing with visual studio 2005. (and I'm not really a programmer... I just tinker... so keep that in mind) I have several wav files added as project resources. I am wondering if there is a way...
2
by: babe6776 | last post by:
Computer - Dell Dimension 3100 Windows XP SP2 Media centre When we bought our computer the sound drivers weren't properly loaded, so my husband reloaded them from the internet. The sound has...
0
by: leeogrady | last post by:
Is it possible to create a sound file (ie wav/mp3 or similar) from within vb2005? I import data from a excell file, i would then like to make a series of sound files, 1st file = first line read out...
1
by: sukatoa | last post by:
Now, im currently on an experiment on Java Sound API.... now, i am attempting to capture the duration ( time limit of a given wav file )but still have no idea... I found this link -7.8 but i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.