Announcement

Collapse
No announcement yet.

(39) Rama's Extra Blueprint Nodes for You as a Plugin, No C++ Required!

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

    Hi, we are trying to compile in 4.24 without success. We are getting this error:

    Code:
    Severity Code Description Project File Line Suppression State
    Error LNK2001 unresolved external symbol "__declspec(dllimport) struct FThreadSafeStaticStat<struct FStat_STAT_PhysSceneWriteLock> StatPtr_STAT_PhysSceneWriteLock" (__imp_?StatPtr_STAT_PhysSceneWriteLock@@3U?$FThreadSafeStaticStat@UFStat_STAT_PhysSceneWriteLock@@@@A) Wardens D:\Revolver\Wardens\Intermediate\ProjectFiles\Module.VictoryBPLibrary.cpp.obj 1
    If someone was able to compile, please give us help.
    Thank you.
    Last edited by saga revolver; 12-09-2019, 02:55 PM.

    Comment


      https://mega.nz/#!sSoXTSiA!qsxkqaCVn...kaodrTk2Pcaiag

      Comment


        Hello there,
        Thank you very very much for this amazing plugin. I have a question regarding "Victory Sound Volume Change" and "Victory Get Sound Volume". These 2 functions are working just fine when playing in the editor but they don't work at all when playing in Standalone or packaged game. What can I do to solve this?

        FYI I'm using 4.19.

        Thank you again for the plugin.

        Comment


          4.24 Is Here!

          https://www.mediafire.com/file/rqg11...ory24.zip/file

          Sorry for the delay!



          Rama
          Last edited by Rama; 12-16-2019, 02:52 PM.
          100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

          UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

          Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

          Comment


            Rama Can you please help me add WAV support in the node play sound at location from file? atm it plays only .ogg and ogg is not a common file format that people use. I need it to play Wav files please?

            I'm using 4.23
            Matt Walton: Programmer and owner for WireLiteSoft Games.

            Comment


              Originally posted by frostic View Post
              Rama Can you please help me add WAV support in the node play sound at location from file? atm it plays only .ogg and ogg is not a common file format that people use. I need it to play Wav files please?

              I'm using 4.23
              Here's what you need:

              Code:
              USoundWave* UMyBPFunctionLibrary::GetSoundWaveFromWaveFile(const FString& filePath)
              {
                  USoundWave* sw = NewObject<USoundWave>(USoundWave::StaticClass());
              
                  if (!sw)
                      return nullptr;
              
                  TArray < uint8 > rawFile;
              
                  FFileHelper::LoadFileToArray(rawFile, filePath.GetCharArray().GetData());
                  FWaveModInfo WaveInfo;
              
                  if (WaveInfo.ReadWaveInfo(rawFile.GetData(), rawFile.Num()))
                  {
                      sw->InvalidateCompressedData();
              
                      sw->RawData.Lock(LOCK_READ_WRITE);
                      void* LockedData = sw->RawData.Realloc(rawFile.Num());
                      FMemory::Memcpy(LockedData, rawFile.GetData(), rawFile.Num());
                      sw->RawData.Unlock();
              
                      int32 DurationDiv = *WaveInfo.pChannels * *WaveInfo.pBitsPerSample * *WaveInfo.pSamplesPerSec;
                      if (DurationDiv)
                      {
                          sw->Duration = *WaveInfo.pWaveDataSize * 8.0f / DurationDiv;
                      }
                      else
                      {
                          sw->Duration = 0.0f;
                      }
                      sw->SetSampleRate(*WaveInfo.pSamplesPerSec);
                      sw->NumChannels = *WaveInfo.pChannels;
                      sw->RawPCMDataSize = WaveInfo.SampleDataSize;
                      sw->SoundGroup = ESoundGroup::SOUNDGROUP_Default;
                  }
                  else {
                      return nullptr;
                  }
              
                  return sw;
              }
              Make sure to include:
              Code:
              #include "Sound/SoundWave.h"
              #include "Misc/FileHelper.h"
              This function returns Sound Wave, you can do whatever you want with it. Or modify the function to play Sound Wave at given location if you don't need reference to Sound Wave, and just need a one-off play sound from file.

              And keep in mind that Unreal only works with 16bit .wav files
              Last edited by Jaytheway; 12-30-2019, 12:50 AM.

              Comment


                Originally posted by Jaytheway View Post
                This function returns Sound Wave, you can do whatever you want with it. Or modify the function to play Sound Wave at given location if you don't need reference to Sound Wave, and just need a one-off play sound from file.

                And keep in mind that Unreal only works with 16bit .wav files
                I can't find where to put this code. and I can't seem to find a project for the plugin
                I'm not a c++ programmer. I work in blueprints. I don't even know where to add this code.
                Last edited by frostic; 12-30-2019, 10:58 PM.
                Matt Walton: Programmer and owner for WireLiteSoft Games.

                Comment


                  Originally posted by frostic View Post

                  I can't find where to put this code. and I can't seem to find a project for the plugin
                  I'm not a c++ programmer. I work in blueprints. I don't even know where to add this code.
                  Take a look at this playlist: https://www.youtube.com/watch?v=u1JC...QEyURMThnQYKQD
                  First 2-3 videos should be enough to understand what you need to do here.

                  Basically you need to create a simple BP function in your C++ BP function library. In the header file you'd declare function like this:
                  Code:
                          UFUNCTION(BlueprintCallable, Category = "My - functions", meta = (DisplayName = "Get Sound Wave from Wave file", Keywords = "Get Sound Wave from Wave file"))
                          static USoundWave* GetSoundWaveFromWaveFile(const FString& filePath);
                  And in .cpp file you'd create a definition for the function - code form my previous message.

                  Comment


                    Originally posted by Jaytheway View Post

                    Take a look at this playlist: https://www.youtube.com/watch?v=u1JC...QEyURMThnQYKQD
                    First 2-3 videos should be enough to understand what you need to do here.

                    Basically you need to create a simple BP function in your C++ BP function library. In the header file you'd declare function like this:
                    Code:
                     UFUNCTION(BlueprintCallable, Category = "My - functions", meta = (DisplayName = "Get Sound Wave from Wave file", Keywords = "Get Sound Wave from Wave file"))
                    static USoundWave* GetSoundWaveFromWaveFile(const FString& filePath);
                    And in .cpp file you'd create a definition for the function - code form my previous message.
                    here is what I came up with but It wont compile. I don't know what I did wrong. This is the first time I ever added any c++
                    to my game and I'm failing LOL.

                    In AudioFunctions.cpp i added this code:

                    Code:
                    #include "AudioFunctions.h"
                    #include "Sound/SoundWave.h"
                    #include "Misc/FileHelper.h"
                    #include "Kismet/GameplayStatics.h"
                    
                    void UAudioFunctions::PlaySoundAtLocationFromWAV(UObject* WorldContextObject, const FString& FilePath, FVector Location, float VolumeMultiplier, float PitchMultiplier, float StartTime, class USoundAttenuation* AttenuationSettings)
                    {
                        USoundWave* sw = GetSoundFromWaveFile(FilePath);
                    
                        if (!sw)
                            return;
                    
                        UGameplayStatics::PlaySoundAtLocation(WorldContextObject, sw, Location, VolumeMultiplier, PitchMultiplier, StartTime, AttenuationSettings);
                    }
                    
                    class USoundWave* UAudioFunctions::GetSoundFromWaveFile(const FString& filePath)
                    {
                        USoundWave* sw = NewObject<USoundWave>(USoundWave::StaticClass());
                    
                        if (!sw)
                            return nullptr;
                    
                        TArray < uint8 > rawFile;
                    
                        FFileHelper::LoadFileToArray(rawFile, filePath.GetCharArray().GetData());
                        FWaveModInfo WaveInfo;
                    
                        if (WaveInfo.ReadWaveInfo(rawFile.GetData(), rawFile.Num()))
                        {
                            sw->InvalidateCompressedData();
                    
                            sw->RawData.Lock(LOCK_READ_WRITE);
                            void* LockedData = sw->RawData.Realloc(rawFile.Num());
                            FMemory::Memcpy(LockedData, rawFile.GetData(), rawFile.Num());
                            sw->RawData.Unlock();
                    
                            int32 DurationDiv = *WaveInfo.pChannels * *WaveInfo.pBitsPerSample * *WaveInfo.pSamplesPerSec;
                            if (DurationDiv)
                            {
                                sw->Duration = *WaveInfo.pWaveDataSize * 8.0f / DurationDiv;
                            }
                            else
                            {
                                sw->Duration = 0.0f;
                            }
                            sw->SetSampleRate(*WaveInfo.pSamplesPerSec);
                            sw->NumChannels = *WaveInfo.pChannels;
                            sw->RawPCMDataSize = WaveInfo.SampleDataSize;
                            sw->SoundGroup = ESoundGroup::SOUNDGROUP_Default;
                        }
                        else {
                            return nullptr;
                        }
                    
                        return sw;
                    }

                    And in my AudioFunctions.h i put this:

                    Code:
                    // Fill out your copyright notice in the Description page of Project Settings.
                    
                    #pragma once
                    
                    #include "CoreMinimal.h"
                    #include "Kismet/BlueprintFunctionLibrary.h"
                    #include "AudioFunctions.generated.h"
                    
                    /**
                     *
                     */
                    UCLASS()
                    class StyxVR_API UAudioFunctions : public UBlueprintFunctionLibrary
                    {
                        GENERATED_BODY()
                    
                        //* Declare blueprint functions here?
                        UFUNCTION(BlueprintCallable, Category = "AudioFunctions", meta = (DisplayName = "Get Sound from Wave file", Keywords = "Get Sound from Wave file"))
                        static USoundWave* GetSoundFromWaveFile(const FString& filePath);
                    
                        UFUNCTION(BlueprintCallable, Category = "AudioFunctions", meta = (DisplayName = "Play Sound from Wave file", Keywords = "Play Sound from Wave file"))
                        static USoundWave* PlaySoundAtLocationFromWAV(UObject* WorldContextObject, const FString& FilePath, FVector Location, float VolumeMultiplier, float PitchMultiplier, float StartTime, class USoundAttenuation* AttenuationSettings);
                    
                    };

                    I seem to have some error



                    Click image for larger version  Name:	Screenshot_1.png Views:	0 Size:	12.6 KB ID:	1703353
                    Last edited by frostic; 01-01-2020, 07:26 AM.
                    Matt Walton: Programmer and owner for WireLiteSoft Games.

                    Comment


                      frostic Have you tried compiling just GetSoundFromWaveFile function? It might be easier to just get a sound wave from this function and then do your playback at location from blueprints.
                      fyi, your error picture is too small to read what's going on.

                      Comment


                        I'm an idiot, don't mind me.......

                        your code converts it from the path/filestring into a uSound and that
                        can be played in "play sound at location" instead of the "play sound at location from file" accepts a PATH and yours converts the PATH to an audio file like if i import the wav into my project. Jaytheway YOU SIR ARE AWESOME!
                        Last edited by frostic; 01-01-2020, 06:32 PM.
                        Matt Walton: Programmer and owner for WireLiteSoft Games.

                        Comment


                          frostic While you're at it, you might want to expose some properties of sound wave to blueprints. Stuff that you can usually edit in details panel of the asset:

                          Click image for larger version

