|
@ -41,7 +41,7 @@ void USoundVisComponent::TickComponent(float DeltaTime, ELevelTick TickType, FAc |
|
|
|
|
|
|
|
|
/// Functions to load Data from the HardDrive
|
|
|
/// Functions to load Data from the HardDrive
|
|
|
|
|
|
|
|
|
void USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) |
|
|
|
|
|
|
|
|
bool USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) |
|
|
{ |
|
|
{ |
|
|
// Create new SoundWave Object
|
|
|
// Create new SoundWave Object
|
|
|
CompressedSoundWaveRef = NewObject<USoundWave>(USoundWave::StaticClass()); |
|
|
CompressedSoundWaveRef = NewObject<USoundWave>(USoundWave::StaticClass()); |
|
@ -50,7 +50,7 @@ void USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) |
|
|
if (!CompressedSoundWaveRef) { |
|
|
if (!CompressedSoundWaveRef) { |
|
|
|
|
|
|
|
|
PrintError(TEXT("Failed to create new SoundWave Object!")); |
|
|
PrintError(TEXT("Failed to create new SoundWave Object!")); |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If true, the Sound was successfully loaded
|
|
|
// If true, the Sound was successfully loaded
|
|
@ -64,6 +64,7 @@ void USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) |
|
|
|
|
|
|
|
|
if (bLoaded) |
|
|
if (bLoaded) |
|
|
{ |
|
|
{ |
|
|
|
|
|
UE_LOG(LogTemp, Error, TEXT("LoadSoundFileFromHD 0")); |
|
|
// Fill the SoundData into the SoundWave Object
|
|
|
// Fill the SoundData into the SoundWave Object
|
|
|
if (RawFile.Num() > 0) { |
|
|
if (RawFile.Num() > 0) { |
|
|
|
|
|
|
|
@ -92,11 +93,11 @@ void USoundVisComponent::LoadSoundFileFromHD(const FString& InFilePath) |
|
|
if (!bLoaded) { |
|
|
if (!bLoaded) { |
|
|
|
|
|
|
|
|
PrintError(TEXT("Something went wrong while loading the Sound Data!")); |
|
|
PrintError(TEXT("Something went wrong while loading the Sound Data!")); |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Fill the PCMSampleBuffer
|
|
|
// Fill the PCMSampleBuffer
|
|
|
GetPCMDataFromFile(CompressedSoundWaveRef); |
|
|
|
|
|
|
|
|
return GetPCMDataFromFile(CompressedSoundWaveRef); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool USoundVisComponent::FillSoundWaveInfo(USoundWave* InSoundWave, TArray<uint8>* InRawFile) |
|
|
bool USoundVisComponent::FillSoundWaveInfo(USoundWave* InSoundWave, TArray<uint8>* InRawFile) |
|
@ -124,18 +125,18 @@ bool USoundVisComponent::FillSoundWaveInfo(USoundWave* InSoundWave, TArray<uint8 |
|
|
|
|
|
|
|
|
/// Function to decompress the compressed Data that comes with the .ogg file
|
|
|
/// Function to decompress the compressed Data that comes with the .ogg file
|
|
|
|
|
|
|
|
|
void USoundVisComponent::GetPCMDataFromFile(USoundWave* InSoundWave) |
|
|
|
|
|
|
|
|
bool USoundVisComponent::GetPCMDataFromFile(USoundWave* InSoundWave) |
|
|
{ |
|
|
{ |
|
|
if (InSoundWave == nullptr) { |
|
|
if (InSoundWave == nullptr) { |
|
|
|
|
|
|
|
|
PrintError(TEXT("Passed SoundWave pointer is a nullptr!")); |
|
|
PrintError(TEXT("Passed SoundWave pointer is a nullptr!")); |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (InSoundWave->NumChannels < 1 || InSoundWave->NumChannels > 2) { |
|
|
if (InSoundWave->NumChannels < 1 || InSoundWave->NumChannels > 2) { |
|
|
|
|
|
|
|
|
PrintError(TEXT("SoundWave Object has not the right amount of Channels. Plugin only supports 1 or 2!")); |
|
|
PrintError(TEXT("SoundWave Object has not the right amount of Channels. Plugin only supports 1 or 2!")); |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (GEngine) |
|
|
if (GEngine) |
|
@ -151,13 +152,14 @@ void USoundVisComponent::GetPCMDataFromFile(USoundWave* InSoundWave) |
|
|
|
|
|
|
|
|
// Creates a new DecompressWorker and starts it
|
|
|
// Creates a new DecompressWorker and starts it
|
|
|
InitNewDecompressTask(InSoundWave); |
|
|
InitNewDecompressTask(InSoundWave); |
|
|
|
|
|
return true; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
|
|
|
|
|
|
PrintError(TEXT("Couldn't get a valid Pointer to the Main AudioDevice!")); |
|
|
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<float>& OutFrequencies) |
|
|
void USoundVisComponent::CalculateFrequencySpectrum(USoundWave* InSoundWaveRef, const float InStartTime, const float InDuration, TArray<float>& OutFrequencies) |
|
@ -399,9 +401,9 @@ void USoundVisComponent::HandleFrequencySpectrumCalculation() |
|
|
|
|
|
|
|
|
/// Blueprint Versions of the File Data Functions
|
|
|
/// 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<FString>& OutSoundFileNamesWithPath, TArray<FString>& OutSoundFileNamesWithoutPath) |
|
|
void USoundVisComponent::BP_LoadAllSoundFileNamesFromHD(bool& bLoaded, const FString InDirectoryPath, const bool bInAbsolutePath, const FString InFileExtension, TArray<FString>& OutSoundFileNamesWithPath, TArray<FString>& OutSoundFileNamesWithoutPath) |
|
@ -653,4 +655,4 @@ void USoundVisComponent::BP_GetAverageFrequencyValueInRange(USoundWave* InSoundW |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
OutAverageFrequency = ValueSum / NumberOfFrequencies; |
|
|
OutAverageFrequency = ValueSum / NumberOfFrequencies; |
|
|
} |
|
|
|
|
|
|
|
|
} |