JUCE 6 DelayLine processor

Hello, I am playing around with the new DSP modules from JUCE 6. I am trying to set the maxDelayTime using the explicit constructor of the DelayLine class, but with no avail. I don’t understand how to instantiate a templated explicit constructor.

Here are the constructors for the DelayLine

template <typename SampleType, typename InterpolationType = DelayLineInterpolationTypes::Linear>
class DelayLine
    /** Default constructor. */

    /** Constructor. */
    explicit DelayLine (int maximumDelayInSamples);

I am doing this in a processorChain. I’ve never used an explicit constructor before, so the concept is a bit foggy. Couple that with instantiation within a processor chain as well as a templated type and I’m totally confused.

I am committed to JUCE 6 and I know I could accomplish this without the new DelayLine class, so I am really only interested in figuring this particular situation out.

Any help would be appreciated!

explicit just means you can’t use the constructor for implicit conversions. For example:

void someFunction (const DelayLine<float>& delay) ;
// ...
int a = 500;
someFunction(a); // error
someFunction(500); // error
someFunction(DelayLine<float>(a)); // ok
someFunction(DelayLine<float>(500)); // ok
DelayLine<float> delay = 500; // error
DelayLine<float> delay{ 500 }; // ok
someFunction(delay); // ok
1 Like

This is not very pretty but it does compile :

dsp::ProcessorChain<dsp::DelayLine<float>,dsp::Panner<float>> chain;
// to reset the maximum delay time, 
// assign a new instance of the DelayLine at the chain position 0
chain.get<0>() = dsp::DelayLine<float>(10 * 44100);
1 Like

I can’t tell you how much each example you gave helped. Thank you!

Thank you, great to hear from one of the royalty of JUCE

Hey guys, sorry for dragging up an old thread, but I’m having issues with this myself. I’ve only just started looking into the JUCE DSP classes, so be gentle!

I can easily and quickly create a dsp::DelayLine object and use it accordingly, but all attempts to use one within a dsp::ProcessChain have thwarted me. With a non chained dsp::DelayLine object I can process my signal as simple as this:

	void processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override
		juce::dsp::AudioBlock<float> block(buffer);
		juce::dsp::ProcessContextReplacing<float> context(block);

But if I try this with a delay line that is part of a ProcessorChain I get caught here in the DelayLine::proess method:

So it works fine on it’s own, but causes an assert when part of a dsp::ProcessorChain. Here is my prepareToPlay() method:

void prepareToPlay(double newSampleRate, int blockSize) override
	juce::dsp::ProcessSpec spec{ newSampleRate, blockSize, 2 };
	fxChain.get<0>() = dsp::DelayLine<float>(44100);

My processBlock() function is the same as the one outlined above, only this time I’m calling process(context) on the fxChain object.

I’m obviously doing this all wrong so how is one supposed to do this?

p.s. I am not interested in popping and pushing samples to the delay line at this point…

1 Like

What are the values of inputBlock.getNumChannels() and writePos.size()? That should give you a clue what’s going on.

Your prepareToPlay looks a bit suspicious. If you assign a new delayline like that, it will no longer be “prepared”. Does it work if you assign the new delayline before calling fxChain.prepare(spec)?

Thanks @reuk for the prompt reply!

Suspicious indeed. It will work if I assign the new delay line before call prepare, so long as I also grab the newly assigned delay and call its setDelay() method:

void prepareToPlay(double newSampleRate, int blockSize) override
	fxChain.get<0>() = dsp::DelayLine<float>(44100);
	auto& del = fxChain.get<0>();
	juce::dsp::ProcessSpec spec{ newSampleRate, blockSize, 2 };

So I guess this is a solution, but surely there is an easier way of adding a adding a dsp::DelayLine to a dsp::ProcessorChain? Can I not set the initial delay line when I declare my chain:

dsp::ProcessorChain < juce::dsp::DelayLine<float>> fxChain;

I’ve tried all manner of brackets and braces, but can’t seem to figure it out?

As far as I was able to gather, there is no way. IMHO the whole ProcessorChain is unwieldy to use and inflexible and one might just as well not bother using it. (It is claimed by some people using it might result in performance optimizations, but I haven’t seen any concrete benchmark data about that.)


Thanks @xenakios, if you haven’t figured out a way to do this, then I’ve no hope whatsoever! Not using it is not that big a deal as I’m using an AudioprocessorGraph anyway, so I can quickly set up signal chains there. Just so I’m clear, your criticism is directed at the dsp::ProcessorChain rather than the bulk of the DSP classes themselves?

Right, I am this case criticizing only the ProcessorChain. Some of the DSP module classes are quite useful, but it’s just in some cases a pain to attempt to use them with the ProcessorChain. (And there are problems also with the ProcessorDuplicator.)


Thanks, this is good to know :wink: