Getting the RMS values for fmod event instances

I have several actors with a FMODAudio component that change size based on the volume of the fmod event. I do this with a custom BP node that takes the FMODAudio component object reference and returns the RMS value. My problem is that all of the actor sizes are changing based on the loudest sound that’s getting played by Fmod, and not by the respected fmod event instance.

float UFmod_BP_Function_Library::GetFMODInstanceRMS(UFMODAudioComponent* FMODInstance)
{
    
    FMOD::ChannelGroup* ChanGroup = nullptr;
    FMODInstance->StudioInstance->getChannelGroup(&ChanGroup);
    if (ChanGroup)
    {
        FMOD::DSP* ChanDSP = nullptr;
        ChanGroup->getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &ChanDSP);
        if (ChanDSP)
        {
            ChanDSP->setMeteringEnabled(false, true);
            FMOD_DSP_METERING_INFO Info = {};
            ChanDSP->getMeteringInfo(nullptr, &Info);

            return Info.rmslevel[0];
        }
    }

    return 0;
}

I was able to use your code in a static blueprintable function on multiple blueprints, using different events, and have them work independently from each other.

Your right. Turns out the issue was with a separate function that processed the outputted rms value. The issue with the other function was that it wasn’t instance independent.

1 Like