C++ music

I was wondering how I could make music on code blocks. I've never anything like this before so I don't know what I have to do.
make music

What do you mean by make music?

Do you want to play an audio file?
(like WinAmp
http://www.winamp.com/
or Amarok
http://amarok.kde.org/ )

Do you want to compose a score?
(like Sibelius
http://www.sibelius.com
or MuseScore
http://musescore.org/ )

Do you want your keyboard to act like a musical keyboard? (Or even plug a real keyboard in?)
(like Virtual MIDI Piano Keyboard
http://sourceforge.net/projects/vmpk/ )

Or??

Andy
Last edited on
closed account (1v5E3TCk)
i understand adding background themes to programs S:
I want to put a music file on code blocks somehow so it can play in the background of my program.
You need to use some sort of multimedia library in that case.

There are a number of cross-platform libraries including OpenAL, SFML, and FMOD. See links below for further information/search this site (and the web) for opinions.

If you're running on Windows, you also have the old WINMM API (which is the easiest to use of the Windows API's.) Plus DirectShow, Media Foundation, and XAudio (the successor to DirectSound and XAudio.) With the WINMM API you can play a background file using either the PlaySound() function or the mciSendString function.

Andy

OpenAL
http://connect.creativelabs.com/openal/default.aspx

Playing sound using OpenAL
http://www.david-amador.com/2011/06/playing-sound-using-openal/

Simple and Fast Multimedia Library
http://www.sfml-dev.org/

Playing sounds and musics
http://www.sfml-dev.org/tutorials/2.0/audio-sounds.php

FMOD
http://www.fmod.org/

A Quick Guide to FMOD
http://www.gamedev.net/page/resources/_/technical/game-programming/a-quick-guide-to-fmod-r2098

PlaySound function
http://msdn.microsoft.com/en-us/library/windows/desktop/dd743680%28v=vs.85%29.aspx

The example from the MSDN pretty much does the job; you just need to add the SND_ASYNC flag so the call doesn't block.

PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME | SND_ASYNC);

(to stop the sound, call again with NULL instead of the filename.

mciSendString function
http://msdn.microsoft.com/en-us/library/windows/desktop/dd757161%28v=vs.85%29.aspx

This is more involved; you send MCI commands (as string) to WINMM

See here for the basics:
Looping sound with mciSendString
http://www.cplusplus.com/forum/beginner/77462/

and here:
Using MCI to control multimedia
http://www.codeproject.com/Articles/6073/Using-MCI-to-control-multimedia
Last edited on
closed account (G309216C)
Wow, Andywestken!

It also provided me with useful information, many thanks from me.

To be honest what Andy posted, pretty much has everything covered therefore I suggest you looking into the following links and such.

GL
Topic archived. No new replies allowed.