calf-studio-gear / calf

Developers repository of Calf Studio Gear. Expect some issues when using it for production.
http://calf-studio-gear.org
GNU Lesser General Public License v2.1
685 stars 95 forks source link

Phase reversal in X-Over at 12 db/octave? #194

Open haasn opened 6 years ago

haasn commented 6 years ago

Hey,

While playing around with the calf crossover plugin, I noticed that at 12 dB/octave ("LP2" setting), there's a phase reversal at the crossover point. This does not happen at 24 dB/oct ("LP4") or 48 dB/oct ("LP8").

I noticed this by playing white noise through the crossover plugin and measuring the frequency response of both the high and low signals summed together using the calf "Analyzer" plugin. At 12 dB/octave, there's both a clear dip in the FR response at the crossover frequency, and if I hook up the low and high signals to separate channels, the "phase correlation" diagram is rotated 90°. Inverting either one of the channels (using the "phase" button) gets rid of this effect. At 24 and 48 dB/octave, the situation is reversed, with there being no dip if both channels are left as-is, and a dip+phase rotation if one of the two channels is inverted.

Is this intentional, and if so, why? How come it only affects the 12 dB/octave setting?

haasn commented 6 years ago

Example screenshots demonstrating the effect.

Frequency response of averaged (summed) low and high channels

fr_dip

Phase rotation of a sine wave at the crossover frequency

pr_sine

(You can observe that the phase response line is horizontal at the crossover frequency, rather than vertical)

Flicking the "phase" switch on one of the two channels solves both issues, i.e.

Corrected frequency response when the phase is inverted

fr_flat

haasn commented 6 years ago

FWIW I confirmed this effect using a white noise generator, a microphone, and a speaker+subwoofer pair connected to the crossover. At 12 dB/octave I notice a clear dip in the white noise frequency response, and the sine wave frequency response is attenuated. Inverting either output improves the result. At 24 dB/octave the effect is not present.

haasn commented 6 years ago

While investigating this, I came across another extremely surprising result: Running multiple X-Overs as part of the same calfjackhost, I measure a (consistent) phase separation between them?!

multiple xovers

The out #1 of both xovers feeds into the left/right channels of the analyzer, respectively. Notice the phase separation between them, even though they should be delivering the same signal. Directly connecting the sine wave to the analyzer does not show this effect.

If I run two xovers in two separate calfjackhost instances, I get the expected result:

single xover

As you can see, in this case the samples line up perfectly, drawing a straight line.

Why would having multiple plugins in the same calfjackhost introduce such a significant delay between them? I tried removing and re-adding the second xover at runtime, and the results are always the same - so it's not some weird timing quirk.

haasn commented 6 years ago

Actually, the last issue seems to do with the order of the plugins. It also happens in carla. If I have them in the order "xover, analyzer, xover" I get the phase separation. But if I instead have them in the order "xover, xover, analyzer" or "analyzer, xover, xover", I get the expected result.

I didn't even know the order of plugins in the rack made any difference! To be clear, I'm not talking about the order they're connected in - the connections are always the same in my tests.

richardpl commented 3 years ago

Calf Xover code is missing inverters and allpass components to function properly.