Fmod默认的是(指数衰减),怎么设置线性衰减?

大佬们,请教一个问题啊,fmod默认的是(指数衰减),怎么设置线性衰减?setMode(FMOD_3D_LINEARROLLOFF);好像没有效果
QQ:115452661

What version of FMOD are you using? Sound::setMode(FMOD_3D_LINEARROLLOFF) should result in linear decay. If you do not hear a difference, try setting a lower maximum distance using Sound::set3DMinMaxDistance and see if that makes the effect more noticeable.

jeff_fmod你好,可以留一个联系方式吗?FMOD是最新版本, 线性衰减调试总是不起作用

代码我复制上面了。

jeff_fmod你好,fmode = FMOD_3D_LINEARROLLOFF ;默认为线性,还是不好使
int PLAudio::play(std::string soundPath, std::string mode, std::string groupName, bool isLoop) {
std::shared_ptr s(new Source());
FMOD_MODE fmode = FMOD_DEFAULT;
FMOD::ChannelGroup* cGroup = nullptr;
FMOD_RESULT r = FMOD_OK;
if (mode == “3d” || mode == “2d”){
fmode = FMOD_3D_LINEARROLLOFF ;
LOGI("-c+±PLAudio play1111");
}else if (mode == “music”){
fmode = FMOD_DEFAULT;
LOGI("-c+±PLAudio play222");
}
#ifdef COCOS2DX
unsigned char* data = 0;
ssize_t len = 0;
//data = CCFileUtils::sharedFileUtils()->getFileData(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(soundName.c_str()), “r”, &len);
data = cocos2d::FileUtils::getInstance()->getFileData(cocos2d::FileUtils::getInstance()->fullPathForFilename(soundPath.c_str()), “r”, &len);
FMOD_CREATESOUNDEXINFO exinfo;
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.length = len;
LOGI("-c+±PLAudio play2");
r = _fmodSys->createStream((const char*)data, FMOD_OPENMEMORY | fmode, &exinfo, &s->s);
#else
LOGI("-c+±PLAudio play3");
r = _fmodSys->createStream(soundPath.c_str(), fmode, 0, &s->s);
#endif

if (r != FMOD_OK)
	return 0;
s->mode = mode;
_sources[_id] = s;

if (groupName != "") {
	FMOD::ChannelGroup* masterGroup;
	_fmodSys->createChannelGroup(groupName.c_str(), &cGroup);
	_fmodSys->getMasterChannelGroup(&masterGroup);
	masterGroup->addGroup(cGroup);
	_channelGroups[groupName] = cGroup;
}
else
	_fmodSys->getMasterChannelGroup(&cGroup);

if (isLoop)
	s->s->setMode(FMOD_LOOP_NORMAL);
_fmodSys->playSound(s->s, 0, true, &s->c);
s->c->setChannelGroup(cGroup);
s->c->setPaused(false);
onUpdate();

return this->_id++;

}

jeff_fmod:请教一下,先设置setMode(FMOD_3D_LINEARROLLOFF),还是先设置 [ Sound::set3DMinMaxDistance ]

Calling the functions in a different order should not change the outcome.

I suggest you try running the FMOD 3d example with the following changes around line number 40;

    /*
        Load some sounds
    */
    result = system->createSound(Common_MediaPath("drumloop.wav"), FMOD_3D, 0, &sound1);
    ERRCHECK(result);
    result = sound1->set3DMinMaxDistance(0.5f * DISTANCEFACTOR, 20.0f * DISTANCEFACTOR); // 1. Set a lower max distance
    ERRCHECK(result);
    result = sound1->setMode(FMOD_LOOP_NORMAL | FMOD_3D_LINEARROLLOFF); // 2. Set mode to Linear Rolloff
    ERRCHECK(result);

That way you can hear the difference between linear and exponential roll off, and then apply it to your own project.

...
	s->s->set3DMinMaxDistance(0.5f, 20.0f);  // 1. Set a lower max distance
	if (isLoop)
		s->s->setMode(FMOD_LOOP_NORMAL | FMOD_3D_LINEARROLLOFF); // 2. Set mode to Linear Roll off

	_fmodSys->playSound(s->s, 0, true, &s->c);
	s->c->setChannelGroup(cGroup);
	s->c->setPaused(false);
	onUpdate();
...