music in video games

This is a discussion on music in video games within the Game Programming forums, part of the General Programming Boards category; Hi, I'm currently developing a video game with my group from school. I'm a musician and a coder, so I ...

  1. #1
    C Seņor
    Guest

    Talking music in video games

    Hi, I'm currently developing a video game with my group from school. I'm a musician and a coder, so I am in charge of music and sound FX. I produce my music in WAV though and because of the size of WAV files, this is a problem. I've noticed many PC games with high-quality music and the files seem to be compressed, down to as low as the file size for an mp3.

    So how can I compress my WAV files so the WAV files are not 10x the size of the actual program?

    Thanks a lot,
    Brian

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    Get a program to convert them to mp3's then find some kind of mp3 library for whatever compiler your using (libamp for djgpp/allegro I think). I think you can convert them using that sound recorder utility in windows 98/95, I dont think it is as good in xp but I might be wrong.
    Acos is good

  3. #3
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220

    Re: music in video games

    Compression is complicated, there are probably some libraries to do it for you, and there are libraries that can do mp3 formats for you as well.

    If you want to learn how to compress something, go to http://www.howstuffworks.com/file-compression.htm . It won't give you any code, but it will give you the basic ideas.




    Originally posted by C Seņor

    Thanks a lot,
    Brian
    Wow, my name used to be Brian

  4. #4
    C Seņor
    Guest
    Wow, thanks for the quick responses! I can use LAME (which is a great mp3 encoder) to encode the WAVs to MP3 no problem. And we're currently using CDX to develop the game, do you guys know of any support within CDX for MP3 playback? And if it doesn't does allegro or djgpp support it? I'll look around for other libraries that support it...

    Thanks again,
    Brian

  5. #5
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    I don't think allegro/djgpp supports it, they only support wav and some other format that I can't remember.

  6. #6
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    Typical .wav files are 16 bit 44.1k stereo samples (about 10MB per min). That's way more information than you probably need for your game. Before you look into a heavy compression scheme you might try recording in mono. Maintains the same quality but you lose left and right separation. That cuts the filesize in half (and you probably don't really need stereo sound). You might also reduce the sampling to 8 bit (reducing the size again by half, but that loses a large amount of quality). Then most game music is looped so it's not incredibly long.
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

  7. #7
    C Seņor
    Guest
    taylorguitarman, yeah I wasn't going to put stereo 16 bit 44.1 KHz files in with the game...But making mono wav's will only cut the size by about half...so 5 MB a min. or so.

    I noticed on the Tony Hawk Pro Skater 2 cd, and I'm sure 3 is the same, that they had a full soundtrack of music from different bands. 15+ full-length songs but all compressed to about 3-5 MB. The tracks I want to put on the game will loop and won't be larger than 2 or 3 minutes...I also remember that the file extensions were not .wav. Perhaps a similar compression algorithm is available - does anyone know?

    I also thought of just going the cheap and easy route and just use MIDI or MOD...but there's some big problems with this...

    1. They sound cheesy

    2. I've never written a MIDI song or MOD song, so I have no experience with them other than hearing them.

    So wav's are my best bet......

  8. #8
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    well, about that, it just depends on how well you use the midi's capabilities... after that it just depends on the patches you use, and aside from that it's all you anyway. it may take more time to get the right ambience you'd get more easily with using a directly sampled method, but just look at the midi's from final fantasy 7 or 8... and you'll see what i mean... again do what is most practical... [i'm a musician too. ]
    hasafraggin shizigishin oppashigger...

  9. #9
    Registered User
    Join Date
    Feb 2002
    Posts
    145
    If you want small files try using the .XM extension. I am not at all sure how to write to these sort of files, but I have seen 5 minute songs that at around 300kb. Most of the ones I have downloaded have been sort of like MIDI (mostly trance type music) and so I do not know if this would work for you. Try the site below for some fantasy .XMs if you want.

    http://www.traxinspace.com/Music/Sea...=Style&Param=7

    (If the link doesn't work or whatever, just go to http://www.traxinspace.com and search through Music Genres to Fantasy Songs).

    Hope this helps.


    Kyoto Oshiro

  10. #10
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Personally I think that AC3's are the highest quality music files I've ever heard. But, since there is not much info on them, except from Creative's website, it will probably only work on one series of cards which is not good for games.

    Second to that, the best music I've heard in games, by far, is not MP3 or some other compressed music file, but audio tracks. I love games that play audio tracks right off of the CD. It sounds the best and the audio tracks are there on the CD for you to use, so why not?

    Limitations, though, include only being able to put a set number of songs on the CD (I usually kill the music eventually in all my games anyways - it's usually terrible). The best soundtracks I've heard have been the one for Outlaws, the old LucasArts game, and the one for No One Lives Forever. I've played a lot of games and those by far stick out in my mind. Outlaws uses audio tracks and I'm not sure what No One Lives Forever uses, but it does have an audio CD with it.

    As far as sound samples go, compress them into one file using a compression scheme. Then extract the necessary sounds from the file at load time. That way all the sounds are sitting in memory just waiting to be mixed and played. You would just access them via pointers. If you are in protected mode, this will not be hard to do since memory is near limitless and most have at least 256 MB of RAM on their systems. If you are in real mode, then you should probably use XMS or even EMS - I recommend EMS cause it's faster/easier, but XMS does do some nice things, too. If you know some assembly, using XMS and EMS is very easy. Also if you are not using Allegro, MIDAS, or some other sound system, it will be very easy to do in DJGPP using assembly.
    The only major problem I could see is that you have to go through the DPMI server to use the DMA, since the DMA cannot work with memory over 1MB. You will also have to figure out how to handle hardware interrupts in DJGPP.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Violent video games?
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 58
    Last Post: 04-26-2006, 01:43 PM
  2. What are the best video games youve played??
    By jessie23 in forum A Brief History of Cprogramming.com
    Replies: 45
    Last Post: 01-17-2003, 10:59 AM
  3. Video Games Industry. 5 years left.
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 12-10-2002, 09:52 PM
  4. video games
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 05-29-2002, 04:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21