Suggestion for Matt: How to measure phase shift


I am testing class-D amps, and they often have a significant latency, and that is the reason for the measured signal phase values to be meaningless, both in the main window and in plugins.

There should be another Latency Compensation field in settings, in which user can enter the reference delay between input and output signal at arbitrary chosen frequency, let’s say 1000Hz, and that would predefine phase shift of 0° for that frequency. There could be a button [Accept current delay as the reference latency], for example.
For subsequent measures at different frequencies, the QA Analyzer would subtract the reference delay from measured delay, and then calculate phase shift.

Phase with delay is a very tricky issue. If you don’t specify the delay precisely, then you are left with meaningless phase that is unwrapping quickly that tells you nothing

Consider a 1 kHz sine with a period of 1 mS. If you know the system has precisely a 200.0 mS delay, then you can determine the shift of the 1 kHz. But how do you know if the system delay 199.5 mS with 180 degrees of shift at 1 kHz or 200 mS with 0 degrees at 1 kHz? If you don’t get it precisely right, then your phase measurement across the band is meaningless.

Now, imagine a system with precisely 192.377 mS of delay (unknown to you) and 16 degrees of phase shift at 1 kHz. How can hope to learn that? If you ballpark the delay at 192.4 mS based on say, a scope measurement, then the 23 uS of error is appears as ~90 degrees of phase error at 10 kHz.

It’s very tricky.

For all phase measurements, you need a reference point. The reference point for the QA401 phase measurements is the output before the DAC. What would make sense is a two-channel approach, where the right channel would be used as the reference and the left channel as the input.

A third approach involves centering the recovered impulse response in the window. That can be seen in “Amp FrequencyResponseChirp” plugin (tick the phase box). In order for that work well, you need a reasonably flat passband. But you will still be thwarted by the sharp filters in the ADC and DAC–you can see this in loopback. Remember, a low pass filter will start showing phase changes a decade below your cutoff frequency. In the plot below, this is a chirp with phase plotted. In dark blue you can see the ADC/DAC filters roll off very 50 kHz or so, but you can also see the phase has changed 45 degrees at 5 kHz. A measurement that relied on the right channel as the reference would nullify this.

So, I think your goal is correct, but I think the better way to achieve would be to add a checkbox to the plugin that allowed you specify right-channel as the reference input.


Hi Matt,

I’ll try to describe my user case for measuring the phase shift.
I am testing a D-class amplifier.
I took 1kHz as the reference frequency for the phase shift of 0°. QA Analyzer shows delay 120μs, and I confirmed that value using method you described in topic

After that easy part, I measured the delay for the whole frequency range, stepping 1/3 octave. The larger frequency, the harder is to determine the right moment to mark, but it helps that I don’t expect the mark to jump more than half period between two steps (“reasonably flat passband”).
It would be easier, BTW, if the QA Analyzer would mark time where curves passes x-axis.
The delays I measured where from -3.97μs@31.7Hz to 129μs@17758Hz. To be sure to avoid transients, I took time points near to the end of measuring period, about 0.68ms, carefully counting number of periods before the output and input amplitudes start to fall at the end of measuring period (hence zoom bug I reported two days ago).
The Excel table did the rest: calculates phases from delays, I got from -46.6°@31.7Hz to 60.7°@17758Hz.

Now, I believe that the whole process can be automatized in QA Analyser, no need for the second channel as the reference, at least for the described case.

For the other cases, involving huge jitter and delays, and also when using external generator, where few ns differences in sampling period between QA401 and DAC can accumulate to several μs delay, the second channel would be the solution.

Hi @zoran4afc,

If I understand correctly, this approach would still suffer whatever phase contribution the ADC would have at, say, 20 kHz is that right?

Thanks, Matt

Hi Matt,

good point, I agree that my manual method suffers from ADC phase contribution, but that phase contribution for QA401’s ADC can be determined and then compensated, i.e. baselined.

Best regards