我在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。
有人知道他们在哪里吗?
编辑:另一件事是,杂注注释引发警告,告知您忽略杂记。也许问题与实用性有关?我该如何解决编译指示?
最佳答案
我相信FMOD_HARDWARE来自较旧的FMOD Ex API。您正在使用FMOD 5吗?在我对System::createSound的调用中,我使用了FMOD_DEFAULT或FMOD_CREATESAMPLE(后者将加载整个声音并将其解压缩到内存中,以加快播放速度),这似乎很好地使用了硬件。对于您的playSound通话,请尝试
FMOD::Channel *channel;
system->playSound(sound1, NULL, false, &channel);
关于c++ - 找不到Fmod常量(FMOD_HARDWARE),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25723881/