Answered
0
0

Hey, I am working on a small prototype in Unreal Engine and I am trying to get access to the mixer/bus output volumes in c++ for some visualization effects. Basically I want to access these values: enter image description here

All I seem to get access to is the fader however, or some static volume that doesn’t seem to be right at all. Nothing dynamic.

I am playing an event via blueprint at the moment, then I am trying to access it’s channel group to somehow access the dynamic volume. Not sure if I am on the right track.
The following code is executed every frame, but I always get the same Volume.

FMOD::ChannelGroup *ChannelGroup;
LastEventInstance.Instance->getChannelGroup(&ChannelGroup);

float OutVolume = 0.0f;

if (ChannelGroup)
{
    ChannelGroup->getVolume(&OutVolume);
}

I realized there is fft stuff I could do, and this is probably the way to go, but I have no clue how to use the API. I can’t find any good examples on this.

Any help or code snippets appreaciated.

  • You must to post comments
Great Answer
0
0

If you want the actual metering levels (i.e. instantanous sound coming out of that track at the current time), as you have indicated, then that can be done via the API.

FMOD::ChannelGroup* ChanGroup = nullptr;
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 levels = {};
        ChanDSP->getMeteringInfo(0, &levels);
        if (levels.numsamples > 0)
        {
            // RMS volume is in levels.rmslevel[0], levels.rmslevel[1], etc..
        }
    }
}

Keep in mind that you have to be careful for the event instance to persist as you are querying the information. So for example if you have an FMOD Audio component, make it isn’t destroyed as you are running the above code.

If instead of metering levels you want the combined fader volume after any automation and modulation, then you’ll have to wait until 1.09. In the next major release we’re adding a second optional argument to all the Studio getVolume API calls that can get the final combined volume. This means you can automate a volume in FMOD Studio, and then query it at runtime with a single API call.

  • Denny Strube

    Hey thank you for this post. I already fixed it using spectrum data. I just take the volume across all frequencies and average them out a bit. Enough for my cause.
    Still looking forward to the new version.

    I have a different problem now, however. Some sounds aren’t playing in the packaged version.
    I didn’t have any issues with this in early test builds. Could it be that I have too many sounds in a bank?

  • Denny Strube

    Additional testing done. It seems that in my packaged game, the only sounds playing are the ones hooked up in FMODAudioComponents. Everything played using BlueprintStatics or FMODAudioComponent->SetEvent() followed by FMODAudioComonent->Play() – are not playing.

  • Geoff Carlton

    One thing that might cause it is blueprints loading before plugin load. The deployment page has more info:

    http://www.fmod.org/documentation/#content/generated/engine_ue4/deployment.html

    The sort of code to look for is “static ConstructorHelpers::FClassFinder”. If you don’t have anything like that, then if you have a small project you could send it to support@fmod.com and we can see what is going on.

  • Denny Strube

    Yeah, the blueprint loading before the plugin was the issue! Thank you so much. I was in full desperation mode already! ?

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.