Controling multiplayer game audio during a menu screen


First time post.

I’m getting around learning the basic of coding 95% C++ in UE4.14.3.
Today I ran into a core dump (assert failure) problem attempting to mute active audio during a menu screen after testing the packaged version.

/* GameMenu.h */
        UAudioComponent* AudioComp;
    UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Sounds")
        USoundCue* MenuLoop;
/* GameMenu.cpp */
    if (GEngine)
        auto sounds = GEngine->GetActiveAudioDevice()->GetActiveSounds();
        for (auto sound : sounds)
            UAudioComponent *audioComp = UAudioComponent::GetAudioComponentFromID(sound->GetAudioComponentID());
            if (audioComp->GetAudioComponentID() !=AudioComp->GetAudioComponentID())
            /////////////////////////////////////////// Crashes after this call

When I run this code in debug mode, everything is fine.

When it is packaged Win64, a crash occurs in PauseActiveSound … check(IsInAudioThread()). The assembler code shows an int 3, which I believe is a debug break call.

Anyone have experience implementing basic c++ audio control in UE4, or know of any good samples for controling the vanilla engine audio in c++? The game I’m working on is a 4 person local network based multiplayer, with one of the clients acting as the server. The goal here was, to stop playing the ambient audio and all game audio, then start playing the setup/main menu audio track.



I’ve just found old piece of code I wrote about year ago (for 4.10 or 4.11).
The point is change level(which is normalized value - from 0 to 1) of SoundClasses inside you created SoundMix.

Maybe it would help you! =-]


Nice sample code. I’ll definitely consider it for level control.
So, are you saying, I should avoid pausing the active sounds and instead change the levels?


Seemingly, doing pause menu audio right, isn’t always trivial. :wink: