Advertisement

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

Started by July 16, 2000 04:15 PM
4 comments, last by supersaiyan 24 years, 5 months ago
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?
KA...ME...HA...ME...HA!!!
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+
Advertisement
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'."
- The Goblin (madgob@aol.com)
isn''t there a beep function that makes an anoying beep at any pitch?

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
I believe the function is

playThisMusicFileInMyGameForMeBecauseIDontHaveTheSlightestIdeaHowToDoItMyselfAndIAmUsingDOSTooIfThatHelps("myMusic.mid");

i think the compiler will know what to do


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Oh damn, i didn''t realize you were using DOS in which case you can''t use any of the methods i purposed.


+AA_970+

This topic is closed to new replies.

Advertisement