gtreshchev / RuntimeAudioImporter

Runtime Audio Importer plugin for Unreal Engine. Importing audio of various formats at runtime.
MIT License
308 stars 67 forks source link

Import sound wave as a UASSET #59

Closed vaibhavb09 closed 4 months ago

vaibhavb09 commented 5 months ago

Is there a way to save the imported sound wave as a uasset? The only options I found were to either use the imported sound wave at runtime immediately or to save it as a .wav/.mp3 file. I want to save this as a uasset. How can I achieve this?

gtreshchev commented 5 months ago

Depending on your specific objectives, there may be two answers:

  1. If you want to pre-import audio data as a uasset, please refer to this documentation page for more information. Essentially, you should rename your audio file to have the .imp format (short for "import") and drag it into your editor. This will create a pre-imported RuntimeAudioImporter-specific sound asset. Afterward, you can import it using the ImportAudioFromPreImportedSound function.

  2. If you want to save your audio data to a uasset at runtime, I don't think it's supported by the engine at the moment, since the UFactory used for creating new assets is editor-only, and you can only do this if the editor code is available to you. So, if you want to save the audio data, you could instead export your audio from the imported sound wave to a separate file in a temporary folder for game-specific files using the ExportSoundWaveToFile function, and use a compressed audio format such as OGG Vorbis. Another option is to use USaveGame files, create a field to store TArray<uint8> for your saved audio data, and populate it with the audio data obtained from the ExportSoundWaveToBuffer function. Please refer to this documentation page related to exporting audio data for more information.

vaibhavb09 commented 5 months ago

It's not at runtime per se. It's in editor. I am writing a editor utility to get audio data from an api. Instead of saving it as a file in .wav or .mp3 format, I want to save it as a uasset so that it can be set as a reference in other uasset.

vaibhavb09 commented 5 months ago

Is there a way to save the imported sound wave as a uasset in the editor?

P.S.: Sorry had accidentally closed the issue.

gtreshchev commented 5 months ago

@vaibhavb09 Yes, it is possible via the pre-imported sound assets feature: https://github.com/gtreshchev/RuntimeAudioImporter/wiki/2.-Pre-Importing-Audio-Data