Hello everyone
It’s me again with a potentially silly question on parameters for UGens. I am experiencing something that I simply don’t understand. I have a simple comb filter UGen which has an audio input, a delaytime, a feedback amount, interpolation type and maxdelay parameter.
I have setup two different calculation functions. One for the case where delaytime is control rate, and one if it is audio rate.
If I set my comb filter to use cubic interpolation and modulate the delaytime with an audio rate ugen like LFPar.ar, it sounds great. No artifacts. If I then use the exact same LFPar ugen to modulate it with the exact same settings but with LFPar as a .kr, my comb filter UGen sounds crunchy and artifacty. I’ve tried different smoothing strategies but this sounds like it is beyond smoothing and just me misunderstanding something.
My .sc class looks like this:
NoComb : UGen {
*ar { |input, delaytime=0.5, feedback=0.25, interpolation=2, maxdelay=1|
^this.multiNew('audio', input, delaytime, feedback, interpolation, maxdelay);
}
}
And the two calculation functions (note I use an enum to keep track of input indices):
// Audio rate delaytime
void NoComb::next_ak(int nSamples) {
float *outbuf = out(0);
m_delay.setFeedbackamount(in0(Feedback));
for (int i = 0; i < nSamples; ++i) {
m_delay.setDelaytime(in(DelayTime)[i]);
outbuf[i] = m_delay.process(in(Input)[i]);
}
}
// Control rate delaytime
void NoComb::next_kk(int nSamples) {
const float *input = in(Input);
float *outbuf = out(0);
m_delay.setFeedbackamount(in0(Feedback));
m_delay.setDelaytime(in(DelayTime)[0]);
for (int i = 0; i < nSamples; ++i) {
outbuf[i] = m_delay.process(input[i]);
}
}
The input rate of my delaytime parameter is checked in the constructor and the appropriate calculation function is set there:
if (!m_delay.allocSuccesful()) {
mCalcFunc = make_calc_function<NoComb, &NoComb::clear>();
clear(1);
} else {
if (isAudioRateIn(DelayTime)) {
mCalcFunc = make_calc_function<NoComb, &NoComb::next_ak>();
next_ak(1);
} else {
mCalcFunc = make_calc_function<NoComb, &NoComb::next_kk>();
next_kk(1);
}
}
What am I missing? I’ve been scratching my head over this for a while and cannot understand what the problem seems to be. Thanks for your help once again!