Does anyone know off the top of head if sound programming in games is difficult, say a game like final fantasy that has loads of really amazing tunes, I am intrested to learn it one day when I get better at C++, although I do not know if sound for games is written in C++, could be C or java
Sound is done the same way everything else is. With an API. Some good APIs are DirectSound, FMOD and OpenAL. I think DirectSound is native to C++ but the others can be used with C/C++.
Eh, not to pretend to know anything, but isn't DirectSound a part of DirectX, thereby "native" to Windows?
Isn't there an easy way to do this with MIDI?
I don't know, just asking (and hoping). I've got Maximum Midi by Messick, but what I haven't seen is the musical equivalent of the "Hello, world!" program. You know - "BOOP" and out, return 0;}
Generally, MIDI is the way to go for games because it puts a minimal load on your CPU & data bus. Your soundcard/soundchip does all of the work.
Here's a great MIDI web site.
The site is hard to navigate, so here's the Windows programing info on the same site, where you will find this:
Of course for the ultimate resource, there's MSDN. (The ultimate hard-to-navigate web site too!! :D )
/* Open default MIDI Out device */
if (!midiOutOpen(&handle, (UINT)-1, 0, 0, CALLBACK_NULL) )
/* Output the C note (ie, sound the note) */
/* Output the E note */
/* Output the G note */
/* Here you should insert a delay so that you can hear the notes sounding */
/* Now let's turn off those 3 notes */
/* Close the MIDI device */
I prefer FMOD, it's pretty easy to use. And it's free if you're not selling your program.
Granted it's been a while since I've used FMOD, I'm pretty sure that'll work. If it doesn't there isn't much modification to that code at least, it's so simple to use FMOD. The hardest part is just managing your audio, and that's not all that hard really.
FSOUND_Init( 32000, 64, 0 );
FMUSIC_MODULE midi = FMUSIC_LoadSong( "song.midi" );
FMUSIC_PlaySong( midi );