Steam Audio

Unfortunately, no. We need to do these bindings while initializing the Steam Audio plugin, and it should be done inside plugin’s source code, on where plugin is initialized.

Sorry, I’m a bit confused. I can copy the plugin from Engine/Plugins/Runtime/Steam/SteamAudio to [my project]/Plugins/SteamAudio and modify it. When I open a project, Unreal prefers local version of plugins instead of engine’s plugins. I used it to update the plugin to beta 17 (based on your other pull request - thank you again). But this pull request #5979 changes files in Engine/Source folder - as I understand, to update scene in SteamAudio when engine loads new map. So, I’d like to avoid it if it’s possible, because really, really don’t want to compile engine from sources, and our release is planned before 4.24.

Hello,

I’m trying to figure out the best way to stream realtime audio into UE4, any suggestions would be greatly appreiciated!

So, I figured out how to update environment without changing engine’s core. FAudioDevice::InitializePluginListeners() function is private, but it just updates PluginListener array, which is public.



   void FSteamAudioModule::StartupModule()
   {
       ...
       hWorldPostInit = FWorldDelegates::OnPostWorldCreation.AddRaw(this, &FSteamAudioModule::OnWorld_PostCreation);
   }

   void FSteamAudioModule::ShutdownModule()
   {
       FWorldDelegates::OnPostWorldInitialization.Remove(hWorldPostInit);
       ...
   }

   void FSteamAudioModule::OnWorld_PostCreation(UWorld* World)
   {
       if (FAudioDevice* AudioDevice = GEngine->GetActiveAudioDevice())
       {
           for (TAudioPluginListenerPtr PluginListener : AudioDevice->PluginListeners)
           {
               PluginListener->OnListenerShutdown(AudioDevice);
               PluginListener->OnListenerInitialize(AudioDevice, World);
           }

          UE_LOG(LogSteamAudio, Log, TEXT("OnWorld_PostCreation: Audio Device updated for world %s"), *World->GetName());
       }
       else
       {
           UE_LOG(LogSteamAudio, Error, TEXT("OnWorld_PostCreation: Can't get valid Audio Device"));
       }
   }


UPD. Also, need to filter out sublevels.

Ok, final version. Works with level streaming - although, doesn’t support combining phonon scenes from sublevels.



namespace SteamAudio
{
   ...
    bool HasSceneOnDisk(UWorld* World)
    {
        FString MapName = StrippedMapName(World->GetMapName());
        FString SceneFileName = RuntimePath + MapName + ".phononscene";

        IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
        return PlatformFile.FileExists(*SceneFileName);
    }
}




void FSteamAudioModule::OnWorld_Cleanup(UWorld* World, bool bSessionEnded, bool bCleanupResources)
{
    if (FAudioDevice* AudioDevice = GEngine->GetActiveAudioDevice())
    {
        for (TAudioPluginListenerPtr PluginListener : AudioDevice->PluginListeners)
        {
            PluginListener->OnListenerShutdown(AudioDevice);
        }
    }
}

void FSteamAudioModule::OnWorld_PostCreation(UWorld* World)
{
    bool bHasSceneOnDisk = SteamAudio::HasSceneOnDisk(World);

    if (bHasSceneOnDisk)
    {
        if (FAudioDevice* AudioDevice = GEngine->GetActiveAudioDevice())
        {
            for (TAudioPluginListenerPtr PluginListener : AudioDevice->PluginListeners)
            {
                PluginListener->OnListenerInitialize(AudioDevice, World);
            }

            UE_LOG(LogSteamAudio, Log, TEXT("OnWorld_PostCreation: Audio Device updated for world %s"), *World->GetName());
        }
        else
        {
            UE_LOG(LogSteamAudio, Warning, TEXT("OnWorld_PostCreation: Can't get valid Audio Device"));
        }
    }
    else
    {
        UE_LOG(LogSteamAudio, Log, TEXT("OnWorld_PostCreation: no SteamAudio scene for world %s"), *World->GetName());
    }
}


So, if you can’t wait for 4.24 and don’t want to compile engine from sources

SteamAudio - Project Plugin for Unreal Engine 4.22 (Launcher version)
Link: SteamAudio_ProjectPlugin_422.zip - Google Drive

