JUCE DSP Module coming July 27th?

The whole OS is screwing up the DAW thread pool. Moreover proper DAW probably do work stealing algorithm instead of one thread per plugin.

People ask for multithreaded rendering even in a single instrument.

I have just tried to use the convolution engine with a 5 seconds IR in stereo, with both JUCE and Intel MKL FFT on Windows, it would be better with not uniform partitioned convolution of course but it’s already quite good in my opinion.

Intel FFT will speed up the process, but JUCE FFT has been optimized a little already (it’s 2-3 times faster than JUCE 5.0 FFT) and anyway the heaviest process in CPU now is the convolution (multiplications) and not the FFT anymore.

Have a try and tell me what you think of the CPU load :wink:

Thanks for teaching me my job…
Yes, the OS screws up the thread pool, but that’s not a reason to make it worse. You can assign priorities to threads, but if everyone creates a high priority thread pool, you are slowing everyone down because of the context switch.
Who said anything about creating one thread per plugin? I’m talking about a thread POOL.

  1. As SKot said, the partitioned convolution thread is not required to be a realtime thread and AFAIK don’t need to be.
  2. if you want a single instrument to be multi proc rendered, you don’t have the choice, so…

I know also that some people do the stereo processing using the audio thread and an additional one for the right channel…

Anyway, the not uniform partitioned algorithm seems to be easy to implement for testing purposes, at least to have an idea of what happens in most DAWs in stressing situations. But the most problematic part there was my first point :slight_smile:

You don’t seem to know the issues with multithreading and heavy computations, so let’s try it one last time.
You have a box with 8 cores. Your app launches 8 threads that need to react in realtime, so high priority. As the computations on each thread is quite intense, they are occupied let’s say at 80%.
If one of these threads ends up in a plugin that uses its own threads, these threads will still time from one of the original thread pool, which can get late and thus create audible “cracks”.

The only option here is not to context switch, so not create additional threads and use the original thread pool to add tasks on it. And hope you have enough computation power,s till.

if you have 80% taken then the context switching will not make you miss the deadline unless the job done by the plugin take a large amount of CPU.
And if this case, you will be screwed anyway as the 20% left from your original thread pool will not be enough.
Context switching used to be slow but it’s way better since i7.
Obviously you think that you know way more than me and I think the opposite so it’s going to be a moot point very quickly.
Don’t want to derail the thread more. Sorry about that guys.

alloca uses the same mechanism as allocating local variables on the stack - it simply pushes the stack pointer further by the given amount - no locking or spinning. It doesn’t even do any checks (which is good from a performance and exception safety standpoint) so you should be sure that you know the upper limit of the allocation or you may end up with a stack overflow.

It’s perfectly ok to use it in an audio callback for small amounts of memory. Granted, it is a bit archaic and smells like C :slight_smile: so I try to avoid it.

Even C89, I suppose that VLA are the better way to do them. But as C++11 doesn’t have it, I agree.

Cool! a lot to look at :slight_smile:
Just 2 minor things :

JUCE_SNAP_TO_ZERO(n) is now defined in juce_FloatVectorOperations.h ?
note that the #undef JUCE_SNAP_TO_ZERO is still there at the end of IIRFilter.cpp

All Ocillator's comments are a bit off (copy/paste from the Gain class)
/** Applies a new gain as a linear value. */
void setFrequency (NumericType newGain)

Great work on the filter design stuff, Ivan! But only lowpass versions?
Will you do also bandpass and highpass?

Thanks OBO !

Good point again. Can I ask you what would you do with a high order FIR/IIR filter which is a band-pass or a high-pass filter ?

I never had any use for them personally yet, and I asked to the other guys what they would do with them and they didn’t know either. For filtering audio signals I use only low order IIR filters or transformations from them to make linear phase FIR filters that can be used for EQ purposes. And I use the high order filters for resampling, but only lowpass ones and that’s all.

That’s why I decided to put only lowpass filters there for now, but I might change my mind :wink:

Thanks for questioning. Maybe I’m on a wrong path but I thought of making a pitch shifter by a bandpass filterbank with sharp higher order bandpass filters. Then frequency shifting (as opposed to pitch shifting) each band using hilbert/allpass.

The threading model to use is multiple background threads working at a lower priority swapping input / output with a high priority audio thread. This introduces (at least) one buffer of latency, but it is stable, and doesn’t interfere with a host’s audio thread pool.

I see, indeed there are a lot of things that could be done with a bank of bandpass filters. But I guess that you would need to take a special care of the overlapping issues, and I’m not sure any of the generic filter design methods could do this for you.

When I need to do clean band separation, I use specific algorithms or functions to set the frequencies and resonances of biquads, or linkwitz-riley filters etc. I even saw a patent recently about phase vocoders using linear phase bandpass filters specifically designed :smile:

Thanks, Ivan. Great work!

3 Likes

It looks like the DSP modules haven’t been added to the online API docs… Is there anything which covers the new classes… other than pulling the commit and looking through the source code?

Cheers,

Rail

1 Like

Use this quick and dirty meanwhile:
https://ffaudio.github.io/JUCE/namespacejuce_1_1dsp.html

1 Like

Thanks Daniel

Rail

I see a typo…

static void 	ellipicIntegralK (double k, double &K, double &Kp) noexcept

Rail