[][src]Function periodicsynth::synth

pub fn synth(samples: &mut Vec<f64>, pfunc: PerodicFunction, freq: f64)

Synthesizes a periodic waveform with a arbitary frequency and samplerate. Note that, frequency should be less than half the samplerate (as of the nyquist theorem).

Functions implemented:

  • Sine
  • Square
  • Triangle
  • Sawtooth

Note: the size of the output vector is considered the samplerate, the output vector must be resized before synthesizing.

Arguments

  • samples — Vector to render oscillated samples into.
  • pfunc — Periodic function used to oscillate.
  • freq — Frequency of the function to oscillate on.