[LAD] Determining Phase

Fons Adriaensen fons at linuxaudio.org
Sun Jun 26 12:56:43 UTC 2011

On Sun, Jun 26, 2011 at 10:44:33AM +0200, pshirkey at boosthardware.com wrote:

> I think you understood what I am looking for below.
Unfortunately, I can only guess what the context of
your question was, and I'd probably be wrong :-(

> Does anyone have a code example for this type of filter?

The example Erik gave is a perfect one.
As said, there's no such thing as 'the phase of a waveform'.
For a general waveform, and no matter what interpretation
of 'phase' you'd choose, it would be a function of frequency.

If the waveform is cyclic (e.g. a triangle wave) you could
define some 'phase' value on it, using either the fundamental
frequency or some arbitrary point in the waveform as reference.

But even for a simple sine wave the term 'phase' can mean
different things. Take

  s(t) = sin (w * t + phi), with w = 2 * pi * f

All the following are correct:

(1) If you take 'phase' as a property of s(t) as a
whole, you could say its phase is phi.

(2) If look at absolute phase at time t, it would
be w * t + phi.

(3) If you use t = 0 as a phase reference point, the
phase at time t would be w * t.

It all depends on the context which one you use.

To add some more ambiguity, compare

  s1(t) = sin (w * t + phi) 
  s2(t) = cos (w * t + phi)

In many cases it doesn't matter which one you use when 
defining or explaining something. If you have a maths
background you'd prefer cos() for real signals, since
that's the real part of the complex single frequency
signal exp(j * (w * t + phi)). If you are defining e.g.
a oscillator opcode in a synthesis system you'd prefer
sin(), as this starts at zero for phi = 0. In both
cases you could legitimately refer to 'phi' as 'the
phase'. But the two waveforms are 90 degrees out of
phase w.r.t. each other...



More information about the Linux-audio-dev mailing list