Sound programing

This is a discussion on Sound programing within the C++ Programming forums, part of the General Programming Boards category; Does anyone know off the top of head if sound programming in games is difficult, say a game like final ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479

    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

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379
    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++.

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    20
    Eh, not to pretend to know anything, but isn't DirectSound a part of DirectX, thereby "native" to Windows?

  4. #4
    Interested Newbie
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    51
    Look up FMOD?

  5. #5
    -JM
    -JM is offline
    Registered Usurer
    Join Date
    Apr 2005
    Location
    upstate NY
    Posts
    79
    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;}

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    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!! )

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    31
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sound lags in multi-thread version
    By VirtualAce in forum Game Programming
    Replies: 23
    Last Post: 08-27-2008, 11:54 AM
  2. Low latency sound effects
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 12-21-2004, 12:58 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 11:38 AM
  4. DirectSound - multiple sounds
    By Magos in forum Game Programming
    Replies: 9
    Last Post: 03-03-2004, 03:33 PM
  5. sounds?
    By BODYBUILDNERD in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2002, 02:34 PM

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