Sawtooth wave#

type uz_wavegen_sawtooth_t#
float uz_wavegen_sawtooth_sample(uz_wavegen_sawtooth_t *self, float amplitude, float frequency_Hz)#

Returns one sample of a sawtooth wave.

Parameters:
  • self – Pointer to uz_wavegen_sawtooth instance

  • amplitude – Amplitude for the sawtooth wave

  • frequency_Hz – Frequency for the sawtooth wave in Hz. Only positive values are permitted

Returns:

Returns one sample for current system time

Example#

Listing 89 Example function call to sawtooth wave generator#
1#include "uz_wavegen.h"
2int main(void) {
3   float amplitude = 10.0f;
4   float frequency_Hz = 5.0f;
5   uz_wavegen_sawtooth_t* sawtooth = uz_wavegen_sawtooth_init();
6   float output = uz_wavegen_sawtooth_sample(sawtooth, amplitude, frequency_Hz);
7}

Description#

This function calculates a sawtooth. The phase is tracked in the wavegen instance and advanced on each sample call.

Figure made with TikZ

Fig. 337 sawtooth wave