# Retrieving the Volume after attenuation of an Event in a AudioComponent

**URL:** <https://qa.fmod.com/t/retrieving-the-volume-after-attenuation-of-an-event-in-a-audiocomponent/17827>\
**Category:** Unreal Engine\
**Tags:** ue4, cpp\
**Created:** [October 21, 2021, 9:37am UTC](https://qa.fmod.com/t/retrieving-the-volume-after-attenuation-of-an-event-in-a-audiocomponent/17827 "2021-10-21T09:37:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [October 27, 2021, 2:04am UTC](https://qa.fmod.com/t/retrieving-the-volume-after-attenuation-of-an-event-in-a-audiocomponent/17827/2 "2021-10-27T02:04:26Z")

</div>

To get the instantaneous peak and rms levels of a playing event you can use [`DSP::getMeteringInfo`](https://fmod.com/resources/documentation-api?version=2.02&page=core-api-dsp.html#dsp_getmeteringinfo) on the `ChannelGroup` that the event is playing on. It’s a bit of drilling down from the UFMODEvent to get to it, but the process is as follows:

1. Get the underlying event instance from the UFMODEvent
2. Access the event instance’s channel group using [`EventInstance::getChannelGroup`](https://www.fmod.com/resources/documentation-api?version=2.01&page=core-api-channel.html#channel_getchannelgroup)
3. Get the head, tail or fader DSP object using [`Channel::getDSP`](https://www.fmod.com/resources/documentation-api?version=2.01&page=core-api-channelcontrol.html#channelcontrol_getdsp), depending on which point you want to access the metering info
4. Enable metering on your chosen DSP object with [`DSP::setMeteringEnabled`](https://www.fmod.com/resources/documentation-api?version=2.01&page=core-api-dsp.html#dsp_setmeteringenabled)
5. Retrieve the metering info with [`DSP::getMeteringInfo`](https://www.fmod.com/resources/documentation-api?version=2.01&page=core-api-dsp.html#dsp_getmeteringinfo)
6. Read the resulting peak, rms etc level info from the returned [`FMOD_DSP_METERING_INFO`](https://www.fmod.com/resources/documentation-api?version=2.01&page=plugin-api-dsp.html#fmod_dsp_metering_info) object

I have a basic example class here of what that would look like in the context of UE4.

```auto
#include "DisplayVolume.h"

#include <fmod_studio.hpp>
#include <FMODStudioModule.h>
#include <FMODAudioComponent.h>
#include <FMODEvent.h>
#include <FMODBlueprintStatics.h>

FMOD::ChannelGroup* Channel;
FMOD::DSP* HeadDSP;
FMOD::Studio::System* StudioSystem;
FMOD::Studio::EventInstance* Instance;

void ERRCHECK(FMOD_RESULT result, int line)
{
	if (result != FMOD_OK)
	{
		UE_LOG(LogTemp, Warning, TEXT("Result = %d, %d"), (int)result, line);
	}
}

// Sets default values for this component's properties
UDisplayVolume::UDisplayVolume()
{
	PrimaryComponentTick.bCanEverTick = true;
}

UDisplayVolume::~UDisplayVolume()
{
	Channel->release();
}

// Called when the game starts
void UDisplayVolume::BeginPlay()
{
	Super::BeginPlay();

	if (IFMODStudioModule::IsAvailable())
	{
		StudioSystem = IFMODStudioModule::Get().GetStudioSystem(EFMODSystemContext::Runtime);
		if (StudioSystem)
		{
			// Create event instance
			FFMODEventInstance wrapper = UFMODBlueprintStatics::PlayEvent2D(
				GetOwner(), 
				Event, // UFMODEvent*, Declared in DisplayVolume.h
				true);

			Instance = wrapper.Instance;
		}
	}
}

// Called every frame
void UDisplayVolume::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if (IFMODStudioModule::IsAvailable())
	{
		if (StudioSystem && Instance)
		{
			ERRCHECK(Instance->getChannelGroup(&Channel), __LINE__ );

			if (Channel)
			{
				ERRCHECK(Channel->getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &HeadDSP), __LINE__ );
				if (HeadDSP)
				{
					ERRCHECK(HeadDSP->setMeteringEnabled(false, true), __LINE__ );
					FMOD_DSP_METERING_INFO Info = {};
					ERRCHECK(HeadDSP->getMeteringInfo(nullptr, &Info), __LINE__ );

					GEngine->ClearOnScreenDebugMessages();
					GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(
						TEXT("Metering: %d channels, %d len. rms: %.3f, %.3f, %.3f, %.3f, %.3f, %.3f"),
						Info.numchannels, Info.numsamples,
						Info.rmslevel[0], Info.rmslevel[1], 
						Info.rmslevel[2], Info.rmslevel[3], 
						Info.rmslevel[4], Info.rmslevel[5])
					);
				}
			}
		}
	}
}

```

And the resulting image of the volume debug info.  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/423c34b9293c2d89b35851c060700464fb946dc3.jpeg)

Hopefully that all makes sense, let me know if you have any issues!

---

_[View the full topic](https://qa.fmod.com/t/retrieving-the-volume-after-attenuation-of-an-event-in-a-audiocomponent/17827)._
