diff --git a/RuntimeAudioImporter/Source/RuntimeAudioImporter/Private/RuntimeAudioImporterLibrary.cpp b/RuntimeAudioImporter/Source/RuntimeAudioImporter/Private/RuntimeAudioImporterLibrary.cpp index 74bdaec..7795646 100644 --- a/RuntimeAudioImporter/Source/RuntimeAudioImporter/Private/RuntimeAudioImporterLibrary.cpp +++ b/RuntimeAudioImporter/Source/RuntimeAudioImporter/Private/RuntimeAudioImporterLibrary.cpp @@ -77,7 +77,7 @@ void unreal_free(void* p, void* pUserData) FMemory::Free(p); } -bool URuntimeAudioImporterLibrary::ExportSoundWaveToFile(USoundWave* SoundWaveToExport, FString PathToExport, bool Faster) +bool URuntimeAudioImporterLibrary::ExportSoundWaveToFile(USoundWave* SoundWaveToExport, FString PathToExport) { uint8* PCMData = SoundWaveToExport->RawPCMData; size_t PCMDataSize = SoundWaveToExport->RawPCMDataSize; @@ -93,15 +93,9 @@ bool URuntimeAudioImporterLibrary::ExportSoundWaveToFile(USoundWave* SoundWaveTo drwav_uint64 framesToWrite = PCMDataSize / sizeof(DR_WAVE_FORMAT_PCM) / SoundWaveToExport->NumChannels; - if (Faster) { - ChannelCount = SoundWaveToExport->NumChannels; - SampleRate = FGenericPlatformMath::RoundToInt((framesToWrite / (float)SoundWaveToExport->GetDuration() * ChannelCount)); - } - else { - TArray NeedlessPCMData; //Needless PCMData array, but without it, it is not possible to get SampleRate - SoundWaveToExport->GetImportedSoundWaveData(*&NeedlessPCMData, *&SampleRate, *&ChannelCount); - NeedlessPCMData.Empty(); - } + ChannelCount = SoundWaveToExport->NumChannels; + SampleRate = FGenericPlatformMath::RoundToInt((framesToWrite / (float)SoundWaveToExport->GetDuration() * ChannelCount)); + drwav wavEncode; drwav_data_format format; diff --git a/RuntimeAudioImporter/Source/RuntimeAudioImporter/Public/RuntimeAudioImporterLibrary.h b/RuntimeAudioImporter/Source/RuntimeAudioImporter/Public/RuntimeAudioImporterLibrary.h index 2b3f4bc..35104e7 100644 --- a/RuntimeAudioImporter/Source/RuntimeAudioImporter/Public/RuntimeAudioImporterLibrary.h +++ b/RuntimeAudioImporter/Source/RuntimeAudioImporter/Public/RuntimeAudioImporterLibrary.h @@ -106,12 +106,11 @@ public: * * @param SoundWaveToExport SoundWave object need to be exported * @param PathToExport Path where to save audio file - * @param Faster Get SampleRate faster. Less clear, but fast. The difference is very insignificant, True is recommended * @return Whether the save was successfull or not * @warning It is very important that USoundWave should not used by the engine so that it can be read from physical memory. */ UFUNCTION(BlueprintCallable, meta = (Keywords = "Exporter, Export, Save, Runtime, WAV"), Category = "RuntimeAudioImporter") - static bool ExportSoundWaveToFile(USoundWave * SoundWaveToExport, FString PathToExport, bool Faster = true); + static bool ExportSoundWaveToFile(USoundWave * SoundWaveToExport, FString PathToExport); private: /**