2
$\begingroup$

I am trying to create a chirp signal in the frequency domain, by simply setting the magnitudes of each frequency bin to one, and then setting the phase delay function such that the resulting time delay increases for each frequency bin. I am trying to calculate the length of the resulting chirp from the phase delay function.

If the time delay for each frequency, $td(f)$, equals the period multiplied by the number of cycles introduced by the phase delay, and $\phi(f)$ is the phase delay in radians as a function of frequency, then

$$ td(f) = \frac{\phi(f)}{2\pi}\frac{1}{f} $$

And if we define $\phi(f)$ as,

$$ \phi(f) = 2\pi nf^2 $$

Then it follows that the time delay, $td(f)$, is given by,

$$ td(f) = \frac{2\pi nf^2}{2\pi}\frac{1}{f} = nf $$

And it seems obvious to me that the maximum time delay would occur when f is at its maximum $\frac{fs}{2}$, where $fs$ is the sampling frequency.

However, when I try and synthesise the signal (in Matlab),

% Create frequency axis (0 to nyquist)
fs = 44100;    
fAx = 0:1:(fs/2 - 1);

% Define n so td = nf = 0.25s, and define Phases
n = 0.25/(fs/2);
phi = -2*pi*n*fAx^2;

% Calculate the maximum time delay
td = n*(fs/2);

% Calculate the phase of each frequency up to nyquist
chirp_fft = exp(1i*phases);

% Create Hermitian symmetric signal and ifft
chirp_fft = [chirp_fft(1:end-1), 0, flip(conj(chirp_fft(2:end-1)))];
chirp = ifft(chirp_fft);

% Create time axis and plot chirp
tAx = 0:1/fs:(length(chirp) - 1)/fs;
plot(tAx, chirp)

So by my calculation, the chirp should have a maximum delay of 0.25 seconds, however, when I plot it:Resulting Chirp

It is 0.5s long. When I try this for other values, the resulting chirp is consistently twice as long as my calculation says it should be. Practically this is not a problem, but I'd really like to understand where I've gone wrong! Where is my missing factor of two?

$\endgroup$
  • $\begingroup$ Hint: use group delay instead of phase delay. Worked for me! $\endgroup$ – Olli Niemitalo Oct 26 at 9:25
  • $\begingroup$ This is how I started out initially. If the group delay is defined as, $\tau (f) = 2\pi nf$ , Then the phase delay can be found by integrating the group delay over from 0 to f, $\phi (f) = \int_{0}^{f} \tau (f) df$ Which gives the group delay, $\phi (f) = n\pi f^2$ So in this case, I still seem to get the same answer for my time delay calculation. $\endgroup$ – Leccy PW Oct 26 at 9:40
  • $\begingroup$ Also see Matt's answer here to the same problem: dsp.stackexchange.com/questions/31578/… it is just because frequency is the derivative of phase vs time and the phase is a quadratic for a chirp; $cos(x^2)$ $\endgroup$ – Dan Boschen Oct 26 at 16:27
2
$\begingroup$

Instead of phase delay $td(f)$, use group delay $\tau(f)$:

$$\tau(f) = -\frac{d}{d\omega}\phi(f),\tag{1}$$

calculated as the negative of the derivative of the phase $\phi(f)$ with respect to the angular frequency $\omega$, which is defined by:

$$\omega = 2\pi f\quad\Leftrightarrow\quad f = \frac{\omega}{2\pi}.\tag{2}$$

Using your phase shift $\phi(f)$:

$$\phi(f) = 2\pi n f^2 = \frac{n\omega^2}{2\pi}, \tag{3}$$

we get from Eq. 1:

$$\tau(f) = -\frac{d}{d\omega}\frac{n\omega^2}{2\pi} = \frac{2n\omega}{2\pi} = 2nf.\tag{4}$$

This should explain your empirical results, considering that here $\tau(f) = 2\,td(f)$.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.