Announcement

Collapse
No announcement yet.

Steam Audio

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Originally posted by YuriNK View Post
    dyanikoglu
    Here [ https://github.com/EpicGames/UnrealEngine/pull/5979 ] in comments you said about OnWorldCleanup and OnPostWorldInitialization delegates. Does it mean it's possible to keep all changes within SteamAudio plugin and avoid changing engine's sources?
    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.

    Comment


      Originally posted by dyanikoglu View Post

      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.
      Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
      And random stuff at Youtube

      Comment


        Hello,

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

        Comment


          Originally posted by YuriNK View Post
          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.
          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.

          Code:
             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.
          Last edited by YuriNK; 08-20-2019, 07:11 AM.
          Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
          And random stuff at Youtube

          Comment


            Ok, final version. Works with level streaming - although, doesn't support combining phonon scenes from sublevels.
            Code:
            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);
                }
            }
            Code:
            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());
                }
            }
            Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
            And random stuff at Youtube

            Comment


              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: https://drive.google.com/open?id=1GT...jZVvygubLoIZFa

              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
              Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
              And random stuff at Youtube

              Comment


                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?

                Comment


                  Originally posted by YuriNK View Post
                  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: https://drive.google.com/open?id=1GT...jZVvygubLoIZFa

                  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
                  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.

                  Comment


                    Originally posted by YuriNK View Post
                    Ok, final version. Works with level streaming - although, doesn't support combining phonon scenes from sublevels.
                    Code:
                    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);
                    }
                    }
                    Code:
                    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());
                    }
                    }
                    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.
                    Last edited by dyanikoglu; 09-04-2019, 09:58 AM.

                    Comment


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

                      PhononPluginManager.cpp
                      Code:
                          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
                      Code:
                          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[i];
                                  }
                                  delete[] IndirectOutDeinterleaved;
                                  IndirectOutDeinterleaved = nullptr;
                              }
                      
                              Environment = nullptr;
                          }
                      
                          void FPhononReverb::DestroyReverbEffect()
                          {
                              for (FReverbSource& ReverbSource : ReverbSources)
                              {
                                  if (ReverbSource.ConvolutionEffect)
                                  {
                                      iplDestroyConvolutionEffect(&ReverbSource.ConvolutionEffect);
                                  }
                              }
                          }
                      And to be safe:
                      Code:
                          void FPhononReverb::SetEnvironment(FEnvironment* InEnvironment)
                          {
                              if (!InEnvironment)
                              {
                                  return;
                              }
                      
                              // Free currently existing environment
                              if (Environment)
                              {
                                  // Shutdown all
                                  DestroyReverbEffect();
                                  Shutdown();
                              }
                      
                              ...
                          }
                      Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
                      And random stuff at Youtube

                      Comment


                        Originally posted by YuriNK View Post
                        dyanikoglu
                        I can't test it deeply right now, but this should fix it:

                        PhononPluginManager.cpp
                        Code:
                        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
                        Code:
                        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[i];
                        }
                        delete[] IndirectOutDeinterleaved;
                        IndirectOutDeinterleaved = nullptr;
                        }
                        
                        Environment = nullptr;
                        }
                        
                        void FPhononReverb::DestroyReverbEffect()
                        {
                        for (FReverbSource& ReverbSource : ReverbSources)
                        {
                        if (ReverbSource.ConvolutionEffect)
                        {
                        iplDestroyConvolutionEffect(&ReverbSource.ConvolutionEffect);
                        }
                        }
                        }
                        And to be safe:
                        Code:
                        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.

                        Comment


                          Originally posted by dyanikoglu View Post
                          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.
                          Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
                          And random stuff at Youtube

                          Comment


                            Great, Thanks for information and clarify all confusion.

                            Comment


                              Originally posted by YuriNK View Post
                              Nope, doesn't work. I'll write here later if I succeed.
                              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.
                              Last edited by dyanikoglu; 09-11-2019, 07:08 AM.

                              Comment


                                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:
                                Unable to create scene.
                                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!

                                Comment

                                Working...
                                X