我在Ubuntu中使用FMOD在我的游戏中播放声音。
我有下一个
#include "SoundEngine.h"
bool SoundEngine::initSystem()
{
System_Create(&system);// create an instance of the game engine
system->init(32, FMOD_INIT_NORMAL, 0);// initialise the game engine with 32 channels
//load sounds
system->createSound("Media/NoMoreMagic.ogg", FMOD_HARDWARE, 0, &sound1);
sound1->setMode(FMOD_LOOP_OFF); /* drumloop.wav has embedded loop points which automatically makes looping turn on, */
/* so turn it off here. We could have also just put FMOD_LOOP_OFF in the above CreateSound call. */
system->playSound(FMOD_CHANNEL_FREE, sound1, false, 0);
return true;
}
SoundEngine.h是:
#ifndef SOUNDENGINE_H_
#define SOUNDENGINE_H_
#include "FMOD/inc/fmod.hpp" //fmod c++ header
#pragma comment( lib, "fmodex_vc.lib" ) // fmod library
using namespace FMOD;
class SoundEngine{
public:
bool initSystem(void);
private:
//FMod Stuff
System *system; //handle to FMOD engine
Sound *sound1, *sound2; //sound that will be loaded and played
};
#endif /* SOUNDENGINE_H_ */
问题是找不到FMOD_HARDWARE或FMOD_CHANNEL_FREE。
任何人都知道他们在哪里?
编辑:另一件事是pragma评论抛出一个警告告诉忽略编译指示。也许问题与pragma有关系?我怎样才能解决这个问题?
答案 0 :(得分:1)
我相信FMOD_HARDWARE来自较旧的FMOD Ex API。你在使用FMOD 5吗?在我对System :: createSound的调用中,我使用FMOD_DEFAULT或FMOD_CREATESAMPLE(后者将加载整个声音并将其解压缩到内存中,以加快播放速度),这似乎很好地使用了硬件。对于你的playSound电话,试试
FMOD::Channel *channel;
system->playSound(sound1, NULL, false, &channel);