Welcome, Guest
Username: Password: Remember me

TOPIC: Phase shift, time delay, group delay...

Phase shift, time delay, group delay... 5 years 8 months ago #12268

  • Jim the Oldbie
  • Jim the Oldbie's Avatar
  • Offline
  • Gold Boarder
  • Posts: 250
  • Thank you received: 75
  • Karma: 29
Hello All,

Please forgive me if this is the wrong place for such a question. But you guys have a pretty good handle on this stuff, so I'm hoping one of you might have time to clarify something for me.

I think I have a reasonably good understanding of phase shift, time delay, and group delay, and how they differ from each other. But I get confused when I see them discussed separately, because it makes it appear as if they are easily distinguishable from each other in an existing circuit or device. When we measure the output of a system, we can see that some frequencies are offset in time from others by varying amounts. But how do we determine what proportion of this offset is caused by phase shift, how much of it is time delay, how much is group delay? Is this even possible? Do we have to know each of the contributing factors individually (filter topology, individual driver characteristics, box design, etc. etc.), and "add them up?" Or is it even necessary to think of it this way?

I hope the above makes some sort of sense. I can see where rePhase might render moot most of the above, but it also seems to me that some understanding of this question might be required in order to get the best results from this very interesting tool. Thanks for any help you can provide.

-- Jim
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12274

  • john.reekie
  • john.reekie's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 3481
  • Thank you received: 1498
  • Karma: 137
Hi Jim, if you have no alteration to the signal other than a time delay, you have a linear phase shift. For example, suppose you had no alteration to the signal other than a time delay of 10 ms. You would measure a phase shift of 360 deg at 100 Hz. At 50 Hz, 180 deg; at 200 Hz, 720 deg.

Turning it the other way around, if you measured those phase shifts, then that corresponds to a constant time delay (10 ms). Usually you move the time reference point so that the phase is easier to comprehend - i.e. move it by 10 ms, and all the phase shifts become zero.

Now, think about the relationship between time, phase and frequency. With a phase shift of 180 deg at 50 Hz and 360 deg at 100 Hz, what is the slope of that curve? it is 180/50 deg/Hz, or PI/50 radians/Hz, or 1/(2*50) cycles/Hz (since one cycle = 2PI radians) = 0.01 seconds. So, the slope of the curve is the time delay.

Suppose instead that phase is not linear. In that case, whereever you put the time reference point, some frequencies will not have zero phase shift. Suppose you measured 0 degrees at 50 Hz, 90 deg at 100 Hz, and 360 deg at 200 Hz. Phase varies with frequency in a non-linear way. What is the relationship of phase with time? As before, we take the slope (i.e. the differential) of the phase shift curve to get a time value. Unlike before, this value is now not constant with frequency, but varies. That's the group delay.

With the numbers just given, the group delay at 100 Hz would be around 10 ms at 100 Hz. You'd need a complete curve though. It would be very neat if rephase could display group delay, actually.

With rephase (and a suitable convolution engine), you can linearize the phase shift of the system. That is, "undo" its phase shifts. If phase is linear, group delay is constant; move the time reference, and it's zero. Exactly where the phase shifts are occurring (to your question about crossover, drivers, etc) doesn't really matter as long as you can measure the complete response. rephase does supply some built-in filters for crossover and box phase, which in my experiments so far get you most of the way there.

Hope that helps (and that the explanation is correct... any corrections by anybody are welcome...!)
I am not miniDSP support.

"You must ask the right questions." - Dr. Alfred Lanning's hologram.
-> Have you read the User Manual??
-> Have you drawn and posted a diagram?
-> Have you posted a screenshot?
-> Have you posted your config file?
The administrator has disabled public write access.
The following user(s) said Thank You: Jim the Oldbie, denver8me4dinner

Phase shift, time delay, group delay... 5 years 8 months ago #12279

  • Jim the Oldbie
  • Jim the Oldbie's Avatar
  • Offline
  • Gold Boarder
  • Posts: 250
  • Thank you received: 75
  • Karma: 29
