# Resonance Audio In UE4

**URL:** <https://qa.fmod.com/t/resonance-audio-in-ue4/15877>\
**Category:** Unreal Engine\
**Tags:** ue4, cpp\
**Created:** [June 11, 2020, 4:12pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877 "2020-06-11T16:12:35Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuwee](https://avatars.discourse-cdn.com/v4/letter/y/9e8a1a/32.png) [@Yuwee](https://qa.fmod.com/u/Yuwee)\
**Post date:** [June 11, 2020, 4:12pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/1 "2020-06-11T16:12:35Z")

</div>

Hello,

I’m trying to setup a project with resonance audio through fmod.

We followed the integration details from [The resonance audio fmod guide](https://resonance-audio.github.io/resonance-audio/develop/fmod/game-engine-integration) and managed to get spatialized audio and occlusion to work through the Resonance Audio Source Plugin and Resonance Audio Listener.

We are struggling to set up the Room Effect tho, even while using the default UE4 Audio Volumes, creating a Room Effect, Setting up the Global Reverb Preset, it does not seem to take the fmod audio into account and we can’t hear any reverb.

We’d like to know how we can use the Acoustic Textures system effectively and expose its values in Blueprints, and make it work with already integrated sounds using the Resonance Audio Sources.

The lack of ressources on this plugin is making everything hard to understand and set up properly.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![tristanjl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tristanjl/32/261_2.png) [@tristanjl](https://qa.fmod.com/u/tristanjl)\
**Post date:** [June 15, 2020, 7:14am UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/2 "2020-06-15T07:14:54Z")

</div>

Hi Yuwee,

The Global Reverb Preset is part of UE4’s support for resonance audio. This is separate to FMOD’s resonance support, and so you will need to work through FMOD to have room properties affect FMOD events. At the bottom of the guide, it mentions setting the room properties via FMOD::DSP::setParameterData, so hopefully that will give you a good starting point.

It will be a similar process to what you would need to do for room properties in unity with resonance. It maight be helpful to cross check with the unity instructions on the same page.

---

<div class="post-metadata">

**Author:** ![ptrefall](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ptrefall/32/2672_2.png) [@ptrefall](https://qa.fmod.com/u/ptrefall)\
**Post date:** [July 3, 2021, 9:32am UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/3 "2021-07-03T09:32:53Z")

</div>

How do we get hold of the right DSP instance to apply this parameter data?

---

<div class="post-metadata">

**Author:** ![tristanjl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tristanjl/32/261_2.png) [@tristanjl](https://qa.fmod.com/u/tristanjl)\
**Post date:** [July 5, 2021, 3:44am UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/4 "2021-07-05T03:44:34Z")

</div>

Hi ptrefall,

We don’t have example code for Unreal. You may want to look at the unity integration in FMODResonanceAudio.cs for more detail. It is written in C#, but you can see what needs to be done, such as finding the dsp by name and how to go about iterating through dsps via channels and busses.

---

<div class="post-metadata">

**Author:** ![ahmadsy](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@ahmadsy](https://qa.fmod.com/u/ahmadsy)\
**Post date:** [September 8, 2021, 10:53am UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/5 "2021-09-08T10:53:34Z")

</div>

Hi! Have you any achieves? I’m so need any information, how to realise it. How to connect it with Audio Volumes in the world and more questions…

---

<div class="post-metadata">

**Author:** ![ptrefall](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ptrefall/32/2672_2.png) [@ptrefall](https://qa.fmod.com/u/ptrefall)\
**Post date:** [September 8, 2021, 12:29pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/6 "2021-09-08T12:29:40Z")

</div>

You have to hook up query collider volumes manually. I got the dsp working by porting parts of the Unity code. We opted out of using resonance audio for reverb when we realised that it forced everything into mono (and we want stereo for first person sounds). So now we’re just using fmod reverb snapshots.

---

<div class="post-metadata">

**Author:** ![ahmadsy](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@ahmadsy](https://qa.fmod.com/u/ahmadsy)\
**Post date:** [September 8, 2021, 1:22pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/7 "2021-09-08T13:22:11Z")

</div>

If you share with me the code (for educational purposes) I’d appreciate it!

---

<div class="post-metadata">

**Author:** ![ptrefall](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ptrefall/32/2672_2.png) [@ptrefall](https://qa.fmod.com/u/ptrefall)\
**Post date:** [September 8, 2021, 4:30pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/8 "2021-09-08T16:30:20Z")

</div>

I can post the dsp code a little later, and some details.

---

<div class="post-metadata">

**Author:** ![ptrefall](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ptrefall/32/2672_2.png) [@ptrefall](https://qa.fmod.com/u/ptrefall)\
**Post date:** [September 8, 2021, 7:24pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/9 "2021-09-08T19:24:26Z")

</div>

```auto
// https://github.com/resonance-audio/resonance-audio-fmod-sdk/blob/master/UnityIntegration/Assets/ResonanceAudio/Scripts/FmodResonanceAudio.cs
FMOD::DSP* UAudioSubsystem::InitializeDsp()
{
	FMOD::Studio::System* System = IFMODStudioModule::Get().GetStudioSystem(EFMODSystemContext::Runtime);
	if (System == nullptr)
	{
		LOG(this, LogAudio, Warning, TEXT("Failed to initialize DSP"));
		return nullptr;
	}

	int NumBanks = 0;
	FMOD_RESULT Result = System->getBankCount(&NumBanks);
	if (Result > FMOD_OK)
	{
		LOG(this, LogAudio, Warning, TEXT("Failed to initialize DSP"));
		return nullptr;
	}

	const TSharedPtr<FMOD::Studio::Bank*> Banks(new FMOD::Studio::Bank*[NumBanks]);
	Result = System->getBankList(Banks.Get(), NumBanks, &NumBanks);
	if (Result > FMOD_OK)
	{
		LOG(this, LogAudio, Warning, TEXT("Failed to initialize DSP"));
		return nullptr;
	}

	for (int i = 0; i < NumBanks; i++)
	{
		FMOD::Studio::Bank* CurrentBank = Banks.Get()[i];

		int NumBuses = 0;
		Result = CurrentBank->getBusCount(&NumBuses);
		if (Result > FMOD_OK)
		{
			continue;
		}

		const TSharedPtr<FMOD::Studio::Bus*> Buses(new FMOD::Studio::Bus*[NumBuses]);
		Result = CurrentBank->getBusList(Buses.Get(), NumBuses, &NumBuses);
		if (Result > FMOD_OK)
		{
			continue;
		}

		System->flushCommands();

		for (int j = 0; j < NumBuses; j++)
		{
			FMOD::Studio::Bus* CurrentBus = Buses.Get()[j];
			const TSharedPtr<char> Path(new char[128]);
			int PathLength = 0;
			Result = CurrentBus->getPath(Path.Get(), 128, &PathLength);
			if (Result > FMOD_OK)
			{
				continue;
			}

			System->getBus(Path.Get(), &CurrentBus);
			System->flushCommands();

			const TSharedPtr<FMOD::ChannelGroup*> Group(new FMOD::ChannelGroup*[1]);
			Result = CurrentBus->getChannelGroup(Group.Get());
			if (Result > FMOD_OK)
			{
				continue;
			}

			System->flushCommands();

			if (Group.Get()[0] != nullptr)
			{
				FMOD::ChannelGroup* CurrentGroup = Group.Get()[0];
				int NumDsp = 0;
				Result = CurrentGroup->getNumDSPs(&NumDsp);
				if (Result > FMOD_OK)
				{
					continue;
				}

				const TSharedPtr<FMOD::DSP*> Dsp(new FMOD::DSP*[1]);
				for (int k = 0; k < NumDsp; k++)
				{
					Result = CurrentGroup->getDSP(k, Dsp.Get());
					if (Result > FMOD_OK)
					{
						continue;
					}
					
					FMOD::DSP* CurrentDsp = Dsp.Get()[0];
					const TSharedPtr<char> DspName(new char[128]);
					int UnusedInt = 0;
					unsigned UnusedUint = 0;
					
					Result = CurrentDsp->getInfo(DspName.Get(), &UnusedUint, &UnusedInt, &UnusedInt, &UnusedInt);
					if (Result > FMOD_OK)
					{
						continue;
					}
					
					if (strcmp(DspName.Get(), "Resonance Audio Listener") == 0)
					{
						LOG(this, LogAudio, Log, TEXT("Successfully initialized Resonance Audio Listener DSP"));
						return CurrentDsp;
					}
				}
			}
		}
	}

	LOG(this, LogAudio, Warning, TEXT("Failed to initialize DSP"));
	return nullptr;
}

```

---

<div class="post-metadata">

**Author:** ![ptrefall](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ptrefall/32/2672_2.png) [@ptrefall](https://qa.fmod.com/u/ptrefall)\
**Post date:** [September 8, 2021, 7:29pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/11 "2021-09-08T19:29:35Z")

</div>

And this is how we push room properties to the DSP. The RoomProperties.h file is copied from resonance audio’s room properties header, which you can find on their github and is linked via their documentation.

An audio volume then just needs to set the room properties of that room, and you should be golden (but I leave that up to you to handle what best suits your project).

```auto
void UAudioSubsystem::UpdateRoomProperties(const vraudio::RoomProperties* RoomProperties)
{
	FMOD::DSP* Dsp = GetOrFindListenerDsp();
	if (Dsp != nullptr)
	{
		Dsp->setParameterData(1, RoomProperties, sizeof(vraudio::RoomProperties));
	}
}

```

---

<div class="post-metadata">

**Author:** ![ptrefall](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ptrefall/32/2672_2.png) [@ptrefall](https://qa.fmod.com/u/ptrefall)\
**Post date:** [September 8, 2021, 7:32pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/12 "2021-09-08T19:32:38Z")

</div>

Do note that this code has not been thoroughly tested, so there might be bugs in here.

---

<div class="post-metadata">

**Author:** ![ahmadsy](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@ahmadsy](https://qa.fmod.com/u/ahmadsy)\
**Post date:** [September 8, 2021, 7:42pm UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/13 "2021-09-08T19:42:40Z")

</div>

So, how I understanding, we should call “UpdateRoomProperties” every time, when we overlapping an Audio Volume, which instance locates in another c++ file and pass from this file an instance of RoomProperties struct to “UpdateRoomProperties”…  
Excuse me for my English.

---

<div class="post-metadata">

**Author:** ![ptrefall](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ptrefall/32/2672_2.png) [@ptrefall](https://qa.fmod.com/u/ptrefall)\
**Post date:** [September 9, 2021, 6:13am UTC](https://qa.fmod.com/t/resonance-audio-in-ue4/15877/14 "2021-09-09T06:13:18Z")

</div>

It should be enough to call UpdateRoomProperties when you enter the volume.
