【问题标题】:FMOD I dont hear soundFMOD 我听不到声音
【发布时间】:2014-09-08 17:30:28
【问题描述】:

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

声音引擎,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 方法中,但它不起作用。

【问题讨论】:

    标签: c++ ubuntu fmod


    【解决方案1】:

    问题将是以下行

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

    倒数第二个参数是'paused',正在设置为1(或true),设置为false。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多