SDK 2.0 beta 17 implementation by @dyanikoglu (https://github.com/EpicGames/UnrealEngine/pull/5940)

  • updated SteamAudio headers included
  • my fix to update scene when loading new level

Usage:

steamaudio_api_2.0-beta.17.zip
steamaudio_embree_2.0-beta.17.zip
steamaudio_tan_2.0-beta.17.zip

  • Copy DLLs to [UE 4.22 installation dir]/Engine/Binaries/ThirdParty/Phonon/Win64
  • Copy phonon.lib to [UE 4.22 installation dir]/Engine/Source/ThirdParty/libPhonon/phonon_api/lib/Win64
  • Recompile project if necessary

I’m using Steam Audio with 4.22, the shipped version. I notice that when I play in PIE the level loading time is significantly longer than when using any other audio setup (default or Resonance). Did anyone else notice that level loading times take longer when using the Steam Audio plugin, or am I doing something wrong?

Thank you for the code blocks above!

I think you should create a PR for that, I can close my PR and reference yours on there.

Hello again @YuriNK

We have implemented this solution into our source and tested it extensively.

Unfortunately, we got minor sound distortions on reverbation effects. It sounded like the steam scene was being stacked by getting loaded multiple times incorrectly.

@dyanikoglu
I can’t test it deeply right now, but this should fix it:

PhononPluginManager.cpp



    void FPhononPluginManager::OnListenerShutdown(FAudioDevice* AudioDevice)
    {
        // Shutdown reverb effect
        if (IsUsingSteamAudioPlugin(EAudioPlugin::REVERB))
        {
            ReverbPtr = static_cast<FPhononReverb*>(AudioDevice->ReverbPluginInterface.Get());
            ReverbPtr->DestroyReverbEffect();
            ReverbPtr->Shutdown();
        }

        FSteamAudioModule* Module = &FModuleManager::GetModuleChecked<FSteamAudioModule>("SteamAudio");
        if (Module != nullptr)
        {
            Module->UnregisterAudioDevice(AudioDevice);
        }
    }


PhononReverb.cpp



    void FPhononReverb::Shutdown()
    {
        for (auto& ReverbSource : ReverbSources)
        {
            if (ReverbSource.ConvolutionEffect)
            {
                iplDestroyConvolutionEffect(&ReverbSource.ConvolutionEffect);
            }
        }

        if (ReverbConvolutionEffect)
        {
            iplDestroyConvolutionEffect(&ReverbConvolutionEffect);
        }

        if (IndirectBinauralEffect)
        {
            iplDestroyAmbisonicsBinauralEffect(&IndirectBinauralEffect);
        }

        if (IndirectPanningEffect)
        {
            iplDestroyAmbisonicsPanningEffect(&IndirectPanningEffect);
        }

        if (BinauralRenderer)
        {
            iplDestroyBinauralRenderer(&BinauralRenderer);
        }

        if (IndirectOutDeinterleaved)
        {
            for (int32 i = 0; i < AmbisonicsChannels; ++i)
            {
                delete] IndirectOutDeinterleaved*;
            }
            delete] IndirectOutDeinterleaved;
            IndirectOutDeinterleaved = nullptr;
        }

        Environment = nullptr;
    }

    void FPhononReverb::DestroyReverbEffect()
    {
        for (FReverbSource& ReverbSource : ReverbSources)
        {
            if (ReverbSource.ConvolutionEffect)
            {
                iplDestroyConvolutionEffect(&ReverbSource.ConvolutionEffect);
            }
        }
    }


And to be safe:



    void FPhononReverb::SetEnvironment(FEnvironment* InEnvironment)
    {
        if (!InEnvironment)
        {
            return;
        }

        // Free currently existing environment
        if (Environment)
        {
            // Shutdown all
            DestroyReverbEffect();
            Shutdown();
        }

        ...
    }


Thanks, I will let you know if problem still persists after this change.

Nope, doesn’t work. I’ll write here later if I succeed.

Great, Thanks for information and clarify all confusion.

@YuriNK

Freeman just have shared his previously mentioned 4.24 update for steam audio plugin: https://github.com/EpicGames/UnrealEngine/pull/6203

Looks like they have decided to go with engine source change for level reload support, and their solution seems better because of it also introducing proper support for level reloads on audio plugins.

I’m going to give a quick try to his PR and see if everything works.

Edit: There was a bug preventing me from exporting scene, it’s suggested as a change in PR now. Rest works without problem, and better than my initial implementation. They did lots of fixes onto my PR.

Generating probes problem

Hey, guys. I’m using Steam audio 2.0-beta.13 with UE 4.22. I am able to place a Phonon probe volume but unable to generate probes. Anytime I press “Generate Probes”, the following message pops up:

I couldn’t find any mention of such a problem or the pop-up message above. Am I missing something? Any thoughts for the reason or ideas for a solution?
Thanks in advance!

Hi folks!

We’ve updated the integrated SteamAudio for Unreal, coming in 4.24 – already up in GitHub, questions/issues/feedback, just hit me up or post on the steamcommunity forums. Updated manual should also be up in a day or two:

Hi,

I have just installed UE 4.25 and am attempting to enable dynamic geometry in my project.

In this link https://steamcommunity.com/app/596420

They describe that you have to “click Export to export the geometry data to a file”.

I cant seem to find the steam audio export button in the new layout of UE 4.25.

If anyone could help that would be greatly approciated

Hey Rian - it’s just under the modes option box at the top of the screen in 4.25, and then select steam. You’ll want to tag the geo with the phonon geometry tag first that are animated, and you should then see it register them as dynamic. Hope this helps!
-a
ps: I was getting a crash if I had all dynamic objects, adding at least one static one fixed it. Just a heads up if you see this issue:)

Hi Andy,
Thank you very much for the help and information, all sorted now !

Hi!

Coming with a question about Steam Audio on Mac OSX. Is it supported on this platform? On website it says it does, in release notes it says that it supports Windows and Android, it’s really messy.

Did anyone managed to make it work? It shows on plugins tab in UE4, but really old beta2.17 version (whilst there’s 4.0 version available), and even enabled it doesn’t work. I tried to add this weird -audiomixer command (that everyone using to open this on Windows) by terminal and going “open UE4Editor.app --args -audiomixer”, but to no avail.

If anyone got a way to make it work - or confirm that it’s not supported on Mac so I don’t waste any more of my time, I’d be really grateful.

Thanks in advance!