2

在使用 FMOD 的共振音频插件并尝试在没有 FMOD Studio 的情况下手动设置 DSP 时,我正在努力启用共振音频声音空间化。

我的插件加载和 DSP 设置代码:

auto system = audio->fmod->system; //instance of FMOD::System
unsigned int resHandle;
CHECK_ERR(system->loadPlugin("../lib/resonanceaudio.dll", &resHandle, 0));

//0 = Resonance Audio Listener
//1 = Resonance Audio Soundfield
//2 = Resonance Audio Source
unsigned int listenerPlugin, sourcePlugin;
system->getNestedPlugin(resHandle, 0, &listenerPlugin);
system->getNestedPlugin(resHandle, 2, &sourcePlugin);

FMOD::DSP* listenerDsp;
CHECK_ERR(system->createDSPByPlugin(listenerPlugin, &listenerDsp));
FMOD::DSP* sourceDsp;
CHECK_ERR(system->createDSPByPlugin(sourcePlugin, &sourceDsp));

//This a channel group routed from the Master group
//I want to spatialize all sounds which are played in this group
FMOD::ChannelGroup *worldGroup = nullptr;
system->createChannelGroup("World", &worldGroup);
FMOD::ChannelGroup *masterGroup = nullptr;
system->getMasterChannelGroup(&masterGroup);
masterGroup->addGroup(worldGroup);

//Adding Resonance Audio dsps to the group
worldGroup->addDsp(0, sourceDsp);
worldGroup->addDsp(1, listenerDsp);

//Setting listener's position at (0, 0, 0)
system->set3DListenerAttributes(0, FMOD_VECTOR{0, 0, 0}, 0, FMOD_VECTOR{0, 0, 1}, FMOD_VECTOR{0, 1, 0});

<loading sound> 

FMOD::Channel* channel = nullptr;
CHECK_ERR(system->playSound(sound, worldGroup, true, &channel));
channel->setMode(FMOD_3D);
channel->set3DAttributes(FMOD_VECTOR{4, 0, 3}, nullptr);
channel->setPaused(false);

<somewhere in update loop>
   system->update();

但在这一切之后,我根本听不到任何声音。

我认为错误在我这边,所以我尝试在 FMOD Studio 中重复相同的设置。正如我在代码中所做的那样,我将 Resonance Audio Source 放置在事件主音轨的 Resonance Audio Listener 之前,并且一切正常(至少在 FMOD Studio 中,没有在游戏中尝试过)。

我该如何解决这个问题?

4

1 回答 1

0

从我认为你应该打电话给:

System::getMasterChannelGroup

获取主通道组的实例,然后将 Resonance 音频 DSP 分配给主通道组。

//This a channel group routed from the Master group
//I want to spatialize all sounds which are played in this group
FMOD::ChannelGroup *worldGroup>;
<worldGroup setup>

从这里我不完全确定你的意思,因为我看不到你在哪里设置了主通道的 ChannelGroup 路由。如果我提供的解决方案不正确,请进一步了解我上面提到的代码。

于 2018-06-11T12:54:25.637 回答