Login / Register  0 items | $0.00 New @ KVR
Molem7b5
KVRer
 
4 posts since 6 Oct, 2017

Postby Molem7b5; Tue Jan 02, 2018 11:38 am Modulated delay - clicking matching LFO Rate

I'm pretty new to all this so no doubt I'm doing something stupid.

I'm in the process of trying to make a bog-standard modulated delay unit using the RackAFX development environment.

I've coded a wave table oscillator that works fine by itself, but when I integrate this for use in a modulated delay line, the sine wave setting causes clicks that a match whatever I've got the rate set to. This doesn't however happen when I have it set to Triangle.

I'm thinking it might have something to do with my wrapping, but I use the same implementation to check and wrap my read and write index for the delay buffer and that seems to work fine.

Anyone got any ideas? I can post sections of my code if needed.
mystran
KVRAF
 
4674 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Tue Jan 02, 2018 6:18 pm Re: Modulated delay - clicking matching LFO Rate

Molem7b5 wrote:I've coded a wave table oscillator that works fine by itself, but when I integrate this for use in a modulated delay line, the sine wave setting causes clicks that a match whatever I've got the rate set to. This doesn't however happen when I have it set to Triangle.

I'm thinking it might have something to do with my wrapping, but I use the same implementation to check and wrap my read and write index for the delay buffer and that seems to work fine.


There are a bunch of things that could go wrong, but first sanity check that your sine period is correct (eg. [0, 2*pi]) since that would obviously cause problems otherwise.

Then I'm not entirely sure why you're integrating the waveform, but if you're doing it numerically, keep in mind that you will get some error accumulation that you will have to deal with one way or another. One option is to use leaky integrator, the other option is to let your LFO generate an analytically integrated waveform directly.

Either way, I'd probably debug it by having the code just output the raw modulated delay time "as audio" and see if looks like something continuous. If it does, then you can assume that the problem is in delay code (eg. interpolation or wrapping or whatever). If the control signal looks wrong already, then you know to fix that first.
Image <- plugins | forum
Molem7b5
KVRer
 
4 posts since 6 Oct, 2017

Postby Molem7b5; Wed Jan 03, 2018 1:33 am Re: Modulated delay - clicking matching LFO Rate

Thanks!

Sorry, I use the term integrate incorrectly. I just meant that when I use the WTO to modulate my delay line I hear clicks on the Sine setting.

Next silly questions - How would I go about outputting the raw modulated delay time?

Currently I can look at the audio output from my WTO (through RackAFX's built in analyser) as a stand alone synth plugin and it looks fine. As in, it looks as a sine wave should.
stratum
KVRian
 
1439 posts since 29 May, 2012

Postby stratum; Wed Jan 03, 2018 3:50 am Re: Modulated delay - clicking matching LFO Rate

What does WTO stand for? If Wave table oscillator the value jumps in its output can cause clicking sounds.
~stratum~
Molem7b5
KVRer
 
4 posts since 6 Oct, 2017

Postby Molem7b5; Wed Jan 03, 2018 4:02 am Re: Modulated delay - clicking matching LFO Rate

Ahhh okay, that makes sense. But then wouldn't that also be audible listening to it as a standalone synth plugin? i.e listening it's output
stratum
KVRian
 
1439 posts since 29 May, 2012

Postby stratum; Wed Jan 03, 2018 4:09 am Re: Modulated delay - clicking matching LFO Rate

Sure, but if you are using it as a LFO modulating another signal, it will be heard in a different way.
~stratum~
Molem7b5
KVRer
 
4 posts since 6 Oct, 2017

Postby Molem7b5; Wed Jan 03, 2018 4:34 am Re: Modulated delay - clicking matching LFO Rate

Okay, because listening to the Sine wave standalone it sounds fine. It's only when I use it to modulate I get the clicks.

Maybe it I try and output the numerical values and see if there is a noticeable jump?
stratum
KVRian
 
1439 posts since 29 May, 2012

Postby stratum; Wed Jan 03, 2018 4:42 am Re: Modulated delay - clicking matching LFO Rate

Doing that both on the LFO and final output together with any intermediate variables used during calculation might be a good idea.

I remember using oversampling and low pass filtering for a similar effect years ago to avoid clicks (i.e. to filter them out, actually) but since I don't remember that code well that might be misleading.
~stratum~
mystran
KVRAF
 
4674 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Wed Jan 03, 2018 7:21 am Re: Modulated delay - clicking matching LFO Rate

Molem7b5 wrote:Okay, because listening to the Sine wave standalone it sounds fine. It's only when I use it to modulate I get the clicks.

Maybe it I try and output the numerical values and see if there is a noticeable jump?


It's entirely possible that your modulation signal is fine and the problem is somewhere else and the point of this exercise was to try and figure out where to look next.

What I'd probably try next would be to look at the raw read/write positions (maybe before and after wrapping), using whatever technique you find most convenient (eg. plot them, output them as audio, sprintf to OutputDebugString or even add a tracepoint in a debugger) and see if they look sensible.

If you're using a buffer (eg. array, std::vector, or similar) that doesn't have bound checking built in, then it's also good idea to add some sanity checking code where you perform your reads and writes and check that your indexes are actually within buffer bounds; it's pretty easy to go "off by one" when trying to efficiently convert times to buffer indexes and such.

Then you can put the checks within an #ifndef NDEBUG or some such preprocessor conditional so you don't need to pay any performance penalties in your final code, but can still enable them later again if you hit a similar problem again.

In general, writing a bunch of debug code to figure out what your actual code is doing is often very helpful and not something to be afraid of.
Image <- plugins | forum
DNAdisaster
KVRist
 
36 posts since 31 Jan, 2011

Postby DNAdisaster; Sun Jan 07, 2018 6:13 pm Re: Modulated delay - clicking matching LFO Rate

Probably getting ahead of myself here, but in addition to placing assert statements directly in your code (which is a good idea), you might also consider writing an automated test for this. Maybe generate a few periods of a sine using std::sin for your reference signal, and then use your own code to generate the same signal. Then go through the two arrays sample by sample and check that the error between them is less than some tolerance. Something like this:
Code: Select all
void test_sine() {
    std::array<double, N> ref_sine;
    std::array<double, N> my_sine;
    // ...generate several periods of the two signals...
    for(int i=0; i<N; i++){
        double err = std::abs(ref_sin[i] - my_sin[i])
        assert(err < ERR_TOL);
    }
}

If it fails, looking at it in a debugger should shed some light on where the defect is. If not, you know that the defect is most likely outside your sine generator code. External tests have the advantage of being able to verify components of your code independently from one another, and most importantly run them under controlled conditions. It'll also pay off later on to have a collection of test cases you can use as sanity checks.

Moderator: Moderators (Main)

Return to DSP and Plug-in Development