Phasing in chorus effect?

Post Reply
poetix
Posts: 54
Joined: Mon Nov 28, 2022 3:26 pm

Phasing in chorus effect?

Post 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?
London, UK
Developer, Vulpus Labs
Musician, w/trem
UrbanCyborg
Posts: 588
Joined: Mon Nov 15, 2021 9:23 pm

Re: Phasing in chorus effect?

Post 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
Cyberwerks Heavy Industries -- viewforum.php?f=76
User avatar
utdgrant
Posts: 535
Joined: Wed Apr 07, 2021 8:58 am
Location: Scotland
Contact:

Re: Phasing in chorus effect?

Post 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.
______________________
Dome Music Technologies
poetix
Posts: 54
Joined: Mon Nov 28, 2022 3:26 pm

Re: Phasing in chorus effect?

Post 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.
London, UK
Developer, Vulpus Labs
Musician, w/trem
User avatar
utdgrant
Posts: 535
Joined: Wed Apr 07, 2021 8:58 am
Location: Scotland
Contact:

Re: Phasing in chorus effect?

Post 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.
______________________
Dome Music Technologies
Post Reply

Return to “Module Designer”