I am struggling to enable Resonance Audio sound spatialization when using Resonance Audio plugin for FMOD and trying to setup DSPs manually, without FMOD Studio.
My code for plugin loading and DSPs’ setup:
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(FMOD_CHANNELCONTROL_DSP_TAIL, sourceDsp);
worldGroup->addDsp(FMOD_CHANNELCONTROL_DSP_TAIL, 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();
But after all of this I cant hear anything, audio just isnt playing. I also noticed that if I setup reverb sends for channel I will be able to hear the reverb, but not the audio itself.
What I am doing incorrectly and how can I fix this issue?