john.reekie wrote:
Hi Jim, if you have no alteration to the signal other than a time delay, you have a linear phase shift. For example, suppose you had no alteration to the signal other than a time delay of 10 ms. You would measure a phase shift of 360 deg at 100 Hz. At 50 Hz, 180 deg; at 200 Hz, 720 deg.

Turning it the other way around, if you measured those phase shifts, then that corresponds to a constant time delay (10 ms). Usually you move the time reference point so that the phase is easier to comprehend - i.e. move it by 10 ms, and all the phase shifts become zero.

Yup, this is how I've been seeing things, so far so good...

john.reekie wrote:
Now, think about the relationship between time, phase and frequency. With a phase shift of 180 deg at 50 Hz and 360 deg at 100 Hz, what is the slope of that curve? it is 180/50 deg/Hz, or PI/50 radians/Hz, or 1/(2*50) cycles/Hz (since one cycle = 2PI radians) = 0.01 seconds. So, the slope of the curve is the time delay.

Suppose instead that phase is not linear. In that case, whereever you put the time reference point, some frequencies will not have zero phase shift. Suppose you measured 0 degrees at 50 Hz, 90 deg at 100 Hz, and 360 deg at 200 Hz. Phase varies with frequency in a non-linear way. What is the relationship of phase with time? As before, we take the slope (i.e. the differential) of the phase shift curve to get a time value. Unlike before, this value is now not constant with frequency, but varies. That's the group delay.

With the numbers just given, the group delay at 100 Hz would be around 10 ms at 100 Hz. You'd need a complete curve though. It would be very neat if rephase could display group delay, actually.

Aha, this is the part I have not been seeing. I still don't fully understand it (my maths are a bit sketchy), but I know if I read it over & over a few more times, the light bulb will switch on! :lol:

john.reekie wrote:
With rephase (and a suitable convolution engine), you can linearize the phase shift of the system. That is, "undo" its phase shifts. If phase is linear, group delay is constant; move the time reference, and it's zero. Exactly where the phase shifts are occurring (to your question about crossover, drivers, etc) doesn't really matter as long as you can measure the complete response. rephase does supply some built-in filters for crossover and box phase, which in my experiments so far get you most of the way there.

Hope that helps (and that the explanation is correct... any corrections by anybody are welcome...!)

I have a feeling that your explanation above will be a turning point in my understanding of all this. Thanks for taking the time to reply, John.

-- Jim
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12303

  • John Ashman
  • John Ashman's Avatar
  • Offline
  • Gold Boarder
  • Posts: 226
  • Thank you received: 23
  • Karma: 5
john.reekie wrote:
Hi Jim, if you have no alteration to the signal other than a time delay, you have a linear phase shift. For example, suppose you had no alteration to the signal other than a time delay of 10 ms. You would measure a phase shift of 360 deg at 100 Hz. At 50 Hz, 180 deg; at 200 Hz, 720 deg.

John, if there is a pure time delay, such as the 10ms, that doesn't induce any phase shift (done properly). Phase shift occurs when the signal is delayed in proportion to the frequency. So not everything would be 10ms. The amount of time delay would vary from almost 0ms to some other figure. There is no phase shift in a time delay because all of the signals are synced up and the wave form is identical.

For instance, if you do a phase delay of 180 degrees, then all of the individual frequencies would be delayed by a time factor corresponding to half a wavelengh in time, which is to say, a much longer delay for low frequencies than high requencies.
Last Edit: 5 years 8 months ago by John Ashman.
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12318

  • john.reekie
  • john.reekie's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 3481
  • Thank you received: 1498
  • Karma: 137
John Ashman wrote:
john.reekie wrote:
Hi Jim, if you have no alteration to the signal other than a time delay, you have a linear phase shift. For example, suppose you had no alteration to the signal other than a time delay of 10 ms. You would measure a phase shift of 360 deg at 100 Hz. At 50 Hz, 180 deg; at 200 Hz, 720 deg.

John, if there is a pure time delay, such as the 10ms, that doesn't induce any phase shift (done properly).

You are not understanding the purpose of the example. Let me try again :)

