我實際上嘗試播放與FMOD的聲音,但它沒有奏效。FMOD不播放聲音C++
#ifndef __SOUND_HH__
#define __SOUND_HH__
#include <string>
#include <fmodex/fmod.h>
class Sound
{
FMOD_SYSTEM *sys;
FMOD_SOUND *explosion;
FMOD_RESULT resExplosion;
FMOD_CHANNEL *channel1;
public:
Sound();
~Sound();
void play(const std::string &);
};
#endif
和
#include <string>
#include <iostream>
#include "Sound.hh"
Sound::Sound()
{
FMOD_System_Create(&this->sys);
FMOD_System_Init(this->sys, 1, FMOD_INIT_NORMAL, NULL);
}
Sound::~Sound()
{
FMOD_System_Release(sys);
}
但是當我做遊戲( 「mysound.wav」);在我的代碼沒有追加,我驗證返回值,沒有問題。所以有什麼想法?感謝
void Sound::play(const std::string &filename)
{
FMOD_System_CreateStream(this->sys, filename.c_str(), FMOD_HARDWARE | FMOD_LOOP_OFF | FMOD_2D, 0, &this->explosion);
FMOD_System_PlaySound(sys, FMOD_CHANNEL_FREE, explosion, 0 , &channel1);
std::cout << "playayayyayayayayya" << std::endl;
}
你打開/關閉揚聲器了嗎?你有沒有試過通過媒體播放器播放聲音? –
我試着在C中使用FMOD的其他項目,它的工作。我嘗試使用相同的聲音,並始終不工作 – ago
哪裏是您要調用播放功能的代碼? –