Name:	details.png
Views:	191
Size:	76.1 KB
ID:	1703541

                          You can find it all here: https://docs.unrealengine.com/en-US/...ave/index.html

                          But first check if it's not already available:
                          Click image for larger version

Name:	properties.png
Views:	172
Size:	24.0 KB
ID:	1703542

                          Comment


                            Jaytheway I sent you a private message. I'm having an issue with the code not working after build/compile
                            Matt Walton: Programmer and owner for WireLiteSoft Games.

                            Comment


                              frostic The issue was that SoundWave never got RawPCMData baked into it, which is apparently what it needs in packaged builds. Here's fixed GetSoundWaveFromWaveFile function:

                              Code:
                              class USoundWave* UMyBPFunctionLibrary::GetSoundWaveFromWaveFile(const FString& filePath, bool& Success)
                              {
                                  if (filePath == "") { Success = false; return nullptr; }
                              
                                  USoundWave* sw = NewObject<USoundWave>(USoundWave::StaticClass());
                                  if (!sw) { Success = false; return nullptr; }
                              
                                  TArray < uint8 > rawFile;
                              
                                  FFileHelper::LoadFileToArray(rawFile, filePath.GetCharArray().GetData());
                                  FWaveModInfo WaveInfo;
                              
                                  if (WaveInfo.ReadWaveInfo(rawFile.GetData(), rawFile.Num()))
                                  {
                              
                                      // - catching not supported bit depth
                                      if (*WaveInfo.pBitsPerSample != 16) { Success = false;  return nullptr; }
                              
                                      sw->InvalidateCompressedData();
                              
                                      sw->RawData.Lock(LOCK_READ_WRITE);
                                      void* LockedData = sw->RawData.Realloc(rawFile.Num());
                                      FMemory::Memcpy(LockedData, rawFile.GetData(), rawFile.Num());
                                      sw->RawData.Unlock();
                              
                                      int32 DurationDiv = *WaveInfo.pChannels * *WaveInfo.pBitsPerSample * *WaveInfo.pSamplesPerSec;
                                      if (DurationDiv)
                                      {
                                          sw->Duration = *WaveInfo.pWaveDataSize * 8.0f / DurationDiv;
                                      }
                                      else
                                      {
                                          sw->Duration = 0.0f;
                                      }
                                      sw->SetSampleRate(*WaveInfo.pSamplesPerSec);
                                      sw->NumChannels = *WaveInfo.pChannels;
                                      sw->RawPCMDataSize = WaveInfo.SampleDataSize;
                                      sw->SoundGroup = ESoundGroup::SOUNDGROUP_Default;
                              
                                  }
                                  else {
                                      Success = false;
                                      return nullptr;
                                  }
                              
                                  // - Baking PCM Data from file into SoundWave memory
                                  const int32 NumSamples = sw->RawPCMDataSize / sizeof(Audio::DefaultUSoundWaveSampleType);
                              
                                  sw->RawPCMData = (uint8*)FMemory::Malloc(sw->RawPCMDataSize);
                                  FMemory::Memcpy(sw->RawPCMData, WaveInfo.SampleDataStart, NumSamples * sizeof(Audio::DefaultUSoundWaveSampleType));
                              
                                  if (!sw) { Success = false; return nullptr; }
                              
                                  Success = true;
                                  return sw;
                              }
                              Header:
                              Code:
                              UFUNCTION(BlueprintCallable, Category = "JP - Nodes", meta = (DisplayName = "Get Sound Wave from Wave file", Keywords = "Get Sound Wave from Wave file"))
                              static class USoundWave* GetSoundWaveFromWaveFile(const FString& filePath, bool& Success);
                              "Success" bool returns false if:
                              - file path is invalid
                              - failed to create SoundWave
                              - input wave file has unsupported bit depth (other than 16)
                              Last edited by Jaytheway; 01-04-2020, 02:31 PM.

                              Comment


                                Originally posted by Jaytheway View Post
                                frostic The issue was that SoundWave never got RawPCMData baked into it, which is apparently what it needs in packaged builds. Here's fixed GetSoundWaveFromWaveFile function:
                                You are awesome thank you!
                                Matt Walton: Programmer and owner for WireLiteSoft Games.

                                Comment

                                Working...
                                X