x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Multiple Audio Decompressing Threads?

Hey there,

I've got a question about Threading. I checked out the normal Multithread Wiki post by Rama and the TaskGraph:

https://wiki.unrealengine.com/Multi-Threading:_How_to_Create_Threads_in_UE4 https://wiki.unrealengine.com/Multi-Threading:_Task_Graph_System

What do you want to achieve?

I want to be able to Decompress Audio, not one Audio file after another, but 1 to N different amounts of Audio files at the same time. I already got i working via the "How to Create Threads in UE4" Wiki entry.

But for that, I currently need to start that one thread, have a Timer listen to the Thread and then, after the Thread is finished, start the next one.

That's why i checked out the TaskGraphSystem. While the Threads getting called, i can't really access the Tasks.

Inside of the Decompress Function, that will be called in the Run,DoWork or what ever it's called, function, i use a USoundWave Pointer which i use and fill with data. The USoundWave Object will get passed when creating the thread, data will be used, data will be filled and the USoundWave Object needs to get back to the original class that created the Thread.

The class is a UActorComponent Child. It loads a SoundFile from the HDD, packs the compressed Data into the USoundWave object and then starts a Thread to decompress it. And i want to load multiple at the same time.

But i can't manage to access the Task from the TaskGraph. And if i pass the task a Pointer to the ActorComponent and let it call and pass the USoundWave Object back to the Component, it crashs.

So i can't manage to get the USoundWave pointer back from the Task.

Can anyone guide me into the correct direction of what to use how to?

  • 1 or Multiple Threads simultaneously

  • Pass USoundWave Pointer on Creation

  • Get USoundWave Pointer back after Thread finished

That's "all" i need.

If you need more information, please tell me (:

Product Version: UE 4.11
Tags:
more ▼

asked Apr 16 '16 at 10:06 PM in C++ Programming

avatar image

eXi
6.7k 330 181 462

avatar image Minus_Kelvin STAFF Apr 17 '16 at 10:39 PM

UE4 is already decompressing audio files asynchronously using the task graph system. Why are you trying to do it over?

On PC, there are "sound groups" that group audio assets together and allow the ability to automatically trigger real-time decompression vs "asyncronous full-decompression on load behavior". The group definition and behaviors are defined in engine ini files.

The current default sound group fully decompresses sounds into memory on load (asynchronously) if the sound file is longer than 5 seconds. Longer sound files sound files will be real-time decompressed using the task graph system.

4.12 has some improvements to the system so that asynchronously decoded buffers will be submitted from the xaudio2 thread and new tasks will be launched from the xaudio2 thread when xaudio2 buffers are completed (OnBufferEnd). This prevents audio buffer underruns for real-time async decompression during heavy CPU usage on the main thread.

avatar image eXi Apr 18 '16 at 12:24 AM

I'm loading Audio Files from the HDD and then decompressing them while the game runs. Then I use the decompressed Data to get the Frequency Spectrum via FFT.

That's similar to the Audio Visualization Plugin that Epic has in the Engine. Despite the fact that my Plugin actually calculates the correct spectrum and can be packaged.

I didn't know that the Engine already uses the TaskGraph System, as I'm totally new to this. For the 4.10 Version of the Plugin, I just used the FRunnable to decompress it when needed.

In which classes should I look to find code examples for this? Currently it loads .ogg files. :D It's just a hobby project. I don't actually know what I'm doing, but I want to learn a bit more about the threading and create a better 4.11 Version of my plugin.

It would be really helpful to get a good solution for decompressing the .ogg files (and later maybe .wav files too). I tried using the "FAsyncAudioDecompressor" or what ever its called, but couldn't get the correct sample data from it.

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question