Resonance Audio In UE4

,

Hello,

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

We followed the integration details from The resonance audio fmod guide 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.

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.

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

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.

1 Like

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…

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.

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

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

1 Like
// 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;
}

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).

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

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

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.

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