Prevent Plugin from Locking when Heavy Processing + Adding Process Indicator [Multithreading?]

Hi everyone,

I’m creating an ARA plugin that makes use of ARA’s ability to read entire audiosources at once, which I am using CURL to be processed through the network and receive processed audio data. Basically, I am extracting the audio from the DAW as a .wav file, sending it via CURL for processing, receiving back a processed .wav file, then playing it back.

The issue I’m facing right now is that when the CURL call is happening, the plugin/DAW sort of “locks up” and I get the spinning wheel of death on my mac, during which I can’t perform any action on the plugin/DAW. The process is quite heavy so it takes up to a minute when making this call on a 3 minute long-ish wav file.

My question may be a bit broad, but what would be the best way to 1) prevent the plugin/DAW from locking up during this CURL call and 2) display a sort of “progress bar” that indicates how much of the processing is done? I have a pretty good idea about 2) but I’m mostly looking for an answer for 1). Should I be doing some kind of multi-thread processing? If so, what’s the best way to approach multi-threading in JUCE?

Any kind of pointers will help, thank you very much.

I’m not very familiar with what you try to achieve, but it seems that the DAW hangs because you are running a heavy task on the Message Thread. You indeed should not do that.

Instead, you should run this task on a separate thread. You can use a simple std::thread and detach it. But since you also want a progress bar, you should look at Juce’s ThreadWithProgressWindow. It does exactly what you want.

Careful though, you say you are building a plugin, so you might want to avoid popup windows, especially modal ones like ThreadWithProgressWindow. So maybe you should instead bake a progress bar inside your already existing plugin editor.

Thanks! Your advice is a lot of help.

Instead of curl you could also have a look at DownloadTask, which is designed to download in the background and you can use the Listener to display progress.