Phase is related to time and frequency, specifically a time delay of 1/f is a 360 phase shift. Correct?

Now consider different frequencies, and compare the signal "before" the time delay and "after" the time delay. What is the relationship between the phase of the input signal and the output signal? To make it concrete, say the delay is 10 ms. At 100 Hz, the time delay delays the waveform by a full cycle, so the phase shift is 360 degrees. Right? At 50 Hz, the time delay delays the waveform by half a cycle, so the phase shift is 180 degrees. Right?

As I explained, this is a linear phase shift i.e. the amount of phase shift is proportional to frequency. Yes, the shape of the waveform (any waveform) going in is the same as the shape of the waveform coming out, as you say. But still, the phase shift at different frequencies between the input and output signals is not zero. It is a linear phase shift.

If you are looking just at the components of a waveform, then usually you would shift the time reference to remove the absolute time delay. The reason I started with the example of time delay and linear phase shift is to introduce the notion that time is related to phase as the slope of the phase change. So, when you have a non-linear phase shift, the slope of that curve is the frequency-dependent delay i.e. the group delay. I find that this helps to understand what group delay means in a more concrete way than just saying "group delay is the negative derivative of phase". :)
I am not miniDSP support.

"You must ask the right questions." - Dr. Alfred Lanning's hologram.
-> Have you read the User Manual??
-> Have you drawn and posted a diagram?
-> Have you posted a screenshot?
-> Have you posted your config file?
Last Edit: 5 years 8 months ago by john.reekie.
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12320

  • John Ashman
  • John Ashman's Avatar
  • Offline
  • Gold Boarder
  • Posts: 226
  • Thank you received: 23
  • Karma: 5
But it's not a phase shift at all. A phase shift distorts the signal and while the ear isn't that adept at hearing it, even at extreme levels, it shows up as an obvious change in the signal shape. A delay of one cycle is simply a delay. If you delay all frequencies by one cycle, then that his a phase delay. If you delay everything by a specific time, then that is simply time delay. Phase shift is a relative thing. If you delay a pure sine wave by half a cycle, you're really not shifting phase, unless there is another frequency to which it is related.

If you're using it to make the point, I just am completely misunderstanding the point you're making, unless you're trying to equate a term I've never even heard of, "linear phase shift" with "time delay", which I think entirely muddies the waters as there is no phase shift.
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12321

  • john.reekie
  • john.reekie's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 3481
  • Thank you received: 1498
  • Karma: 137
Hi John, you would be familiar with the term "linear phase filter", though? (DEQX uses it to describe what their product does.) Here's a definition: "Linear phase is a property of a filter, where the phase response of the filter is a linear function of frequency, " (en.wikipedia.org/wiki/Linear_phase)

The article continues: "Since a linear phase ... filter has constant group delay, all frequency components have equal delay times. That is, there is no distortion due to the time delay of frequencies relative to one another.."

Hope that helps... (my emphasis added to quotes)
I am not miniDSP support.

"You must ask the right questions." - Dr. Alfred Lanning's hologram.
-> Have you read the User Manual??
-> Have you drawn and posted a diagram?
-> Have you posted a screenshot?
-> Have you posted your config file?
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12323

  • John Ashman
  • John Ashman's Avatar
  • Offline
  • Gold Boarder
  • Posts: 226
  • Thank you received: 23
  • Karma: 5
Ahhhhh. You mean a "linear-phase delay". Time delay, but sure, if you put a hyphen in there, it clears it up more. I was reading it like "linear phase-delay". Now having searched it, I see that the term is used with a hyphen between linear and phase to keep it clean. This is why I was confused. As you were.....just...you know, don't forget the hyphen ;)
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12336

  • Jim the Oldbie
  • Jim the Oldbie's Avatar
  • Offline
  • Gold Boarder
  • Posts: 250
  • Thank you received: 75
  • Karma: 29
Hi John, may I butt in with a quick question or two? Just trying to keep up here...

john.reekie wrote:
As I explained, this is a <em>linear</em> phase shift i.e. the amount of phase shift is proportional to frequency. Yes, the shape of the waveform (any waveform) going in is the same as the shape of the waveform coming out, as you say. But still, the phase shift at different frequencies between the input and output signals is not zero. It is a <em>linear phase shift</em>.

