Jump to content
  • Advertisement
Sign in to follow this  
Saint Squireen

I can play sounds?:O

This topic is 2290 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

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??

Share this post


Link to post
Share on other sites
Advertisement

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??


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 : http://lazyfoo.net/SDL_tutorials/lesson11/index.php Edited by DZee

Share this post


Link to post
Share on other sites
well if you just wanna play a little beep in C++ use the escape character "\a".

cout << "\a";

This will give u a nice little beep.

Share this post


Link to post
Share on other sites

well if you just wanna play a little beep in C++ use the escape character "\a".

cout << "\a";

This will give u a nice little beep.

You can't possibly be serious.

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".

cout << "\a";

This will give u a nice little beep.

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='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".

cout << "\a";

This will give u a nice little beep.

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 smile.png

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!