So after playing around with some things, I have discovered a few new issues.
a) The vorbis header file is only for loading in OGG files. The issue here is that (from my understanding) UE4 converts everything to an OGG file during runtime in order to have a consistant audio format for the application.
b) the code I most recently posted is ONLY for loading in raw OGG files, and should not be used.
c) I am getting closer to understanding what is happening, because i have gotten this error message during a full crash of unreal engine during playback in the PIE
Assertion failed: Wave->
GetPrecacheState() == ESoundWavePrecacheState::Done [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/Windows/XAudio2/Private/XAudio2Buffer.cpp] [Line: 364]
Will do some more reasearch on the XAudion2Buffer, but if anyone has some insight that would be great!
Current Code
if (WaveInfo.ReadWaveInfo(rawFile.GetData(), rawFile.Num()))
{
//************************************************
//CREATES THE SOUNDWAVE OBJECT AND ENSURES IT IS NOT NULL
//************************************************
USoundWave* sw = NewObject<USoundWave>(USoundWave::StaticClass()); //creates a placeholder SoundWave on the stack
if (!sw)
{
UE_LOG(LogTemp, Error, TEXT("There was a nullptr when creating the USoundWave object."));
return nullptr; //checks to be sure it was created, if not return NullPtr
}
//************************************************
//FILLS THE SOUNDWAVE DATA USING THE USOUNDWAVE NATIVE FUNCTIONS
//************************************************
int32 DurationDiv = *WaveInfo.pChannels * *WaveInfo.pBitsPerSample * *WaveInfo.pSamplesPerSec; //calucates the duration divider const
if (DurationDiv) //IF dureation div is not null
{
//PRE Debug logs
UE_LOG(LogTemp, Log, TEXT("SQ NumChannels-> %i"), *WaveInfo.pChannels);
UE_LOG(LogTemp, Log, TEXT("SQ Duration-> %f"), *WaveInfo.pWaveDataSize * 8.0f / DurationDiv);
UE_LOG(LogTemp, Log, TEXT("SQ RawPCMDataSize-> %i"), WaveInfo.SampleDataSize);
UE_LOG(LogTemp, Log, TEXT("SQ SampleRate-> %u"), *WaveInfo.pSamplesPerSec);
// Fill in all the Data we have
sw->DecompressionType = EDecompressionType::DTYPE_RealTime;
sw->SoundGroup = ESoundGroup::SOUNDGROUP_Default;
sw->NumChannels = *WaveInfo.pChannels;
sw->Duration = *WaveInfo.pWaveDataSize * 8.0f / DurationDiv; ;
sw->RawPCMDataSize = WaveInfo.SampleDataSize;
sw->SetSampleRate(*WaveInfo.pSamplesPerSec);
//POST Debug logs
UE_LOG(LogTemp, Log, TEXT("SW NumChannels-> %i"), sw->NumChannels);
UE_LOG(LogTemp, Log, TEXT("SW Duration-> %f"), sw->Duration);
UE_LOG(LogTemp, Log, TEXT("SW RawPCMDataSize-> %i"), sw->RawPCMDataSize);
UE_LOG(LogTemp, Log, TEXT("SW SampleRate-> %u"), sw->__PPO__SampleRate);
}
else
{
UE_LOG(LogTemp, Error, TEXT("There was an error reading data from WaveInfo. Duration Div Error."));
return nullptr;
}
//************************************************
//INVALIDATES COMPRESSED DATA, AND WRITES THE RAW DATA TO THE RAW PCM DATA OF THE NEW SOUNDWAVE
//************************************************
sw->InvalidateCompressedData(); //changes the GUID and flushes all the compressed data
sw->RawData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(sw->RawData.Realloc(rawFile.Num()), rawFile.GetData(), rawFile.Num());
sw->RawData.Unlock();
return sw;
}
else
{
return nullptr;
}
}