I understand what you're saying, but I must admit I've always been more comfortable thinking of a time delay as just a time delay, and not as a continuously (even linearly) varying phase shift. But maybe that's part of why I haven't been fully comprehending this stuff.

john.reekie wrote:
If you are looking just at the components of a waveform, then usually you would shift the time reference to remove the absolute time delay. The reason I started with the example of time delay and linear phase shift is to introduce the notion that time is related to phase as the slope of the phase change. So, when you have a <em>non-linear</em> phase shift, the slope of that curve is the frequency-dependent delay i.e. the group delay. I find that this helps to understand what group delay means in a more concrete way than just saying "group delay is the negative derivative of phase". :)

So let me try this out: On a graph of phase angle vs linear frequency, linear (pure?) phase shift is represented as a straight, sloping line (or if you prefer, a sawtooth as the phase wraps); and any deviation from that straight line is the group delay?

-- Jim, fingers crossed
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12337

  • Jim the Oldbie
  • Jim the Oldbie's Avatar
  • Offline
  • Gold Boarder
  • Posts: 250
  • Thank you received: 75
  • Karma: 29
Jim the Oldbie forgot something when he wrote:
So let me try this out: On a graph of phase angle vs linear frequency, linear (pure?) phase shift is represented as a straight, sloping line (or if you prefer, a sawtooth as the phase wraps); and any deviation from that straight line is the group delay?

Oops! One more detail: The above example assumes a time delay of > zero? (Otherwise no slope, heh)
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12340

  • john.reekie
  • john.reekie's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 3481
  • Thank you received: 1498
  • Karma: 137
Jim the Oldbie wrote:
Hi John, may I butt in with a quick question or two?

Of course! It's your thread... :)
I must admit I've always been more comfortable thinking of a time delay as just a time delay, and not as a continuously (even linearly) varying phase shift.

I'd usually think of it that way too (as a simple time delay). But it's important (per your original question) to understand the relationships between things too. You'll notice this (for example) if you try to measure phase shift of a speaker and don't have the time reference in the exact right spot.
So let me try this out: On a graph of phase angle vs linear frequency, linear (pure?) phase shift is represented as a straight, sloping line (or if you prefer, a sawtooth as the phase wraps);

On a graph of phase angle vs linear frequency, a pure time delay is represented as a straight, sloping line (or if you prefer, a sawtooth as the phase wraps)
and any deviation from that straight line is the group delay?

If the line is not straight, then you don't have a constant group delay.
I am not miniDSP support.

"You must ask the right questions." - Dr. Alfred Lanning's hologram.
-> Have you read the User Manual??
-> Have you drawn and posted a diagram?
-> Have you posted a screenshot?
-> Have you posted your config file?
The administrator has disabled public write access.

Phase shift, time delay, group delay... 5 years 8 months ago #12341

  • john.reekie
  • john.reekie's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 3481
  • Thank you received: 1498
  • Karma: 137
