# Chirp after T seconds

Suppose we have this signal from this wiki page

$$a(t)=\sin(\varphi_o + f_0t + (f_1-f_0)t^2/T)$$

The article tells that T is a period of chirp modulation in which frequency changes. So my question is how to create signal with constant $$f_1$$ frequency after T?

how to create signal with constant $$f_1$$ frequency after T?

Find the instantaneous phase at the end of the $$T$$ interval and keep adding it to the phase that makes the $$\sin()$$ "go round".

A plain simple oscillator at some frequency $$f$$ has its phase increasing at a constant rate.

Here is an example (in GNU Octave but easily transferable to other platforms as well):

Fs = 44100; % Sampling frequency in Hz
T = 1; % Total duration of the signal in seconds
f = 120; % Frequency of the oscillator
t = 0:(1./Fs):(T - (1./Fs)); % Time vector
p = 2.0 .* pi .* t; %Phase vector
y = sin(f.*p);


Now y contains our 120 Hz sinusoid sampled at 44.1kHz.

Notice here that phase (p) is a "straight line" that grows at a constant rate of $$\frac{2 \pi f}{Fs}$$.

When the oscillator is "chirping", the rate of change of the phase is variable. For example:

Fs = 44100; % Sampling frequency in Hz
T = 1; % Total duration of the signal in seconds
f0 = 1; % Start chirp at
f1 = 120; % end chirp at (Better keep f1>f0)
t = 0:(1./Fs):(T - (1./Fs)); % Time vector
p = 2.0 .* pi .* t; %Phase vector
y = sin(f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2));


Now, this looks like:

And the rate of change of the phase of the $$\sin$$ is:

Now, from the first example, the phase "step" is f.*p(2)-f.*p(1) == 0.017097 and from the second example, after doing:

s = diff(f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2)); % Get the first derivative of phase to find the **rate of change**.


The "last" rate of change is s(end) == 0.017097.

So, to have the oscillator stay at the chirp's concluding frequency, keep accumulating the phase at the constant rate you are after from the last known value of the chirp's phase (to avoid phase jumps). For example:

r = f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2);  % The phase as above.
z = r(end) + cumsum(ones(1,T.*Fs).*0.017097); % A running sum of duration T.*Fs (samples).


Now, if you feed the combined result of r, z into the oscillator y with something like y = sin([r,z]); it would look like:

...with a rate of change of:

Hope this helps.

• Thank you! I thought about that I need to fix the phase of the signal. – lisichka ggg Apr 24 at 16:40
• @lisichkaggg No worries, all the best with your project. – A_A Apr 24 at 20:31

If you want the frequency to linearly increase from $$f_0$$ to $$f_1$$ (i.e., a chirp) then the solution is given in the answer to this related question.

If you want a sinusoid with a constant frequency $$f_0$$ for $$t, and with frequency $$f_1$$ for $$t>T$$, then - since the phase is ($$2\pi$$ times) the integral of the frequency - the corresponding phase is given by

$$\frac{\phi(t)}{2\pi}=\begin{cases}f_0t,&tT\end{cases}$$

where I've chosen the constants in such a way that the phase is continuous at $$t=T$$.

The desired signal is given by

$$x(t)=\sin(\phi(t))\tag{1}$$

• The seconds answer is what I need. Thanks for answer! – lisichka ggg Apr 24 at 14:53