2

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(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();

But after all of this I dont hear any audio at all.

I assume the mistake is on my side so I tried to repeat the same setup in FMOD Studio. As I did in code I placed Resonance Audio Source before the Resonance Audio Listener at the master track of the event and everything worked correctly (at least in FMOD Studio, didnt try it in game).

How can I fix this issue?

Daniil Dubrovsky
  • 459
  • 7
  • 17

1 Answers1

0

From what I think you should be calling:

System::getMasterChannelGroup

To get an instance of the master channel group and then assigning the Resonance audio DSPs to the master channel group.

//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>

From this I was not entirely sure what you meant as I cannot see where you have setup the ChannelGroup routing from the master channel. If the solution I have provided is incorrect, then please provide further insight into the code I have mentioned above.

WoodyDev
  • 1,386
  • 1
  • 9
  • 19
  • I updated the code to show how worldGroup is setup. I also tried to add Resonance Audio dsps directly to Master group but it didnt work, unfortunately. The result stayed the same. – Daniil Dubrovsky Jun 11 '18 at 14:00
  • What exactly was the error message when adding DSPs directly to the Master group? – WoodyDev Jun 11 '18 at 15:05
  • When I add Source DSP at index 0 and Listener DSP at index 1 the channel which is played on the Master group just becomes inaudiable, I cant hear anything. However all function calls return FMOD_OK so there is no error message – Daniil Dubrovsky Jun 11 '18 at 15:13
  • In regards to the sound being cut out when you add it to the master group, I believe you are affecting the main channel fader/mixer when you overwrite index 1 [according to the FMOD docs](https://www.fmod.com/docs/api/content/generated/FMOD_CHANNELCONTROL_DSP_INDEX.html). So maybe its worth adding your DSPs to indexes 2,3? – WoodyDev Jun 12 '18 at 07:22
  • I tried to use FMOD_CHANNELCONTROL_DSP_TAIL when specifying index for a dsp and also tried to put dsp in indexes 2,3, in both cases it resulted in complete lack of audio – Daniil Dubrovsky Jun 15 '18 at 19:21