Sign in to follow this  

I can play sounds?:O

This topic is 1988 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[quote name='Saint Squireen' timestamp='1341765031' post='4956954']
I can play sounds in C++? How do I go about doing that? It doesnt matter if its how to play a little beep or a whole entire song but how do you do it??
[/quote]

C++ doesn't support sounds, you need to use your OS API for that (or a third party API that your OS and/or drivers support)

For Windows you have some basic sound support in the Win32 API and better sound support with DirectX or OpenAL (OpenAL is also available on Mac and Linux)

Share this post


Link to post
Share on other sites
The easiest and most straight forward way is to use an external library. I've written my own .wav decoder once and it's rather nightmarish.

Now, which library depends on what exactly you want to do. If you want to analyse streams of bytes as the sound goes then some libraries are better suited for that. If you are simply looking for something that will let you read a specific file format then there's easier stuff you can use.

I'd recommend checking out SDL since it comes with image loading features, threading, sound, etc. It's a nice package that will get you up and running fast. Check this page out : [url="http://lazyfoo.net/SDL_tutorials/lesson11/index.php"]http://lazyfoo.net/SDL_tutorials/lesson11/index.php[/url] Edited by DZee

Share this post


Link to post
Share on other sites
[quote name='frazchaudhry' timestamp='1341775652' post='4956991']
well if you just wanna play a little beep in C++ use the escape character "\a".
[CODE]
cout << "\a";
[/CODE]
This will give u a nice little beep.
[/quote]
You can't possibly be serious.

Share this post


Link to post
Share on other sites
[quote name='Bacterius' timestamp='1341778728' post='4957011']
[quote name='frazchaudhry' timestamp='1341775652' post='4956991']
well if you just wanna play a little beep in C++ use the escape character "\a".
[CODE]
cout << "\a";
[/CODE]
This will give u a nice little beep.
[/quote]
You can't possibly be serious.
[/quote]

try it out then and see for yourself

Share this post


Link to post
Share on other sites
[quote name='frazchaudhry' timestamp='1341782096' post='4957028']
[quote name='Bacterius' timestamp='1341778728' post='4957011']
[quote name='frazchaudhry' timestamp='1341775652' post='4956991']
well if you just wanna play a little beep in C++ use the escape character "\a".
[CODE]
cout << "\a";
[/CODE]
This will give u a nice little beep.
[/quote]
You can't possibly be serious.
[/quote]

try it out then and see for yourself
[/quote]
I wasn't doubting you, I know this console escape produces a beep. It's just that it's hardly flexible enough to do anything resembling a song with it, and the OP is probably better off using actual API's. I didn't mean to offend [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

On topic, if you are interested in playing songs only, you might want to take a look at MIDI synthetizers, they are very nice to produce simple music and it's relatively easy to use. However in terms of simplicity, if you are under Windows, nothing beats the PlaySound function (in MMSystem, iirc) to play wave files, for instance. It's a start, at least. Edited by Bacterius

Share this post


Link to post
Share on other sites
[quote name='Bacterius' timestamp='1341783336' post='4957033']
I wasn't doubting you, I know this console escape produces a beep. It's just that it's hardly flexible enough to do anything resembling a song with it, and the OP is probably better off using actual API's. I didn't mean to offend
[/quote]
No offense taken. You're right there's no way he can make a song out of it. But he did ask for a beep and I was just trying to be a little smart ass :).

Share this post


Link to post
Share on other sites

This topic is 1988 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this