Sawtooth wave with offset#
-
float uz_wavegen_sawtooth_sample_with_offset(uz_wavegen_sawtooth_t *self, float amplitude, float frequency_Hz, float offset)#
Returns one sample of a sawtooth wave with a configurable DC offset.
- 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
offset – DC offset added to the sample
- Returns:
Returns one sample for current system time
Example#
1#include "uz_wavegen.h"
2int main(void) {
3 float amplitude = -5.0f;
4 float frequency_Hz = 10.0f;
5 float offset = 1.0f;
6 uz_wavegen_sawtooth_t* sawtooth = uz_wavegen_sawtooth_init();
7 float output = uz_wavegen_sawtooth_sample_with_offset(sawtooth, amplitude, frequency_Hz, offset);
8}
Description#
This function calculates a sawtooth with specified offset. The phase is tracked in the wavegen instance and advanced on each sample call.

Fig. 338 sawtooth wave with offset