[英]Fmod Stream use to work
here is my problem. 这是我的问题。 I am trying to set up a stream to play in my program.
我正在尝试设置要在程序中播放的流。 It worked well once, then I changed the name of my class and now it does not work anymore and I get error 30 from the result.
它曾经很好地工作过,然后我更改了班级的名称,但现在它不再工作了,结果中出现错误30。 I cannot find any explanations on why it worked before and now it does not.
我找不到关于它为什么起作用的任何解释,而现在却没有。 Here is my SoundStream.h
这是我的SoundStream.h
#include "fmod.hpp"
#include "common.h"
#include <iostream>
class SoundStream
{
public:
FMOD::System *system,*sys;
FMOD::Sound *sound, *sound_to_play;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
void startStream()
{
result = system->init(32, FMOD_INIT_NORMAL, 0);
std::cout << result << std::endl;
result = system->createStream("singing.wav", FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);
std::cout << result << std::endl;
sound_to_play = sound;
result = system->playSound(sound_to_play, 0, false, &channel);
std::cout << result << std::endl;
std::cout << "Working" << std::endl;
}
};
Created it like this in my other function: 在我的其他函数中这样创建它:
SoundStream soundStream;
soundStream.startStream();
Everything is linked correctly. 一切都正确链接。
Thanks 谢谢
It seems like you're not creating the System object: 似乎您没有在创建System对象:
System_Create(&system);
Also the arguments you're passing to System::playSound are not valid (I'm using FMOD 4.44.58-1). 另外,您传递给System :: playSound的参数无效(我正在使用FMOD 4.44.58-1)。
Here is a working example: 这是一个工作示例:
#include "fmod.hpp"
class SoundStream
{
public:
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel;
void startStream()
{
System_Create(&system);
system->init(32, FMOD_INIT_NORMAL, 0);
system->createStream("singing.wav", FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);
system->playSound(FMOD_CHANNEL_REUSE, sound, false, &channel);
}
};
int main(int argc, char** argv)
{
SoundStream soundStream;
soundStream.startStream();
while(true) {} // ctrl + c to exit
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.