Clarification on how getMeteringInfo works

,

Hi everyone,
I’m trying to understand in detail how FMOD::DSP::getMeteringInfo works in the Core API.
I need the RMS level of an FMOD event to modify the size of a mesh in real time, but the values I’m getting are unclear.

Here’s the code I’m using for testing in Unreal:

float UPRFileUtility::TestFMODModulation(UFMODAudioComponent* InAudioComp)
{
    FMOD::ChannelGroup* ChanGroup = nullptr;
    InAudioComp->StudioInstance->getChannelGroup(&ChanGroup);
    if (ChanGroup)
    {
        FMOD::DSP* ChanDSP = nullptr;
        ChanGroup->getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &ChanDSP);
        if (ChanDSP)
        {
            ChanDSP->setMeteringEnabled(true, false);

            FMOD_DSP_METERING_INFO prelevels = {};
            ChanDSP->getMeteringInfo(&prelevels, 0);

            if (prelevels.numsamples > 0)
            {
                float sum = 0;
                for (int i = 0; i < 32; i++)
                {
                    if (prelevels.rmslevel[i] > 0)
                    {
                        sum += prelevels.rmslevel[i];
                        UE_LOG(LogTemp, Error, TEXT("rmslevel: %f at index %d"), prelevels.rmslevel[i], i);
                    }
                }

                UE_LOG(LogTemp, Warning, TEXT("sum: %f and numsample: %d"),     sum, prelevels.numsamples);
                return sum / 32.f;
            }
        }
    }

    return -1.f;
}

As you can see in the image, only a few indeces of the array contain values different from 0, yet in Unreal Engine the sound that’s playing is perfectly audible.

Would it be possible to get more detailed information about howFMOD::DSP::getMeteringInfo works?

Thanks in advance!

The FMOD_DSP_METERING_INFO RMS values are the per-channel RMS of the buffer at that point in time. Most of them are going to be zero, unless you have 32 channels playing.
The channel layout depends on your FMOD_SPEAKERMODE, if you are using FMOD_SPEAKERMODE_SURROUND then these values mean:

FL [0] FR [1] C [2] SL [3] SR [4]
0.000000 0.005351 0.000790 0.000000 0.000000

Or if you are using FMOD_SPEAKERMODE_QUAD then these values mean:

FL [0] FR [1] SL [3] SR [4]
0.000000 0.005351 0.000790 0.000000
1 Like