Efficient computing of a sinusoid.

Namespace: dsp

Prototype

static Vecf sigsin(float f, int n)

Parameters

fNormalized frequency of the sinusoid (between -0.5 et 0.5)
nNumber of points to generate.

Returns

Real vector defined by: \[ y_k = \sin\left(2\pi k f\right),\quad k = 0\dots n-1 \]

Description

This function generates a real sinusoidal signal, based on an harmonic oscillator (which is far more efficient than by using the trigonometric functions of the standard library). Note however that if \(n\) is a big number, there can be some divergence, both in gain and in phase.

Example


  // Fréquence = 0.01, 200 échantillons
  soit x = sigsin(0.01, 200);
  Figure f;
  f.plot(x);

See also

sigcos(), sigexp(), sigcar(), sigtri()