Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 16th, 2005, 07:55 PM
bballmitch
Guest
 
Posts: n/a
Default Playsound Function

Why won't the following code work?

char soundfile2[] = "C:/Windows/Media/pinky and the
brain.wav";

PlaySound(soundfile2,NULL,SND_FILENAME|SND_SYNC|SN D_ASYNC);
getchar();

i put libwinmm.a in the parameters and i have all the right headerfiles
in there, but it won't work. it says that i must declare SND_FILENAME ,
SND_SYNC and everything else in the second line. It works perfectly in
a console application but it doesn't seem to work in a glut
application. BTW, im using namespace std.
can someone please help me out.

  #2  
Old August 16th, 2005, 08:05 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: Playsound Function

bballmitch wrote:[color=blue]
> Why won't the following code work?
>
> char soundfile2[] = "C:/Windows/Media/pinky and the
> brain.wav";
>
> PlaySound(soundfile2,NULL,SND_FILENAME|SND_SYNC|SN D_ASYNC);
> getchar();
>
> [...][/color]

There is no 'PlaySound' function in Standard C++, which is incidentally
the only subject of this newsgroup. Please try a newsgroup for your
platform if it supports playing sound.

Also, as a side note, the directory name separator in Windows is not
the '/' symbol but the '\' symbol, which also needs to be doubled when
put in a string literal. You might want to try

char soundfile2[] = "C:\\Windows\\Media\\pinky and the brain.wav";

V
  #3  
Old August 16th, 2005, 11:55 PM
bballmitch
Guest
 
Posts: n/a
Default Re: Playsound Function

you want to bet there's no playsound function? i know for a fact there
is cause i've used it. but it won't work in an OpenGL file, only
console application. i need help, so don't talk about what you don't
know. those three lines EXACTLY work in Dev C++ console application.

  #4  
Old August 17th, 2005, 12:15 AM
Alf P. Steinbach
Guest
 
Posts: n/a
Default Re: Playsound Function

* bballmitch:[color=blue]
> you want to bet there's no playsound function? i know for a fact there
> is cause i've used it. but it won't work in an OpenGL file, only
> console application. i need help, so don't talk about what you don't
> know. those three lines EXACTLY work in Dev C++ console application.[/color]

As we all know it's september.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
  #5  
Old August 17th, 2005, 12:25 AM
Andre Kostur
Guest
 
Posts: n/a
Default Re: Playsound Function

"bballmitch" <lubanfamily@sbcglobal.net> wrote in
news:1124232331.661988.74390@g49g2000cwa.googlegro ups.com:
[color=blue]
> you want to bet there's no playsound function? i know for a fact there
> is cause i've used it. but it won't work in an OpenGL file, only
> console application. i need help, so don't talk about what you don't
> know. those three lines EXACTLY work in Dev C++ console application.[/color]

Yep. I will bet you that there is no playsound (or PlaySound) function
defined in Standard C++. This is comp.lang.c++, where the topic is
Standard C++. You're talking about some 3rd party library. You're much
better off asking in a newsgroup specific to the library and/or platform
that you are using.
  #6  
Old August 17th, 2005, 12:25 AM
Default User
Guest
 
Posts: n/a
Default Re: Playsound Function

bballmitch wrote:
[color=blue]
> you want to bet there's no playsound function? i know for a fact there
> is cause i've used it. but it won't work in an OpenGL file, only
> console application. i need help, so don't talk about what you don't
> know. those three lines EXACTLY work in Dev C++ console application.[/color]

*plonk*



Brian
  #7  
Old August 17th, 2005, 09:45 AM
bballmitch
Guest
 
Posts: n/a
Default Re: Playsound Function

I'll bet you MY LIFE there is. just type "playsound function in C++"
into google and watch like 10 links to information stating that the
playsound function is used in C++.

  #8  
Old August 17th, 2005, 09:55 AM
Nikos Chantziaras
Guest
 
Posts: n/a
Default Re: Playsound Function

bballmitch wrote:[color=blue]
> I'll bet you MY LIFE there is. just type "playsound function in C++"
> into google and watch like 10 links to information stating that the
> playsound function is used in C++.[/color]

YES, there IS such a function! Look up its usage in the documentation.
If it still won't work, make sure your loudspeakers are turned on, and
pluged in. If there's still no sound, by a new soundcard. If that
won't help either, try Pascal instead of C++; it has a more compatible
playsound function (supports DirectX, Paula chip, and other stuff).
  #9  
Old August 17th, 2005, 11:45 AM
Rein Anders Apeland
Guest
 
Posts: n/a
Default Re: Playsound Function

On Tue, 2005-08-16 at 15:45 -0700, bballmitch wrote:[color=blue]
> you want to bet there's no playsound function? i know for a fact there
> is cause i've used it. but it won't work in an OpenGL file, only
> console application. i need help, so don't talk about what you don't
> know. those three lines EXACTLY work in Dev C++ console application.[/color]

