FMOD我听不到声音



最后,我能够毫无错误地执行playSound,但现在我听不到声音了。

SoundEngine,h

    #ifndef SOUNDENGINE_H_
#define SOUNDENGINE_H_
#include "FMOD/inc/fmod.hpp" //fmod c++ header
//#include "FMODEX/inc/fmodlinux.h"
class SoundEngine{
public:
    bool initSystem(void);
    void update(void);
private:
    //FMod Stuff
        FMOD_SYSTEM     *system; //handle to FMOD engine
        FMOD_SOUND      *sound1, *sound2; //sound that will be loaded and played
        FMOD_CHANNELGROUP *channels;
};

和SoundEngine.cpp

#include "SoundEngine.h"
#include <iostream>
using namespace std;
FMOD_RESULT result;
bool SoundEngine::initSystem()
{
    result = FMOD_System_Create(&system);
    unsigned int version;
    cout<<result<<endl;
    result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
    cout<<result<<endl;
    cout<<"Sonido"<<endl;
    //load sounds
    result = FMOD_System_CreateSound(system, "Media/NMG.mp3", FMOD_CREATESAMPLE, 0, &sound1);
    cout<<result<<endl;
    result = FMOD_System_CreateChannelGroup(system,"canal",&channels);
    cout<<result<<endl;
    result = FMOD_System_PlaySound(system,  sound1,channels, 1, NULL);
    cout<<result<<endl;
    //FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, )
    //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);
    cout<<"Sonido"<<endl;
    return true;
}

我认为它是正确的,必须播放声音,但我没有听到任何声音(我打开了电脑音量,它可以工作)。我还需要使用其他方法吗?

我还在每帧中使用FMOD_System_Update()。

编辑:我也试着把

while(true) FMOD_System_Update();

在initSystem方法内部,但它不起作用。

问题将是以下行

result = FMOD_System_PlaySound(system,  sound1,channels, 1, NULL);

倒数第二个参数是"paused",它被设置为1(或true),请将其设置为false。

最新更新