How do I append music that a user selects into an array?

I have all of my music in my game to be in a .wav format. I want players to be able to add their own music to be played in-game, However it does not seem to be working. I have tried running ‘Create Runtime Audio Importer’, and it seems to work, but it will not append the audio file into my array of ‘Sound Wave Object Referances’. I am willing to send any screenshots of the blueprint that i have, just let me know what you need.

When you create a variable from Create Runtime Audio Importer, does it come in as “Sound Wave Object” or something else? I’d like to see a screenshot. I have used audio a lot haven’t tried the Create Runtime Audio Importer.





Here are all the coding i have. Any questions, just ask.

You seem to not be handling the objects correctly in terms of garbage collection. You should move both the Runtime Audio Importer and Imported Sound Wave objects to separate variables immediately after their creation (the latter is currently moved to an array with a 2 second delay, but it should be moved immediately to prevent premature garbage collection).

I’m not sure exactly how you’re processing the import, but there might be issues with the logic of your blueprint nodes. I recommend adding a way to log the behavior, such as using a print string after key node executions to see if they run as expected, etc.

I seem to have made it work, however, it will not save any of the audios that the player adds. Once, the player quits out of the game, all of the custom audios are gone.

Hi, yes, you’ll need to store them in some way, such as in a separate file to import later, or as a buffer, like an array of bytes. You can use save game files in UE to save and load this data.

For instructions on exporting audio data into a file or buffer, refer to this docs page: Export audio | Georgy Dev Docs
For instructions on using save game files (which is cross-platform and already integrated within UE), follow this page: Saving and Loading Your Game in Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer Community