I can play sounds?:O
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??
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)
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
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
well if you just wanna play a little beep in C++ use the escape character "\a".
This will give u a nice little beep.
cout << "\a";
This will give u a nice little beep.
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.
He/she is actual serious hahaha I literally just tried it out and it works!!!!! Wow, I would never have thought that!!
[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 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
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement