Page 1 of 1

Phasing in chorus effect?

Posted: Tue Dec 20, 2022 5:47 pm
by poetix
I'm noticing that in a chorus effect I've implemented, there's a phasing/flanging effect on the pure wet signal (i.e. only the delayed/pitch-bent sound) even when the speed and width of the effect are very low. Although it sounds cool in it's own way, it's not what I'm after, and I'm wondering what might be producing it. I'm doing no upsampling/downsampling, just using 3rd-degree Lagrangian interpolation to get the "fractional" delay out of the recording buffer, i.e.

Code: Select all

public double readSample(double pointer) {
    int ptrLeft = (int) pointer;

    double dMinus1 = pointer - ptrLeft;
    if (dMinus1 == 0.0) {
        return buffer.readAt(ptrLeft);
    }

    double dMinus2 = dMinus1 - 1;
    double dMinus3 = dMinus2 - 1;
    double d = dMinus1 + 1;

    double halfDTimesDMinus3 = d * dMinus3 * 0.5;
    double oneSixthDMinus1TimesDMinus2 = dMinus1 * dMinus2 / 6.0;

    double n0 = buffer.readAt(ptrLeft - 1);
    double n1 = buffer.readAt(ptrLeft);
    double n2 = buffer.readAt(ptrLeft + 1);
    double n3 = buffer.readAt(ptrLeft + 2);

    double h0 = -oneSixthDMinus1TimesDMinus2 * dMinus3;
    double h1 = halfDTimesDMinus3 * dMinus2;
    double h2 = -halfDTimesDMinus3 * dMinus1;
    double h3 = d * oneSixthDMinus1TimesDMinus2;

    return (n0 * h0) + (n1 * h1) + (n2 * h2) + (n3 * h3);
}
I could understand slight aliasing, ringing etc that might need to be filtered out, but the phasing/flanging effect is unexpected - what might be causing it, and how might I counter it?

Re: Phasing in chorus effect?

Posted: Tue Dec 20, 2022 6:04 pm
by UrbanCyborg
You might be running into Runge's phenomenon. If that's what's causing the phasing you're hearing, the S-Runge algorithm without resampling would handle it, although I'm not sure what the computational load might be. More, certainly. I don't see any other way a Lagrangian curve fit would mess with phase, especially in a time-dependent manner.

Reid

Re: Phasing in chorus effect?

Posted: Tue Dec 20, 2022 11:28 pm
by utdgrant
In the Zeit delay and Solaris Ensemble, I just used a naïve linear interpolation to calculate the 'fractional' buffer position sample value. It seems to work well enough to my ears.

Code: Select all

   antiAliasedDelayedValue = (1.0 - fractionalDelayCV) * delayedValueN +
                                             fractionalDelayCV * delayedValueNPlus1;
Where fractionalDelayCV is the fractional distance from one sample buffer value to the next (value 0.0 to 1.0).

In your code:

fractionalDelayCV = dMinus1
delayedValueN = buffer.readAt(ptrLeft);
delayedValueNPlus1 = buffer.readAt(ptrLeft + 1);

To get the full conext, you can download the full source code on the Dome Music Technologies Documentation Page.

Re: Phasing in chorus effect?

Posted: Wed Dec 21, 2022 4:12 pm
by poetix
Turns out it's not that deep - a matter of maintaining a small circular buffer, and moving the pointer forwards when it should have been moved back...

I am going to have to get better at writing automated tests for this kind of thing, clearly.

Re: Phasing in chorus effect?

Posted: Wed Dec 21, 2022 4:35 pm
by utdgrant
poetix wrote: Wed Dec 21, 2022 4:12 pm moving the pointer forwards when it should have been moved back...
Very easily done! :)

Glad you got it sorted.