So, if I happen to make my own little collection of
functions for my own private robot project and name
one of the functions 'StartRightWheel', then that
function is automatically part of the C++ standard?

Note that I _am_ able to use it...

I am willing to bet that there is _no_ function called
'StartRightWheel' in the C++ standard.

--
Mvh / Regards
Rein Anders Apeland

  #10  
Old August 17th, 2005, 12:35 PM
Gernot Frisch
Guest
 
Posts: n/a
Default Re: Playsound Function

[color=blue]
> I'll bet you MY LIFE there is.[/color]

OK. I'll come get it ;)
BTW: Don't cross post (especially not to c.l.c++ and c.g.a.opengl for
a question that is related to comp.os.ms-windows.programmer.win32

-Gernot


  #11  
Old August 17th, 2005, 12:35 PM
Richard Herring
Guest
 
Posts: n/a
Default Re: Playsound Function

In message <fEqMe.30125$Tf5.20403@newsread1.mlpsca01.us.to.ve rio.net>,
Victor Bazarov <v.Abazarov@comAcast.net> writes[color=blue]
>Also, as a side note, the directory name separator in Windows is not
>the '/' symbol but the '\' symbol,[/color]

Only for the command-line interface. Everywhere else the '/' works fine.

To maintain marginal on-topicality, the following will work (provided
the named file actually exists ;-) in a Windows environment:

#include <istream>
#include <fstream>
int main()
{
std::ifstream s("C:/Windows/Media/pinky and the brain.wav");
// do something with s
}



--
Richard Herring
  #12  
Old August 17th, 2005, 07:05 PM
bballmitch
Guest
 
Posts: n/a
Default Re: Playsound Function

its not that its not playing sound, it won't compile. :(

  #13  
Old August 17th, 2005, 08:15 PM
Josh Mcfarlane
Guest
 
Posts: n/a
Default Re: Playsound Function

bballmitch wrote:[color=blue]
> its not that its not playing sound, it won't compile. :([/color]

Which is probably because you are using the 3rd-party function without
including the constants that it defines. Now, as stated earlier, you
have two options for troubleshooting this:

A. Go to a newsgroup that discusses it (NOT the C++ newsgroup which
only deals with C++ and STL, which PlaySound is part of.)

B. Look at the documentation for how to use the function, or the result
of the google searches that you gave up your life for.

  #14  
Old August 17th, 2005, 08:25 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: Playsound Function

Josh Mcfarlane wrote:[color=blue]
> [...]
> A. Go to a newsgroup that discusses it (NOT the C++ newsgroup which
> only deals with C++ and STL, which PlaySound is part of.)[/color]

Should probably be "which PlaySound isn't part of"...
[color=blue]
> [..][/color]
  #15  
Old August 17th, 2005, 09:15 PM
Josh Mcfarlane
Guest
 
Posts: n/a
Default Re: Playsound Function

Victor Bazarov wrote:[color=blue]
> Should probably be "which PlaySound isn't part of"...[/color]

Doh! Typo for the win. Indeed that n't is the most important part.

  #16  
Old August 17th, 2005, 10:55 PM
bballmitch
Guest
 
Posts: n/a
Default Re: Playsound Function

thank you, just one question though.......what do you mean do
something with s? suppose i just want it to play that song, what do i
put? that compiles but it wont' play(and im playing music on my
computer right now, so its not my computer). if you could just tell me
what to put in that "do something" line, i'll be set. thanks.

  #17  
Old August 17th, 2005, 11:05 PM
Josh Mcfarlane
Guest
 
Posts: n/a
Default Re: Playsound Function

bballmitch wrote:[color=blue]
> thank you, just one question though.......what do you mean do
> something with s? suppose i just want it to play that song, what do i
> put? that compiles but it wont' play(and im playing music on my
> computer right now, so its not my computer). if you could just tell me
> what to put in that "do something" line, i'll be set. thanks.[/color]

The C++ Library does not even require your computer to have a monitor,
much less speakers.

What you do with s is dependant upon your 3rd-party library, which is
what we've been trying to tell you. In order to find out what to do
with s, you will have to refer to another newsgroup dealing with your
function or it's documentation.

  #18  
Old August 17th, 2005, 11:15 PM
bballmitch
Guest
 
Posts: n/a
Default Re: Playsound Function

in C++ what would you do?

  #19  
Old August 17th, 2005, 11:25 PM
David Rasmussen
Guest
 
Posts: n/a
Default Re: Playsound Function

bballmitch wrote:[color=blue]
> in C++ what would you do?
>[/color]

Use a third-party library, since C++ itself or its standard library
doesn't deal with sound.

/David
  #20  
Old August 29th, 2005, 07:25 PM
Kevin Handy
Guest
 
Posts: n/a
Default Re: Playsound Function

bballmitch wrote:[color=blue]
> in C++ what would you do?
>[/color]

I believe that "\a" is defined in the standard.

You can just wrap the code to decode the stream around
sleep's and 'std::cout << "\a";' to approximate your
audio stream.

Let us know how it works out.

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles