fmod简单使用试例

#include 
#include 
#include "fmod.h"

#define FILENAME "wave.mp3"

int main()
{
    FMOD_RESULT fmodResult;
    FMOD_SYSTEM *fmodSystem;
    FMOD_SOUND  *sound;
    FMOD_CHANNEL *channel;

    // create the main FMOD system object
    fmodResult = FMOD_System_Create(&fmodSystem);              
    if (fmodResult != FMOD_OK)
        exit(-1);

    // initialize FMOD
    fmodResult = FMOD_System_Init(fmodSystem, 10, FMOD_INIT_NORMAL, 0);
    if (fmodResult != FMOD_OK)
        exit(-1);

    // load the sound file
    fmodResult = FMOD_System_CreateSound(fmodSystem, FILENAME, FMOD_SOFTWARE, 0, &sound);
    if (fmodResult != FMOD_OK)
        exit(-1);

    // tweak the volume, set some parameters and play the file
    FMOD_Sound_SetMode(sound, FMOD_LOOP_NORMAL);
    fmodResult = FMOD_System_PlaySound(fmodSystem, FMOD_CHANNEL_FREE, sound, 1, &channel);
    FMOD_Channel_SetVolume(channel, 1);
    FMOD_Channel_SetLoopCount(channel, -1);
    FMOD_Channel_SetPaused(channel, 0);

    char cmd;
    while (cmd = getchar())
    {
        switch (cmd)
        {
        case 'q':
            exit(0);

        case '1':
            FMOD_Channel_SetVolume(channel, 0.1);
            break;

        case '5':
            FMOD_Channel_SetVolume(channel, 0.5);
            break;
        }
    }
	
    return 0;
}

你可能感兴趣的:(开发)