Recently, I’ve been trying to import audio at runtime, and I’ve come across the great Runtime Audio Importer plugin, which has been super helpful.
Unfortunately, the plugin doesn’t work particularly well in UE5, due to a couple of issues, like SetSoundAssetCompressionType only working in the editor, and SoundWaveProcedural having no obvious way of stopping audio from playing, despite having access to the duration and looping properties.
If a procedural sound reaches the duration, regardless of whether it’s looping or not, the Parse method continues to be called, and AudioComponents playing that sound never change status to “Stopped”.
Even if you stop and destroy the AudioComponent directly, the procedural sound is never cleaned from memory, despite the fact that it shouldn’t be referenced anywhere else.
Talking of being unable to reference it anywhere else, you can only play a procedural sound from one Audio Component, which is quite wasteful in this particular case.
In regards to the SoundWave SoundAssetCompressionType property, without the ability to set this, there is no real option for importing audio at runtime without some kind of dummy SoundWave, since a default SoundWave is built with the compression type “BinkAudio”, meaning that without a decoder set, the engine will throw a null exception.
I can set any of the buffers in a SoundWave, but, I can’t set the compression type? This seems like very strange logic to me.
Can there not be a “RuntimeSoundWave” class, where we can generate sounds during gameplay, and then have them treated like a regular SoundWave? Sounds with a beginning, an end (Audio Components stopped when they reach the end), and cleaned up by the garbage collector when no longer needed?