I need to add (sorry but it's late here...): your original quote based on my earlier statements "linear (pure?) phase shift is represented as a straight, sloping line" is fine too, it's just not very clear (my fault)
I am not miniDSP support.

"You must ask the right questions." - Dr. Alfred Lanning's hologram.
-> Have you read the User Manual??
-> Have you drawn and posted a diagram?
-> Have you posted a screenshot?
-> Have you posted your config file?
The administrator has disabled public write access.

Phase shift, time delay, group delay... 3 years 11 months ago #21763

  • Richard
  • Richard's Avatar
  • Offline
  • Expert Boarder
  • Posts: 127
  • Thank you received: 68
  • Karma: 13
PHASE GRAPH LINES

Reading the phase vs frequency response graph across horizontal axis from left (eg. 20Hz) to right (eg. 20,000Hz) with vertical axis phase +180 degrees at top, 0 degrees in centre, and –180 degrees at the bottom…

Flat horizontal line on 0 degrees = your two signals are in perfect sync at all frequencies. Hooray. However, that doesn’t mean they’re both “perfect” – oh no! – flat line doesn’t mean they’ve suffered no phase distortion anywhere, in fact they could both have been equally badly phase skewed by your D/A and A/D converter chains going along into your FFT analyser, but the transfer function graph just shows the relative phase difference between them, which, if they’ve both been skewed equally, it won’t show up on the A vs B graph because there’s no relative difference.

Flat horizontal line at 180 degrees = your signals are in perfect sync at all frequencies but with inverted polarity. But as above it just means you have a match, not that they’re intrinsically perfect and devoid of phase distortion.

Graph sloping downwards (going from left to right) means transfer function “output” (test signal) comes later after the “input” (reference signal). For a simple fixed time delay such as latency, if graph’s frequency Hz has linear horizontal axis, then you get a dead straight line slope gradient which repeats as it has to cross over the +180/-180 degree border and wraps around for each successive repeat beyond 180 degrees, but for pure time delay, these are evenly spaced and the Gradient of the slope proportional to the delay. However MOST graphs show frequency Hz with a logarithmic horizontal axis, so then you get a gradually increasing gradient where the bass is gentle slope, midrange steeper, and treble very, very steep with lots of wrap-arounds. This is NORMAL look for a logarithmic Hz graph with a fixed time delay. A fixed delay like this means zero relative phase shift. At each given frequency the slope is proportional to the delay, but they’re not all the same anymore because the axis is logarithmic. You can work out the ratio of the difference in freq to the difference in phase degrees to calculate the time delay. A good book for this subject is Chapter 10, of Bob McCarthy “Sound Systems: Design And Optimization”

Graph sloping upwards (going from left to right) means transfer function “output” (test signal) is ahead of the “input” (reference signal), which typically implies that you’ve added too much compensation digital delay to your reference signal….

MEASURING PHASE WITH FFT ANALYSER

Because obviously sending test signal round a loop via output DAC, through amplifier, loudspeaker driver, a few feet of air (speed of sound approx 1 foot per millisecond), into Earthworks measuring mic, mic preamp, A/D converter, USB interface, Windows computer, etc. is bound to add considerable overall latency delay, you must take this into account with dual channel FFT analyser transfer function measurements.

If you don’t take that delay offset into account when running FFT software A vs B transfer function comparison, you’ll see a massive downwards slope with hundreds of wrap-arounds more and more intensely climbing into high freqs, because the output test signal coming back from the loop is at least something like 300 samples (7 milliseconds) or so behind the duplicate reference signal which you’re feeding directly into FFT also. So you add delay to reference to compensate, and watch the screen as the wrap-arounds unfold till you’re down to a fairly flat curve, and that’s probably the closest you can get to synchronizing your files for the FFT analysis benefit. Any relative freq vs phase shifts are then easier to observe in the graph shape. If you over correct, adding too much delay, the graph swings upwards more and more, meaning the reference input is lagging behind the test signal output.

Experimenting with FFT software on live audio input is the easiest way to see and understand the real behaviour of the phase vs frequency graphs, and FFT software can usually switch between log and linear Hz scales, and make things clear.

I can recommend “Visual Analyser” as the best free download FFT software for Windows, unless you’ve already bought SMAART or something.... There are also iPad apps like StudioSixDigital AudioTools, etc. Something like the MiniDSP USB Streamer can help you get clean high quality digital audio into your computer without going through a nasty computer soundcard's A/D converters.

WHY DOES PHASE SHIFT ANYWAY ?

Phase shift makes sense, just like frequency response and EQ makes sense…

Phase shift occurs in simple analogue filter circuits because they use capacitors to impede low frequencies but conduct high frequencies, and inductors to impede high frequencies while conducting low frequencies. eg. HPF for instance is an RC circuit with capacitor and resistor. At low freqs capacitor charges up so fast it’s in phase with the AC voltage, up to the point where it impedes the current fully, so at AC voltage maximum peak there is no current flowing through. At high freqs the slow capacitor charging time means it lags behind the AC voltage, but when AC supply voltage reduces to minimum zero, current can most easily flow back opposite direction from charge stored in capacitor and so the current flow actually peaks when the voltage crosses zero line, and then it gets increasingly impeded in other direction by the negative voltage again and so on. So the peak current flow pattern is 90 degrees out of phase with the AC voltage’s peak sinusoidal pattern. We’re not simply talking about domestic AC mains at 50Hz fixed freq, but alternating audio signal voltages containing all different frequencies which are an overall Fourier sum of all those frequencies they contain, for which all those different phase shifts are relevant, so the capacitor HPF filter which has that HPF shape impeding low frequencies also shows that phase response shape across those same frequencies. Plotted on a graph, the phase response is the first derivative of amplitude response, mathematically speaking. These basic textbook analogue filters are recreated digitally within DSP by using the same mathematical formulae so they behave in the same way (digital IIR filters) with the same phase shifts. More complicated DSP formulae can create more complicated filter behaviour such as FIR filters with lots of taps. (The taps represent the number of mathematical coefficients of the very complex polynomial equation that defines the filter shape.)

Phase shift occurs in speakers because they also build up energy in resonances at various frequencies which takes time and their mechanical / kinetic motion behaviour vs input signal voltage has similar minimum phase relationship to the applied signal voltage, and the maths would prove this – but very complicated with lots of Theile / Small parameters, etc.
Vents also have phase shift because the resonance takes time to build up and to die away. Linearising phase via digital FIR processing doesn’t stop that physics from happening, it just allows you to move the build-up of that energy to begin earlier until all your energy peak centres are time-aligned together in sync, for constant group delay across bandwidth, looking at where the energy peaks, but each freq resonance decay (and pre-ring with FIR) will still be there, and you’ll see it on a waterfall graph, but at least they all occur in unison and it feels more correct.

Group delay is just another way of plotting phase response as millisecond delay vs frequency, which is perhaps an easier way to visualize it, because delay is viewed in real-world units like milliseconds, rather than “phase degrees” which requires more abstract thought, compounded by wrap-arounds, relativity and logarithmic graphs.
Impulse response is another way of viewing this information which is even more abstract to visualise how you’re deviating from the target.

The target is only an optimal correction for a given loudspeaker, though…
eg. You can’t make a vented cabinet have the impulse response of a closed box, but you can get the bulk of the vented cabinet’s energy peak (which would have lagged far behind in the low bass) to occur at time “t” alongside all the other freqs, using OpenDRC with rePhase generated FIR filter. If you want a perfect speaker, you’ll still have to buy the best components with high BL factor, lightweight moving mass cone, high linear xmax, etc. and have a very rigid, well damped cabinet and class A or AB amplifier with good damping factor, etc. There’s no such thing as a free lunch. You can’t just FIR correct any cheap crappy speakers and make them sound like Dynaudio Consequence, because although they’d be nominally flat and phase coherent, they won’t get a faster rise time or damping, or higher output capacity where they otherwise bottom out or have cone break-up modes. The group delay and phase response might be a straight line, but then that speaker is optimised perhaps, but not eradicated of all its inherent physical limitations, and those will still be subject to physics, and its weaknesses or indeed qualities will be there in what you hear.
Last Edit: 3 years 11 months ago by Richard.
The administrator has disabled public write access.
The following user(s) said Thank You: devteam, Thunderstruck

Phase shift, time delay, group delay... 2 years 2 months ago #32805

  • hadisumoro
  • hadisumoro's Avatar
  • Offline
  • Junior Boarder
  • Posts: 33
  • Thank you received: 14
  • Karma: 1
Last Edit: 2 years 2 months ago by hadisumoro.
The administrator has disabled public write access.
The following user(s) said Thank You: devteam

Phase shift, time delay, group delay... 2 years 2 months ago #32926

  • captgnarly
  • captgnarly's Avatar
  • Offline
  • Senior Boarder
  • Posts: 60
  • Thank you received: 15
  • Karma: 5
Thank you Hadi,
that is really a great article on prosoundweb, one of the clearest, best explanations I've encountered.
Mark
The administrator has disabled public write access.
Moderators: devteam