Archived

This topic is now archived and is closed to further replies.

How do you insert music into a C++ file.

This topic is 6359 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 was going to make a music file,(in C++) like this: #include< /*needed music include file(if one''s needed)*/ > #include int main(); { while(1) { //music commands here } SHORT GetAsyncKeyState(INT vKey) if vk_down break; return 0; I need the command to insert music into the program, and I need the header file(if needed) for music. BTW, would this work?

Share this post


Link to post
Share on other sites
Ok first you have to know that you aren''t making a music file your playing a music file w/ c++. There are a few ways to do this.

1. Use PlaySound, you have to include mmsystem.h and link to winmm.lib. This will play a wave file, look up the command in the docs and you''ll find all the parameters. The downside to this is that it loads the entire sound file in RAM which can be slow and take up alot of space if the file is large, also you cannot mix sfx with the music.

2. Use direct sound, this will allow you to stream (load pieces of the file in memory as it''s played) any sound file and sfx can be mixed. The big downside to this is that you have to write your own loader for the sound file format you choose (some of which are very difficult to load).

3. Use a sound system, download a sound system from the net which will allow you to play many different types of sound files, with mixing and streaming(if necessary, MODs don''t need to be streamed). An example would be FMOD (www.fmod.org). The downside is that you are limited to the features of the system.


+AA_970+

Share this post


Link to post
Share on other sites
I believe Borland also has some commands for playing music notes.

I''d recommend checking it out if that''s what you''re after.

- Goblin
"In order to understand the full depth of mankind, you must first seperate the word into its component parts: 'mank' and 'ind'."

Share this post


Link to post
Share on other sites