Playing a song?

For a cheap gift(I have no money right now) I'm programming something for my mom that says I Love You and plays a song. I was wondering how do you play a song using C++?
You'll need an audio library. You might want to check out SDL_mixer. What you need to do can be done with just a couple of calls.
thanks can you get me head start before I start looking around the net.
What, you mean like a link?
http://www.libsdl.org/projects/SDL_mixer/
Yea and thanks
EDIT: Last question you just include the library in the c++ file?
Last edited on
No. You only include the header in the cpp so you and your code can know what functions the library provides.
To actually be able to use the functions, you need to statically link the library. How yo do this will depend on you development environment.
You need to edit the project properties with the libraries includes and libs. And make sure you include the correct .dll files in the project directories. Look up lazy foo's website on how to install the SDL.
what? I'm clues less about header files, and project things. Its been few weeks and only really know coding .cpp file.
Might possibly be a little hard for you to code some sound depending on how exactly you are wanting to do it. Are looking at calling like your speakers for example and placing certain hertz and freq or w/e. Or do you have like a mp3 or something you want a program to load up?
Mp3 file to play nothing really fancy
EDIT:for example the song Deck the Halls
Last edited on
I know an alternative way. Convert the mp3 into a wave file and use PlaySound() function.. Here is a sample code.

1
2
3
4
5
6
#include<windows.h>

void main()
{
       PlaySound(TEXT("i_love_you.wav"), NULL, SND_FILENAME);
}


You need to link 'winm.lib' to your .cpp file. Just browse around with your project options (or properties) till you find an option of linking libraries.
Last edited on
thanks
Topic archived. No new replies allowed.