delay
FFT-based delaying of a vector.
Namespace: dsp::fourier
Prototype
Vector<T> delay(const Vector<T> &x, float τ)
Parameters
x | Vector of samples. |
τ | Delay to be applied, in number of samples (can be positive or negative, and not necessarily an integer). |
Returns
Time shifted vector.
Description
Apply a fractionnal delay to the input signal:
The delay can be positive (to effectively delay the signal), or negative (to have the signal earlier).
- Note
- If the request delay is an integer, a simple shift of the vector is done. Otherwise, the delay is applied in the frequency domain (after the input signal has been zero-padded so as to mitigate border effects):
\[ Y_n = X_n \cdot e^{\frac{-2\pi\mathbf{i}\tau \cdot n}{N}} \]
Example
// Signal test : gaussienne
soit x = siggauss(20);
// Délais de 1 échantillons
soit x1 = délais(x, 1),
// Délais de 1.5 échantillons
x2 = délais(x, 1.5),
// Avance de 1 échantillons
x3 = délais(x, -1);
Figure f;
f.plot(x, "b-o" , "x" );
f.plot(x1, "g-o" , "x1 (+1)" );
f.plot(x2, "m-o" , "x2 (+1,5)" );
f.plot(x3, "c-o" , "x3 (-1)" );