diff --git a/Content/Blueprints/BP_controller.uasset b/Content/Blueprints/BP_controller.uasset index 2458ab3..1d06107 100644 Binary files a/Content/Blueprints/BP_controller.uasset and b/Content/Blueprints/BP_controller.uasset differ diff --git a/Plugins/eXiSoundVis/Source/eXiSoundVis/Private/SoundVisComponent.cpp b/Plugins/eXiSoundVis/Source/eXiSoundVis/Private/SoundVisComponent.cpp index 2462a82..fee0d85 100644 --- a/Plugins/eXiSoundVis/Source/eXiSoundVis/Private/SoundVisComponent.cpp +++ b/Plugins/eXiSoundVis/Source/eXiSoundVis/Private/SoundVisComponent.cpp @@ -41,7 +41,7 @@ void USoundVisComponent::TickComponent(float DeltaTime, ELevelTick TickType, FAc /// Functions to load Data from the HardDrive -void USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) +bool USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) { // Create new SoundWave Object CompressedSoundWaveRef = NewObject(USoundWave::StaticClass()); @@ -50,7 +50,7 @@ void USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) if (!CompressedSoundWaveRef) { PrintError(TEXT("Failed to create new SoundWave Object!")); - return; + return false; } // If true, the Sound was successfully loaded @@ -64,6 +64,7 @@ void USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) if (bLoaded) { + UE_LOG(LogTemp, Error, TEXT("LoadSoundFileFromHD 0")); // Fill the SoundData into the SoundWave Object if (RawFile.Num() > 0) { @@ -92,11 +93,11 @@ void USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) if (!bLoaded) { PrintError(TEXT("Something went wrong while loading the Sound Data!")); - return; + return false; } // Fill the PCMSampleBuffer - GetPCMDataFromFile(CompressedSoundWaveRef); + return GetPCMDataFromFile(CompressedSoundWaveRef); } bool USoundVisComponent::FillSoundWaveInfo(USoundWave* InSoundWave, TArray* InRawFile) @@ -124,18 +125,18 @@ bool USoundVisComponent::FillSoundWaveInfo(USoundWave* InSoundWave, TArrayNumChannels < 1 || InSoundWave->NumChannels > 2) { PrintError(TEXT("SoundWave Object has not the right amount of Channels. Plugin only supports 1 or 2!")); - return; + return false; } if (GEngine) @@ -151,13 +152,14 @@ void USoundVisComponent::GetPCMDataFromFile(USoundWave* InSoundWave) // Creates a new DecompressWorker and starts it InitNewDecompressTask(InSoundWave); + return true; } else { PrintError(TEXT("Couldn't get a valid Pointer to the Main AudioDevice!")); - return; } } + return false; } void USoundVisComponent::CalculateFrequencySpectrum(USoundWave* InSoundWaveRef, const float InStartTime, const float InDuration, TArray& OutFrequencies) @@ -399,9 +401,9 @@ void USoundVisComponent::HandleFrequencySpectrumCalculation() /// Blueprint Versions of the File Data Functions -void USoundVisComponent::BP_LoadSoundFileFromHD(const FString InFilePath) +bool USoundVisComponent::BP_LoadSoundFileFromHD(const FString InFilePath) { - LoadSoundFileFromHD(InFilePath); + return LoadSoundFileFromHD(InFilePath); } void USoundVisComponent::BP_LoadAllSoundFileNamesFromHD(bool& bLoaded, const FString InDirectoryPath, const bool bInAbsolutePath, const FString InFileExtension, TArray& OutSoundFileNamesWithPath, TArray& OutSoundFileNamesWithoutPath) @@ -653,4 +655,4 @@ void USoundVisComponent::BP_GetAverageFrequencyValueInRange(USoundWave* InSoundW } OutAverageFrequency = ValueSum / NumberOfFrequencies; -} \ No newline at end of file +} diff --git a/Plugins/eXiSoundVis/Source/eXiSoundVis/Public/SoundVisComponent.h b/Plugins/eXiSoundVis/Source/eXiSoundVis/Public/SoundVisComponent.h index 089ec7f..aa668db 100644 --- a/Plugins/eXiSoundVis/Source/eXiSoundVis/Public/SoundVisComponent.h +++ b/Plugins/eXiSoundVis/Source/eXiSoundVis/Public/SoundVisComponent.h @@ -134,14 +134,14 @@ public: /// Functions to load Data from the HardDrive // Function to load a sound file from the HD - void LoadSoundFileFromHD(const FString& InFilePath); + bool LoadSoundFileFromHD(const FString& InFilePath); // Function to fill in the RawFile sound data into the USoundWave object bool FillSoundWaveInfo(class USoundWave* InSoundWave, TArray* InRawFile); /// Function to decompress the compressed Data that comes with the .ogg file - void GetPCMDataFromFile(class USoundWave* InSoundWave); + bool GetPCMDataFromFile(class USoundWave* InSoundWave); /// Function to calculate the frequency spectrum @@ -158,6 +158,8 @@ public: // DEBUG Test function to check if Task can call stuff in here void Notify_SoundDecompressed(); + void Notify_FailedToDecompress(); + // Function that is looped to handle the calculation of the FrequencySpectrum UFUNCTION() void HandleFrequencySpectrumCalculation(); @@ -171,7 +173,7 @@ public: * */ UFUNCTION(BlueprintCallable, meta = (DisplayName = "Load Sound File"), Category = "SoundVis | SoundFile") - void BP_LoadSoundFileFromHD(const FString InFilePath); + bool BP_LoadSoundFileFromHD(const FString InFilePath); /** * Will get an Array of Names of the Found SoundFiles