source_ohc

Generation of an exponential signal through a harmonic oscillator.

Namespace: dsp

Prototype

sptr<Source<cfloat, OHConfig>> source_ohc(float freq)

Parameters

freqNormalized frequency of the exponential (between -0.5 et 0.5).

Returns

Complex data source.

Description

This function returns a data source, which can be called several times (generation of a continuous flow of samples, contrary to sigexp(), which can only generate a fixed number of samples).

The quadrature oscillator is based on simple first order recursive (complex) filter: \[ z_k = z_{k-1} \cdot e^{2\pi\mathbf{i}f} \] which enables to generate an exponential signal: \[ z_k = e^{2\pi\mathbf{i}kf} \]

Note
To generate an exponential of fixed frequency, this method will be more efficient than using the trigonometric functions of the standard library.


Example

  // Set oscillator frequency = one 40th of the sampling frequency
  soit ol = source_ohc(0.025);
  // Generate 200 samples
  soit x = ol->step(200);
  Figure f;
  f.plot(x, "", "x");

See also

source_ohr(), sigexp()