mirror of
https://github.com/storytold/RuntimeAudioImporter.git
synced 2026-10-09 00:09:48 +00:00
Correct filling of LPCM data, working with compressed formats
This commit is contained in:
+10
-15
@@ -218,14 +218,19 @@ class USoundWave* URuntimeAudioImporterLibrary::GetSoundWaveObject(const uint8*
|
|||||||
Status = TranscodingStatus::UnsupportedBitDepth;
|
Status = TranscodingStatus::UnsupportedBitDepth;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
sw->InvalidateCompressedData();
|
|
||||||
sw->RawData.Lock(LOCK_READ_WRITE);
|
sw->RawData.Lock(LOCK_READ_WRITE);
|
||||||
void* LockedData = sw->RawData.Realloc(WaveDataSize);
|
FMemory::Memcpy(sw->RawData.Realloc(WaveDataSize), WaveData, WaveDataSize);
|
||||||
FMemory::Memcpy(LockedData, WaveData, WaveDataSize);
|
|
||||||
sw->RawData.Unlock();
|
sw->RawData.Unlock();
|
||||||
|
|
||||||
|
OnProgress_Internal(85);
|
||||||
|
|
||||||
|
// RawPCMDataSize = WaveDataSize - 44 bytes (the header of the WAV data) = SampleDataSize
|
||||||
|
sw->RawPCMDataSize = WaveInfo.SampleDataSize;
|
||||||
|
sw->RawPCMData = (uint8*)FMemory::Malloc(sw->RawPCMDataSize);
|
||||||
|
FMemory::Memmove(sw->RawPCMData, WaveData, WaveDataSize);
|
||||||
|
|
||||||
// Callback Dispatcher OnProgress (not completely accurate implementation)
|
// Callback Dispatcher OnProgress (not completely accurate implementation)
|
||||||
OnProgress_Internal(80);
|
OnProgress_Internal(90);
|
||||||
|
|
||||||
int32 DurationDiv = *WaveInfo.pChannels * *WaveInfo.pBitsPerSample * *WaveInfo.pSamplesPerSec;
|
int32 DurationDiv = *WaveInfo.pChannels * *WaveInfo.pBitsPerSample * *WaveInfo.pSamplesPerSec;
|
||||||
if (DurationDiv)
|
if (DurationDiv)
|
||||||
@@ -244,7 +249,7 @@ class USoundWave* URuntimeAudioImporterLibrary::GetSoundWaveObject(const uint8*
|
|||||||
sw->SoundGroup = ESoundGroup::SOUNDGROUP_Default;
|
sw->SoundGroup = ESoundGroup::SOUNDGROUP_Default;
|
||||||
|
|
||||||
// Callback Dispatcher OnProgress (not completely accurate implementation)
|
// Callback Dispatcher OnProgress (not completely accurate implementation)
|
||||||
OnProgress_Internal(85);
|
OnProgress_Internal(95);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -270,16 +275,6 @@ class USoundWave* URuntimeAudioImporterLibrary::GetSoundWaveObject(const uint8*
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sw->RawPCMData = (uint8*)FMemory::Malloc(sw->RawPCMDataSize);
|
|
||||||
|
|
||||||
// Callback Dispatcher OnProgress (not completely accurate implementation)
|
|
||||||
OnProgress_Internal(90);
|
|
||||||
|
|
||||||
FMemory::Memcpy(sw->RawPCMData, WaveInfo.SampleDataStart, sw->RawPCMDataSize);
|
|
||||||
|
|
||||||
// Callback Dispatcher OnProgress (not completely accurate implementation)
|
|
||||||
OnProgress_Internal(95);
|
|
||||||
|
|
||||||
if (!sw)
|
if (!sw)
|
||||||
{
|
{
|
||||||
Status = TranscodingStatus::InvalidUSoundWave;
|
Status = TranscodingStatus::InvalidUSoundWave;
|
||||||
|
|||||||
Reference in New Issue
Block a user