-
Sound programing
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;}
-
MIDI link
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:
Code:
HMIDIOUT handle;
/* Open default MIDI Out device */
if (!midiOutOpen(&handle, (UINT)-1, 0, 0, CALLBACK_NULL) )
{
/* Output the C note (ie, sound the note) */
midiOutShortMsg(handle, 0x00403C90);
/* Output the E note */
midiOutShortMsg(handle, 0x00404090);
/* Output the G note */
midiOutShortMsg(handle, 0x00404390);
/* Here you should insert a delay so that you can hear the notes sounding */
Sleep(1000);
/* Now let's turn off those 3 notes */
midiOutShortMsg(handle, 0x00003C90);
midiOutShortMsg(handle, 0x00004090);
midiOutShortMsg(handle, 0x00004390);
/* Close the MIDI device */
midiOutClose(handle);
}
Of course for the ultimate resource, there's MSDN. (The ultimate hard-to-navigate web site too!! :D )
-
I prefer FMOD, it's pretty easy to use. And it's free if you're not selling your program.
www.fmod.org
Code:
FSOUND_Init( 32000, 64, 0 );
FMUSIC_MODULE midi = FMUSIC_LoadSong( "song.midi" );
FMUSIC_PlaySong( midi );
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.