gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Just simple background music

#60794 - whitewiz - Mon Nov 14, 2005 10:27 pm

Im a little newbie at coding


But Im coding an app and i want to put some backgroundmusic to it

and whats the easiest way of doing that?

#60795 - keldon - Mon Nov 14, 2005 10:43 pm

there are existing libraries for doing this. but if you want to do this yourself it's basically a case of storing a list of notes and playing them back.

To do this easily every 12 or so VBL's you change to the next note. If you want to further this you can create note lengths

once you've done this you can start to factor in code to have playlists and the like, just get the code for reading your notes from the list first - it's quite easy.

#60799 - tepples - Mon Nov 14, 2005 10:54 pm

But in the playback routine that runs every 10 or so vblanks, you're going to have to play a note. At this stage, you probably don't want to write a mixer and deal with PCM, so you're going to need to learn to deal with the four tone generators inherited from the GBC. I'd suggest reading the guide at belogic.com (if it's still up) and then learning about equal temperament.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#60804 - keldon - Mon Nov 14, 2005 11:32 pm

http://devrs.com/gb/files/sndtab.html

you can get away without knowing about equal temperment, if i can find my trusty gbdk includes i'll post the tunings - they should be the same for gba right?

#60813 - gauauu - Tue Nov 15, 2005 2:25 am

If you want to know the easiest way, you use one of the existing libraries that keldon was talking about.

Krawall is a common one. (there are others, just do a search on the forums or look at the faq). With these, you can often just "play" certain types of music files, by adding a couple function calls, and linking in the library.

#60868 - thegamefreak0134 - Tue Nov 15, 2005 5:52 pm

Although your music may be simple, there's really no simple way to include audio in your game. Krawall is the only system I've evet actually gotten to work, and I can walk you through it if you'd like.
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]